1 // ***************************************************************************
2 // SamProgramChain.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 methods for operating on a SamProgram record "chain"
9 // ***************************************************************************
11 #ifndef SAM_PROGRAMCHAIN_H
12 #define SAM_PROGRAMCHAIN_H
14 #include <api/api_global.h>
15 #include <api/SamProgram.h>
21 // chain is *NOT* sorted in any order
22 // use First()/Last() to retrieve oldest/newest programs, respectively
23 typedef std::vector<SamProgram> SamProgramContainer;
24 typedef SamProgramContainer::iterator SamProgramIterator;
25 typedef SamProgramContainer::const_iterator SamProgramConstIterator;
27 class API_EXPORT SamProgramChain {
31 SamProgramChain(void);
32 SamProgramChain(const SamProgramChain& other);
33 ~SamProgramChain(void);
35 // query/modify program data
37 // appends a program record to the chain
38 void Add(SamProgram& program);
39 void Add(std::vector<SamProgram>& programs);
41 // clears all read group entries
44 // returns true if chain contains this program record (matches on ID)
45 bool Contains(const SamProgram& program) const;
46 bool Contains(const std::string& programId) const;
48 // returns the first (oldest) program in the chain
49 SamProgram& First(void);
50 const SamProgram& First(void) const;
52 // returns true if chain is empty
53 bool IsEmpty(void) const;
55 // returns last (most recent) program in the chain
56 SamProgram& Last(void);
57 const SamProgram& Last(void) const;
59 // returns number of program records in the chain
62 // retrieves a modifiable reference to the SamProgram object associated with this ID
63 SamProgram& operator[](const std::string& programId);
65 // retrieve STL-compatible iterators
67 SamProgramIterator Begin(void); // returns iterator to begin()
68 SamProgramConstIterator Begin(void) const; // returns const_iterator to begin()
69 SamProgramConstIterator ConstBegin(void) const; // returns const_iterator to begin()
70 SamProgramIterator End(void); // returns iterator to end()
71 SamProgramConstIterator End(void) const; // returns const_iterator to end()
72 SamProgramConstIterator ConstEnd(void) const; // returns const_iterator to end()
76 int IndexOf(const std::string& programId) const;
77 const std::string NextIdFor(const std::string& programId) const;
81 SamProgramContainer m_data;
84 } // namespace BamTools
86 #endif // SAM_PROGRAMCHAIN_H