BamTools  2.4.1
SamProgramChain.h
Go to the documentation of this file.
1 // ***************************************************************************
2 // SamProgramChain.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 October 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides methods for operating on a SamProgram record "chain"
8 // ***************************************************************************
9 
10 #ifndef SAM_PROGRAMCHAIN_H
11 #define SAM_PROGRAMCHAIN_H
12 
13 #include "api/api_global.h"
14 #include "api/SamProgram.h"
15 #include <string>
16 #include <vector>
17 
18 namespace BamTools {
19 
20 // chain is *NOT* sorted in any order
21 // use First()/Last() to retrieve oldest/newest programs, respectively
22 typedef std::vector<SamProgram> SamProgramContainer;
23 typedef SamProgramContainer::iterator SamProgramIterator;
24 typedef SamProgramContainer::const_iterator SamProgramConstIterator;
25 
27 
28  // ctor & dtor
29  public:
30  SamProgramChain(void);
31  SamProgramChain(const SamProgramChain& other);
32  ~SamProgramChain(void);
33 
34  // query/modify program data
35  public:
36  // appends a program record to the chain
37  void Add(SamProgram& program);
38  void Add(std::vector<SamProgram>& programs);
39 
40  // clears all read group entries
41  void Clear(void);
42 
43  // returns true if chain contains this program record (matches on ID)
44  bool Contains(const SamProgram& program) const;
45  bool Contains(const std::string& programId) const;
46 
47  // returns the first (oldest) program in the chain
48  SamProgram& First(void);
49  const SamProgram& First(void) const;
50 
51  // returns true if chain is empty
52  bool IsEmpty(void) const;
53 
54  // returns last (most recent) program in the chain
55  SamProgram& Last(void);
56  const SamProgram& Last(void) const;
57 
58  // returns number of program records in the chain
59  int Size(void) const;
60 
61  // retrieves a modifiable reference to the SamProgram object associated with this ID
62  SamProgram& operator[](const std::string& programId);
63 
64  // retrieve STL-compatible iterators
65  public:
66  SamProgramIterator Begin(void); // returns iterator to begin()
67  SamProgramConstIterator Begin(void) const; // returns const_iterator to begin()
68  SamProgramConstIterator ConstBegin(void) const; // returns const_iterator to begin()
69  SamProgramIterator End(void); // returns iterator to end()
70  SamProgramConstIterator End(void) const; // returns const_iterator to end()
71  SamProgramConstIterator ConstEnd(void) const; // returns const_iterator to end()
72 
73  // internal methods
74  private:
75  int IndexOf(const std::string& programId) const;
76  const std::string NextIdFor(const std::string& programId) const;
77 
78  // data members
79  private:
80  SamProgramContainer m_data;
81 };
82 
83 } // namespace BamTools
84 
85 #endif // SAM_PROGRAMCHAIN_H
std::vector< SamProgram > SamProgramContainer
Definition: SamProgramChain.h:22
SamProgramContainer::iterator SamProgramIterator
Definition: SamProgramChain.h:23
#define API_EXPORT
Definition: api_global.h:18
Sorted container "chain" of SamProgram records.
Definition: SamProgramChain.h:26
Contains all BamTools classes & methods.
Definition: Sort.h:24
SamProgramContainer::const_iterator SamProgramConstIterator
Definition: SamProgramChain.h:24
Represents a SAM program record.
Definition: SamProgram.h:21