GCTAOnOffObservations Class Reference

ON/OFF Observation container class. More...

#include <GCTAOnOffObservations.hpp>

Inheritance diagram for GCTAOnOffObservations:

GContainer GBase List of all members.

Public Member Functions

 GCTAOnOffObservations (void)
 Void constructor.
 GCTAOnOffObservations (const GCTAOnOffObservations &obs)
 Copy constructor.
 GCTAOnOffObservations (const GFilename &filename)
 Load constructor.
virtual ~GCTAOnOffObservations (void)
 Destructor.
GCTAOnOffObservationsoperator= (const GCTAOnOffObservations &obs)
 Assignment operator.
GCTAOnOffObservationoperator[] (const int &index)
 Return pointer to observation.
const GCTAOnOffObservationoperator[] (const int &index) const
 Return pointer to observation (const version).
void clear (void)
 Clear observations.
GCTAOnOffObservationsclone (void) const
 Clone observations.
std::string classname (void) const
 Return class name.
GCTAOnOffObservationat (const int &index)
 Return pointer to observation.
const GCTAOnOffObservationat (const int &index) const
 Return pointer to observation (const version).
int size (void) const
 Return number of observations in container.
bool is_empty (void) const
 Signals if there are no observations in container.
GCTAOnOffObservationset (const int &index, const GCTAOnOffObservation &obs)
 Set observation in container.
GCTAOnOffObservationappend (const GCTAOnOffObservation &obs)
 Append observation to container.
GCTAOnOffObservationinsert (const int &index, const GCTAOnOffObservation &obs)
 Insert observation into container.
void remove (const int &index)
 Remove observation from container.
void reserve (const int &num)
 Reserves space for observations in container.
void extend (const GCTAOnOffObservations &obs)
 Append observations from observation container.
bool contains (const std::string &instrument, const std::string &id) const
 Signals if observation exists.
void load (const GFilename &filename)
 Load observations from XML file.
void save (const GFilename &filename) const
 Save observations into XML file.
void read (const GXml &xml)
 Read observations from XML document.
void write (GXml &xml) const
 Write observations into XML document.
void models (const GModels &models)
 Set model container.
void models (const GFilename &filename)
 Load models from XML file.
const GModelsmodels (void) const
 Return model container.
std::string print (const GChatter &chatter=NORMAL) const
 Print observation list information.

Protected Member Functions

void init_members (void)
 Initialise class members.
void copy_members (const GCTAOnOffObservations &obs)
 Copy class members.
void free_members (void)
 Delete class members.
int get_index (const std::string &instrument, const std::string &id) const
 Return observation index by instrument and identifier.

Protected Attributes

std::vector< GCTAOnOffObservation * > m_obs
 List of observations.
GModels m_models
 List of models.

Detailed Description

ON/OFF Observation container class.

This class in a container of GCTAOnOffObservation objects. Still some work to do and things to be clarified...

Definition at line 49 of file GCTAOnOffObservations.hpp.


Constructor & Destructor Documentation

GCTAOnOffObservations::GCTAOnOffObservations ( void   ) 

Void constructor.

Definition at line 61 of file GCTAOnOffObservations.cpp.

References init_members().

Referenced by clone().

GCTAOnOffObservations::GCTAOnOffObservations ( const GCTAOnOffObservations obs  ) 

Copy constructor.

Parameters:
obs Observation container.

Definition at line 76 of file GCTAOnOffObservations.cpp.

References copy_members(), and init_members().

GCTAOnOffObservations::GCTAOnOffObservations ( const GFilename filename  )  [explicit]

Load constructor.

Parameters:
[in] filename XML filename.
Construct the observation container by loading all relevant information from a XML file. Please refer to the read() method for more information about the structure of the XML file.

Definition at line 98 of file GCTAOnOffObservations.cpp.

References init_members(), and load().

GCTAOnOffObservations::~GCTAOnOffObservations ( void   )  [virtual]

Destructor.

Definition at line 114 of file GCTAOnOffObservations.cpp.

References free_members().


Member Function Documentation

GCTAOnOffObservation * GCTAOnOffObservations::append ( const GCTAOnOffObservation obs  ) 

Append observation to container.

Parameters:
[in] obs Observation.
Returns:
Pointer to deep copy of observation.
Exceptions:
GException::invalid_value Observation with same instrument and identifier already exists in container.
Appends a deep copy of an observation to the container.

Definition at line 299 of file GCTAOnOffObservations.cpp.

References GCTAOnOffObservation::clone(), G_APPEND, get_index(), GCTAOnOffObservation::id(), GCTAOnOffObservation::instrument(), m_obs, and gammalib::str().

Referenced by read().

const GCTAOnOffObservation * GCTAOnOffObservations::at ( const int &  index  )  const

Return pointer to observation (const version).

Parameters:
[in] index Observation index [0,...,size()-1].
Exceptions:
GException::out_of_range Operation index is out of range.
Returns a const pointer to the observation with specified index.

Definition at line 224 of file GCTAOnOffObservations.cpp.

References G_AT, m_obs, and size().

GCTAOnOffObservation * GCTAOnOffObservations::at ( const int &  index  ) 

Return pointer to observation.

Parameters:
[in] index Observation index [0,...,size()-1].
Returns:
Observation.
Exceptions:
GException::out_of_range Operation index is out of range.
Returns a pointer to the observation with specified index.

Definition at line 202 of file GCTAOnOffObservations.cpp.

References G_AT, m_obs, and size().

std::string GCTAOnOffObservations::classname ( void   )  const [inline, virtual]

Return class name.

Returns:
String containing the class name ("GCTAOnOffObservations").

Implements GBase.

Definition at line 119 of file GCTAOnOffObservations.hpp.

void GCTAOnOffObservations::clear ( void   )  [virtual]

Clear observations.

Implements GBase.

Definition at line 166 of file GCTAOnOffObservations.cpp.

References free_members(), and init_members().

Referenced by load().

GCTAOnOffObservations * GCTAOnOffObservations::clone ( void   )  const [virtual]

Clone observations.

Returns:
Pointer to deep copy of observation container.

Implements GBase.

Definition at line 184 of file GCTAOnOffObservations.cpp.

References GCTAOnOffObservations().

Referenced by extend().

bool GCTAOnOffObservations::contains ( const std::string &  instrument,
const std::string &  id 
) const

Signals if observation exists.

Parameters:
[in] instrument Instrument.
[in] id Observation identifier.
Returns:
True if observation with specified instrument and identifier id exists.
Searches all observations for a match with the specified instrument and identifier. If the specified attributes have been found, true is returned.

Definition at line 477 of file GCTAOnOffObservations.cpp.

References get_index().

void GCTAOnOffObservations::copy_members ( const GCTAOnOffObservations obs  )  [protected]

Copy class members.

Parameters:
[in] obs Observation container.
Copies all class members. Deep copies are created for the observations, which is what is needed to have a real physical copy of the members.

Definition at line 766 of file GCTAOnOffObservations.cpp.

References m_models, and m_obs.

Referenced by GCTAOnOffObservations(), and operator=().

void GCTAOnOffObservations::extend ( const GCTAOnOffObservations obs  ) 

Append observations from observation container.

Parameters:
[in] obs Observations.
Exceptions:
GException::invalid_value Observation with same instrument and identifier already exists in container.
Appends deep copies of observations to the container.

Definition at line 422 of file GCTAOnOffObservations.cpp.

References clone(), G_EXTEND, get_index(), is_empty(), m_obs, reserve(), size(), and gammalib::str().

void GCTAOnOffObservations::free_members ( void   )  [protected]

Delete class members.

Deallocates all observations. Since container classes that hold pointers need to handle the proper deallocation of memory, we loop here over all pointers and make sure that we deallocate all observations in the container.

Definition at line 790 of file GCTAOnOffObservations.cpp.

References m_obs.

Referenced by clear(), operator=(), and ~GCTAOnOffObservations().

int GCTAOnOffObservations::get_index ( const std::string &  instrument,
const std::string &  id 
) const [protected]

Return observation index by instrument and identifier.

Parameters:
[in] instrument Instrument.
[in] id Observation identifier.
Returns:
Observation index (-1 of instrument and observation identifier has not been found)
Returns observation index based on the specified instrument and observation identifier id. If no observation with the specified attributes has been found, the method returns -1.

Definition at line 815 of file GCTAOnOffObservations.cpp.

References m_obs, and size().

Referenced by append(), contains(), extend(), insert(), and set().

void GCTAOnOffObservations::init_members ( void   )  [protected]

Initialise class members.

Definition at line 747 of file GCTAOnOffObservations.cpp.

References GModels::clear(), m_models, and m_obs.

Referenced by clear(), GCTAOnOffObservations(), and operator=().

GCTAOnOffObservation * GCTAOnOffObservations::insert ( const int &  index,
const GCTAOnOffObservation obs 
)

Insert observation into container.

Parameters:
[in] index Observation index [0,...,size()-1].
[in] obs Observation.
Returns:
Pointer to deep copy of observation.
Exceptions:
GException::out_of_range Observation index is out of range.
GException::invalid_value Observation with same instrument and identifier already exists in container.
Inserts a deep copy of an observation into the container before the observation with the specified index.

Definition at line 342 of file GCTAOnOffObservations.cpp.

References GCTAOnOffObservation::clone(), G_INSERT, get_index(), GCTAOnOffObservation::id(), GCTAOnOffObservation::instrument(), is_empty(), m_obs, size(), and gammalib::str().

bool GCTAOnOffObservations::is_empty ( void   )  const [inline, virtual]

Signals if there are no observations in container.

Returns:
True if container is empty, false otherwise.
Signals if the observation container does not contain any observation.

Implements GContainer.

Definition at line 176 of file GCTAOnOffObservations.hpp.

References m_obs.

Referenced by extend(), and insert().

void GCTAOnOffObservations::load ( const GFilename filename  ) 

Load observations from XML file.

Parameters:
[in] filename XML filename.
Loads observation from a XML file into the container. Please refer to the read() method for more information about the structure of the XML file.

Definition at line 496 of file GCTAOnOffObservations.cpp.

References clear(), read(), and GFilename::url().

Referenced by GCTAOnOffObservations().

const GModels & GCTAOnOffObservations::models ( void   )  const [inline]

Return model container.

Returns:
Model container.
Returns the model container of the observations.

Definition at line 220 of file GCTAOnOffObservations.hpp.

References m_models.

Referenced by models().

void GCTAOnOffObservations::models ( const GFilename filename  ) 

Load models from XML file.

Parameters:
[in] filename XML filename.
Loads the models from a XML file. Please refer to the GModels::read() method for more information about the expected structure of the XML file.

Definition at line 687 of file GCTAOnOffObservations.cpp.

References GModels::load(), and m_models.

void GCTAOnOffObservations::models ( const GModels models  )  [inline]

Set model container.

Parameters:
[in] models Model container.
Sets the model container for the observations.

Definition at line 205 of file GCTAOnOffObservations.hpp.

References m_models, and models().

GCTAOnOffObservations & GCTAOnOffObservations::operator= ( const GCTAOnOffObservations obs  ) 

Assignment operator.

Parameters:
[in] obs Observation container.
Returns:
Observation container.

Definition at line 136 of file GCTAOnOffObservations.cpp.

References copy_members(), free_members(), and init_members().

const GCTAOnOffObservation * GCTAOnOffObservations::operator[] ( const int &  index  )  const [inline]

Return pointer to observation (const version).

Parameters:
[in] index Observation index [0,...,size()-1].
Returns a const pointer to the observation with specified index.

Definition at line 148 of file GCTAOnOffObservations.hpp.

References m_obs.

GCTAOnOffObservation * GCTAOnOffObservations::operator[] ( const int &  index  )  [inline]

Return pointer to observation.

Parameters:
[in] index Observation index [0,...,size()-1].
Returns:
Observation.
Returns a pointer to the observation with specified index.

Definition at line 134 of file GCTAOnOffObservations.hpp.

References m_obs.

std::string GCTAOnOffObservations::print ( const GChatter chatter = NORMAL  )  const [virtual]

Print observation list information.

Parameters:
[in] chatter Chattiness (defaults to NORMAL).
Returns:
String containing observation list information

Implements GBase.

Definition at line 703 of file GCTAOnOffObservations.cpp.

References EXPLICIT, m_models, NORMAL, gammalib::parformat(), GModels::print(), SILENT, size(), and gammalib::str().

void GCTAOnOffObservations::read ( const GXml xml  ) 

Read observations from XML document.

Parameters:
[in] xml XML document.
Exceptions:
GException::invalid_instrument Invalid instrument encountered in XML file.
Reads observations from the first observation list that is found in the XML document. The decoding of the instrument specific observation definition is done within the observation's GCTAOnOffObservation::read() method. The following file structure is expected:

<observation_list title="observation library"> <observation name="..." id="..." instrument="..."> ... </observation> <observation name="..." id="..." instrument="..."> ... </observation> ... </observation_list>

The name and id attributes allow for a unique identification of an observation within the observation container. The instrument attributes specifies the instrument to which the observation applies. At the moment there is only CTA but more instruments may be implemented later and require the need for a registry (see GObservations.cpp).

The structure within the observation tag is defined by the instrument specific GCTAOnOffObservation class.

Definition at line 569 of file GCTAOnOffObservations.cpp.

References append(), GXmlElement::attribute(), GXmlNode::element(), GXml::element(), GXmlNode::elements(), G_READ, GCTAOnOffObservation::id(), GCTAOnOffObservation::name(), and GCTAOnOffObservation::read().

Referenced by load().

void GCTAOnOffObservations::remove ( const int &  index  )  [virtual]

Remove observation from container.

Parameters:
[in] index Observation index [0,...,size()-1].
Exceptions:
GException::out_of_range Observation index is out of range.
Removes observation of specified index from the container.

Implements GContainer.

Definition at line 394 of file GCTAOnOffObservations.cpp.

References G_REMOVE, m_obs, and size().

void GCTAOnOffObservations::reserve ( const int &  num  )  [inline, virtual]

Reserves space for observations in container.

Parameters:
[in] num Number of observations.
Reserves space for num observations in the container.

Implements GContainer.

Definition at line 190 of file GCTAOnOffObservations.hpp.

References m_obs.

Referenced by extend().

void GCTAOnOffObservations::save ( const GFilename filename  )  const

Save observations into XML file.

Parameters:
[in] filename XML filename.
Saves observations into a XML file. Please refer to the read() method for more information about the structure of the XML file.

Definition at line 520 of file GCTAOnOffObservations.cpp.

References GXml::save(), and write().

GCTAOnOffObservation * GCTAOnOffObservations::set ( const int &  index,
const GCTAOnOffObservation obs 
)

Set observation in container.

Parameters:
[in] index Observation index [0,...,size()-1].
[in] obs Observation.
Returns:
Pointer to deep copy of observation.
Exceptions:
GException::out_of_range Observation index is out of range.
GException::invalid_value Observation with same instrument and identifier already exists in container.
Set a deep copy and observation obs at the specified index in the container.

Definition at line 252 of file GCTAOnOffObservations.cpp.

References GCTAOnOffObservation::clone(), G_SET, get_index(), GCTAOnOffObservation::id(), GCTAOnOffObservation::instrument(), m_obs, size(), and gammalib::str().

int GCTAOnOffObservations::size ( void   )  const [inline, virtual]

Return number of observations in container.

Returns:
Number of observations in container.
Returns the number of observations in the observation container.

Implements GContainer.

Definition at line 162 of file GCTAOnOffObservations.hpp.

References m_obs.

Referenced by at(), extend(), get_index(), insert(), print(), remove(), set(), and write().

void GCTAOnOffObservations::write ( GXml xml  )  const

Write observations into XML document.

Parameters:
[in] xml XML document.
Write observations into the first observation library that is found in the XML document. In case that no observation library exists, one is added to the document. Please refer to the read() method for more information about the structure of the XML document.

Definition at line 631 of file GCTAOnOffObservations.cpp.

References GXmlNode::append(), GXml::append(), GXml::element(), GXml::elements(), m_obs, and size().

Referenced by save().


Member Data Documentation

GModels GCTAOnOffObservations::m_models [protected]

List of models.

Definition at line 109 of file GCTAOnOffObservations.hpp.

Referenced by copy_members(), init_members(), models(), and print().

std::vector<GCTAOnOffObservation*> GCTAOnOffObservations::m_obs [protected]

List of observations.

Definition at line 108 of file GCTAOnOffObservations.hpp.

Referenced by append(), at(), copy_members(), extend(), free_members(), get_index(), init_members(), insert(), is_empty(), operator[](), remove(), reserve(), set(), size(), and write().


The documentation for this class was generated from the following files:
Generated on Mon May 30 22:15:11 2016 for GammaLib by  doxygen 1.4.7