]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/BamIndexFactory_p.h
7b1ff96a6425f42e717c800f55f839ea08ec5b09
[bamtools.git] / src / api / internal / BamIndexFactory_p.h
1 // ***************************************************************************
2 // BamIndexFactory_p.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 5 April 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides interface for generating BamIndex implementations
8 // ***************************************************************************
9
10 #ifndef BAMINDEX_FACTORY_P_H
11 #define BAMINDEX_FACTORY_P_H
12
13 #include <api/BamIndex.h>
14 #include <string>
15
16 namespace BamTools {
17 namespace Internal {
18
19 class BamIndexFactory {
20
21     // static interface methods
22     public:
23         // creates a new BamIndex object, depending on extension of @indexFilename
24         static BamIndex* CreateIndexFromFilename(const std::string& indexFilename,
25                                                  BamReaderPrivate* reader);
26         // creates a new BamIndex object, of requested @type
27         static BamIndex* CreateIndexOfType(const BamIndex::IndexType& type,
28                                            BamReaderPrivate* reader);
29         // returns name of existing index file that corresponds to @bamFilename
30         // will defer to @preferredType if possible
31         // if @preferredType not found, will attempt to load any supported index type
32         // returns empty string if no index file (of any type) is found
33         static const std::string FindIndexFilename(const std::string& bamFilename,
34                                                    const BamIndex::IndexType& preferredType);
35
36     // internal methods
37     public:
38         // generates index filename from BAM filename (depending on requested type)
39         // if type is unknown, returns empty string
40         static const std::string CreateIndexFilename(const std::string& bamFilename,
41                                                      const BamIndex::IndexType& type);
42         // retrieves file extension (including '.')
43         static const std::string FileExtension(const std::string& filename);
44 };
45
46 } // namespace Internal
47 } // namespace BamTools
48
49 #endif // BAMINDEX_FACTORY_P_H