GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GObservationRegistry Class Reference

Interface definition for the observation registry class. More...

#include <GObservationRegistry.hpp>

Inheritance diagram for GObservationRegistry:
GRegistry

Public Member Functions

 GObservationRegistry (void)
 Void constructor. More...
 
 GObservationRegistry (const GObservation *obs)
 Observation constructor. More...
 
 GObservationRegistry (const GObservationRegistry &registry)
 Copy constructor. More...
 
virtual ~GObservationRegistry (void)
 Destructor. More...
 
GObservationRegistryoperator= (const GObservationRegistry &registry)
 Assignment operator. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of registered observations. More...
 
GObservationalloc (const std::string &name) const
 Allocate observation of given name. More...
 
std::string name (const int &index) const
 Returns instrument name for a specific registered observation. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print registry information. More...
 
- Public Member Functions inherited from GRegistry
virtual ~GRegistry (void)
 Destructor. More...
 
std::string content (void) const
 Return list of names in registry. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GObservationRegistry &registry)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Static Private Member Functions

static int & number ()
 
static GRegistryPointer
< std::string > & 
names ()
 
static GRegistryPointer< const
GObservation * > & 
obs ()
 

Detailed Description

Interface definition for the observation registry class.

The registry class allows the registration of observations that are not necessarily compiled into the GammaLib. It uses the static members m_number, m_names, and m_obs which are allocated globally to keep track of observations that are available throughout all linked libraries. To register an observation it is sufficient to add

const GXXXObservation      g_obs_XXX_seed;
const GObservationRegistry g_obs_XXX_registry(&g_obs_XXX_seed);

at the top of the .cpp file of the observation. Here, XXX is a unique name that describes the instrument for which the observation class is implemented.

Definition at line 54 of file GObservationRegistry.hpp.

Constructor & Destructor Documentation

GObservationRegistry::GObservationRegistry ( void  )

Void constructor.

Definition at line 55 of file GObservationRegistry.cpp.

References init_members(), names(), and size().

GObservationRegistry::GObservationRegistry ( const GObservation obs)

Observation constructor.

Parameters
[in]obsObservation.

Definition at line 79 of file GObservationRegistry.cpp.

References init_members(), GObservation::instrument(), names(), number(), obs(), and size().

GObservationRegistry::GObservationRegistry ( const GObservationRegistry registry)

Copy constructor.

Parameters
[in]registryRegistry.

Definition at line 130 of file GObservationRegistry.cpp.

References copy_members(), and init_members().

GObservationRegistry::~GObservationRegistry ( void  )
virtual

Destructor.

Definition at line 146 of file GObservationRegistry.cpp.

References free_members().

Member Function Documentation

GObservation * GObservationRegistry::alloc ( const std::string &  name) const

Allocate observation of given name.

Parameters
[in]nameInstrument name.
Returns
Pointer to observation (NULL if name is not registered).

Returns a pointer to an observation instance for a specific name. If the instrument name has not been found in the registry, a NULL pointer is returned.

Definition at line 205 of file GObservationRegistry.cpp.

References name(), names(), obs(), and size().

Referenced by GObservations::read().

std::string GObservationRegistry::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GObservationRegistry").

Implements GRegistry.

Definition at line 108 of file GObservationRegistry.hpp.

void GObservationRegistry::copy_members ( const GObservationRegistry registry)
protected

Copy class members.

Parameters
[in]registryRegistry.

Definition at line 304 of file GObservationRegistry.cpp.

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

void GObservationRegistry::free_members ( void  )
protected

Delete class members.

Definition at line 314 of file GObservationRegistry.cpp.

Referenced by operator=(), and ~GObservationRegistry().

void GObservationRegistry::init_members ( void  )
protected

Initialise class members.

Definition at line 292 of file GObservationRegistry.cpp.

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

std::string GObservationRegistry::name ( const int &  index) const
virtual

Returns instrument name for a specific registered observation.

Parameters
[in]indexObservation index [0,...,size()[.
Returns
Instrument name.
Exceptions
GException::out_of_rangeObservation index is out of range.

Implements GRegistry.

Definition at line 232 of file GObservationRegistry.cpp.

References G_NAME, names(), and size().

Referenced by alloc().

static GRegistryPointer<std::string>& GObservationRegistry::names ( )
inlinestaticprivate

Definition at line 90 of file GObservationRegistry.hpp.

Referenced by alloc(), GObservationRegistry(), name(), and print().

static int& GObservationRegistry::number ( void  )
inlinestaticprivate

Definition at line 85 of file GObservationRegistry.hpp.

Referenced by GObservationRegistry(), and size().

static GRegistryPointer<const GObservation*>& GObservationRegistry::obs ( )
inlinestaticprivate

Definition at line 95 of file GObservationRegistry.hpp.

Referenced by alloc(), GObservationRegistry(), and print().

GObservationRegistry & GObservationRegistry::operator= ( const GObservationRegistry registry)

Assignment operator.

Parameters
[in]registryRegistry.
Returns
Reference to registry.

Definition at line 168 of file GObservationRegistry.cpp.

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

std::string GObservationRegistry::print ( const GChatter chatter = NORMAL) const
virtual

Print registry information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
Registry content.

Implements GRegistry.

Definition at line 253 of file GObservationRegistry.cpp.

References names(), NORMAL, obs(), gammalib::parformat(), SILENT, size(), and gammalib::str().

int GObservationRegistry::size ( void  ) const
inlinevirtual

Return number of registered observations.

Returns
Number of registered observations.

Returns the number of registered observations.

Implements GRegistry.

Definition at line 122 of file GObservationRegistry.hpp.

References number().

Referenced by alloc(), GObservationRegistry(), name(), and print().


The documentation for this class was generated from the following files: