]> git.donarmstrong.com Git - bamtools.git/blob - src/api/SamProgram.h
Brought API up to compliance with recent SAM Format Spec (v1.4-r962)
[bamtools.git] / src / api / SamProgram.h
1 // ***************************************************************************
2 // SamProgram.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 19 April 2011 (DB)
7 // ---------------------------------------------------------------------------
8 // Provides direct read/write access to the SAM header program records.
9 // ***************************************************************************
10
11 #ifndef SAM_PROGRAM_H
12 #define SAM_PROGRAM_H
13
14 #include "api/api_global.h"
15 #include <string>
16
17 namespace BamTools {
18
19 class SamProgramChain;
20
21 struct API_EXPORT SamProgram {
22
23     // ctor & dtor
24     SamProgram(void);
25     SamProgram(const std::string& id);
26     SamProgram(const SamProgram& other);
27     ~SamProgram(void);
28
29     // query/modify entire program record
30     void Clear(void);                           // clears all data fields
31
32     // convenience query methods
33     bool HasCommandLine(void) const;            // returns true if program record has a command line entry
34     bool HasID(void) const;                     // returns true if program record has an ID
35     bool HasName(void) const;                   // returns true if program record has a name
36     bool HasPreviousProgramID(void) const;      // returns true if program record has a 'previous program ID'
37     bool HasVersion(void) const;                // returns true if program record has a version
38
39     // data members
40     std::string CommandLine;                    // CL:<CommandLine>
41     std::string ID;                             // ID:<ID>          *Required for valid SAM header*
42     std::string Name;                           // PN:<Name>
43     std::string PreviousProgramID;              // PP:<PreviousProgramID>
44     std::string Version;                        // VN:<Version>
45
46     // internal (non-standard) methods & fields
47     private:
48         bool HasNextProgramID(void) const;
49         std::string NextProgramID;
50         friend class BamTools::SamProgramChain;
51 };
52
53 /*! \fn bool operator==(const SamProgram& lhs, const SamProgram& rhs)
54     \brief tests equality by comparing program IDs
55 */
56 API_EXPORT inline bool operator==(const SamProgram& lhs, const SamProgram& rhs) {
57     return lhs.ID == rhs.ID;
58 }
59
60 } // namespace BamTools
61
62 #endif // SAM_PROGRAM_H