#include <GCTAOnOffObservations.hpp>
Inheritance diagram for GCTAOnOffObservations:
Public Member Functions | |
GCTAOnOffObservations (void) | |
Void constructor. | |
GCTAOnOffObservations (const GCTAOnOffObservations &obs) | |
Copy constructor. | |
GCTAOnOffObservations (const GFilename &filename) | |
Load constructor. | |
virtual | ~GCTAOnOffObservations (void) |
Destructor. | |
GCTAOnOffObservations & | operator= (const GCTAOnOffObservations &obs) |
Assignment operator. | |
GCTAOnOffObservation * | operator[] (const int &index) |
Return pointer to observation. | |
const GCTAOnOffObservation * | operator[] (const int &index) const |
Return pointer to observation (const version). | |
void | clear (void) |
Clear observations. | |
GCTAOnOffObservations * | clone (void) const |
Clone observations. | |
std::string | classname (void) const |
Return class name. | |
GCTAOnOffObservation * | at (const int &index) |
Return pointer to observation. | |
const GCTAOnOffObservation * | at (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. | |
GCTAOnOffObservation * | set (const int &index, const GCTAOnOffObservation &obs) |
Set observation in container. | |
GCTAOnOffObservation * | append (const GCTAOnOffObservation &obs) |
Append observation to container. | |
GCTAOnOffObservation * | insert (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 GModels & | models (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. |
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.
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.
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.
[in] | filename | XML filename. |
Definition at line 98 of file GCTAOnOffObservations.cpp.
References init_members(), and load().
GCTAOnOffObservations::~GCTAOnOffObservations | ( | void | ) | [virtual] |
GCTAOnOffObservation * GCTAOnOffObservations::append | ( | const GCTAOnOffObservation & | obs | ) |
Append observation to container.
[in] | obs | Observation. |
GException::invalid_value | Observation with same instrument and identifier already exists in 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).
[in] | index | Observation index [0,...,size()-1]. |
GException::out_of_range | Operation index is out of range. |
index
.
Definition at line 224 of file GCTAOnOffObservations.cpp.
GCTAOnOffObservation * GCTAOnOffObservations::at | ( | const int & | index | ) |
Return pointer to observation.
[in] | index | Observation index [0,...,size()-1]. |
GException::out_of_range | Operation index is out of range. |
index
.
Definition at line 202 of file GCTAOnOffObservations.cpp.
std::string GCTAOnOffObservations::classname | ( | void | ) | const [inline, virtual] |
Return class name.
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.
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.
[in] | instrument | Instrument. |
[in] | id | Observation identifier. |
instrument
and identifier id
exists.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.
[in] | obs | Observation container. |
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.
[in] | obs | Observations. |
GException::invalid_value | Observation with same instrument and identifier already exists in 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.
[in] | instrument | Instrument. |
[in] | id | Observation identifier. |
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.
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.
[in] | index | Observation index [0,...,size()-1]. |
[in] | obs | Observation. |
GException::out_of_range | Observation index is out of range. | |
GException::invalid_value | Observation with same instrument and identifier already exists in container. |
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.
Implements GContainer.
Definition at line 176 of file GCTAOnOffObservations.hpp.
References m_obs.
void GCTAOnOffObservations::load | ( | const GFilename & | filename | ) |
Load observations from XML file.
[in] | filename | XML filename. |
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.
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.
[in] | filename | XML filename. |
Definition at line 687 of file GCTAOnOffObservations.cpp.
References GModels::load(), and m_models.
void GCTAOnOffObservations::models | ( | const GModels & | models | ) | [inline] |
Set model container.
[in] | models | Model container. |
Definition at line 205 of file GCTAOnOffObservations.hpp.
GCTAOnOffObservations & GCTAOnOffObservations::operator= | ( | const GCTAOnOffObservations & | obs | ) |
Assignment operator.
[in] | obs | 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).
[in] | index | Observation index [0,...,size()-1]. |
index
.
Definition at line 148 of file GCTAOnOffObservations.hpp.
References m_obs.
GCTAOnOffObservation * GCTAOnOffObservations::operator[] | ( | const int & | index | ) | [inline] |
Return pointer to observation.
[in] | index | Observation index [0,...,size()-1]. |
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.
[in] | chatter | Chattiness (defaults to NORMAL). |
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.
[in] | xml | XML document. |
GException::invalid_instrument | Invalid instrument encountered in XML file. |
<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.
[in] | index | Observation index [0,...,size()-1]. |
GException::out_of_range | Observation index is out of range. |
index
from the container.
Implements GContainer.
Definition at line 394 of file GCTAOnOffObservations.cpp.
void GCTAOnOffObservations::reserve | ( | const int & | num | ) | [inline, virtual] |
Reserves space for observations in container.
[in] | num | Number of observations. |
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.
[in] | filename | XML filename. |
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.
[in] | index | Observation index [0,...,size()-1]. |
[in] | obs | Observation. |
GException::out_of_range | Observation index is out of range. | |
GException::invalid_value | Observation with same instrument and identifier already exists in container. |
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.
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.
[in] | xml | 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().
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().