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 // ***************************************************************************
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;
21 IBamIODevice* BamDeviceFactory::CreateDevice(const string& source) {
23 // check for requested pipe
24 if ( source == "-" || source == "stdin" || source == "stdout" )
27 // check for HTTP prefix
28 if ( source.find("http://") == 0 )
29 return new BamHttp(source);
31 // check for FTP prefix
32 if ( source.find("ftp://") == 0 )
33 return new BamFtp(source);
35 // otherwise assume a "normal" file
36 return new BamFile(source);