]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamDeviceFactory_p.cpp
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / api / internal / BamDeviceFactory_p.cpp
1 // ***************************************************************************
2 // BamDeviceFactory_p.cpp (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 September 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Creates built-in concrete implementations of IBamIODevices
8 // ***************************************************************************
9
10 #include "api/internal/BamDeviceFactory_p.h"
11 #include "api/internal/BamFile_p.h"
12 #include "api/internal/BamFtp_p.h"
13 #include "api/internal/BamHttp_p.h"
14 #include "api/internal/BamPipe_p.h"
15 using namespace BamTools;
16 using namespace BamTools::Internal;
17
18 #include <iostream>
19 using namespace std;
20
21 IBamIODevice* BamDeviceFactory::CreateDevice(const string& source) {
22
23     // check for requested pipe
24     if ( source == "-" || source == "stdin" || source == "stdout" )
25         return new BamPipe;
26
27     // check for HTTP prefix
28     if ( source.find("http://") == 0 )
29         return new BamHttp(source);
30
31     // check for FTP prefix
32     if ( source.find("ftp://") == 0 )
33         return new BamFtp(source);
34
35     // otherwise assume a "normal" file
36     return new BamFile(source);
37 }