Loading...
Searching...
No Matches
SamProgramChain.h
Go to the documentation of this file.
// ***************************************************************************
// SamProgramChain.h (c) 2011 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
// Last modified: 10 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides methods for operating on a SamProgram record "chain"
// ***************************************************************************
#ifndef SAM_PROGRAMCHAIN_H
#define SAM_PROGRAMCHAIN_H
#include <string>
#include <vector>
#include "api/SamProgram.h"
#include "api/api_global.h"
namespace BamTools {
// chain is *NOT* sorted in any order
// use First()/Last() to retrieve oldest/newest programs, respectively
typedef std::vector<SamProgram> SamProgramContainer;
typedef SamProgramContainer::iterator SamProgramIterator;
typedef SamProgramContainer::const_iterator SamProgramConstIterator;
class API_EXPORT SamProgramChain
{
// ctor & dtor
public:
SamProgramChain();
// query/modify program data
public:
// appends a program record to the chain
void Add(SamProgram& program);
void Add(std::vector<SamProgram>& programs);
// clears all read group entries
void Clear();
// returns true if chain contains this program record (matches on ID)
bool Contains(const SamProgram& program) const;
bool Contains(const std::string& programId) const;
// returns the first (oldest) program in the chain
SamProgram& First();
const SamProgram& First() const;
// returns true if chain is empty
bool IsEmpty() const;
// returns last (most recent) program in the chain
SamProgram& Last();
const SamProgram& Last() const;
// returns number of program records in the chain
int Size() const;
// retrieves a modifiable reference to the SamProgram object associated with this ID
SamProgram& operator[](const std::string& programId);
// retrieve STL-compatible iterators
public:
SamProgramIterator Begin(); // returns iterator to begin()
SamProgramConstIterator Begin() const; // returns const_iterator to begin()
SamProgramConstIterator ConstBegin() const; // returns const_iterator to begin()
SamProgramIterator End(); // returns iterator to end()
SamProgramConstIterator End() const; // returns const_iterator to end()
SamProgramConstIterator ConstEnd() const; // returns const_iterator to end()
// internal methods
private:
int IndexOf(const std::string& programId) const;
const std::string NextIdFor(const std::string& programId) const;
// data members
private:
SamProgramContainer m_data;
};
} // namespace BamTools
#endif // SAM_PROGRAMCHAIN_H
SamProgram.h
api_global.h
BamTools::SamProgramChain::ConstEnd
SamProgramConstIterator ConstEnd() const
Definition SamProgramChain.cpp:123
BamTools::SamProgramChain::operator[]
SamProgram & operator[](const std::string &programId)
Retrieves the modifiable SamProgram record that matches programId.
Definition SamProgramChain.cpp:351
BamTools::SamProgramChain::Clear
void Clear()
Clears all program records.
Definition SamProgramChain.cpp:105
BamTools::SamProgramChain::Begin
SamProgramIterator Begin()
Definition SamProgramChain.cpp:85
BamTools::SamProgramChain::IsEmpty
bool IsEmpty() const
Returns true if chain contains no records.
Definition SamProgramChain.cpp:252
BamTools::SamProgramChain::SamProgramChain
SamProgramChain()
constructor
Definition SamProgramChain.cpp:32
BamTools::SamProgramChain::End
SamProgramIterator End()
Definition SamProgramChain.cpp:156
BamTools::SamProgramChain::Size
int Size() const
Returns number of program records in the chain.
Definition SamProgramChain.cpp:336
BamTools::SamProgramChain::Add
void Add(SamProgram &program)
Appends a program to program chain.
Definition SamProgramChain.cpp:46
BamTools::SamProgramChain::Last
SamProgram & Last()
Fetches last (newest) record in the chain.
Definition SamProgramChain.cpp:266
BamTools::SamProgramChain::Contains
bool Contains(const SamProgram &program) const
Returns true if chains has this program record (matching on ID).
Definition SamProgramChain.cpp:136
BamTools::SamProgramChain::ConstBegin
SamProgramConstIterator ConstBegin() const
Definition SamProgramChain.cpp:114
BamTools::SamProgramChain::First
SamProgram & First()
Fetches first (oldest) record in the chain.
Definition SamProgramChain.cpp:182
BamTools
Contains all BamTools classes & methods.
Definition Sort.h:24
BamTools::SamProgramContainer
std::vector< SamProgram > SamProgramContainer
Definition SamProgramChain.h:22
BamTools::SamProgramIterator
SamProgramContainer::iterator SamProgramIterator
Definition SamProgramChain.h:23
BamTools::SamProgramConstIterator
SamProgramContainer::const_iterator SamProgramConstIterator
Definition SamProgramChain.h:24
BamTools::SamProgram
Represents a SAM program record.
Definition SamProgram.h:22