GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelRegistry Class Reference

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

#include <GModelRegistry.hpp>

Inheritance diagram for GModelRegistry:
GRegistry

Public Member Functions

 GModelRegistry (void)
 Void constructor. More...
 
 GModelRegistry (const GModel *model)
 Model constructor. More...
 
 GModelRegistry (const GModelRegistry &registry)
 Copy constructor. More...
 
virtual ~GModelRegistry (void)
 Destructor. More...
 
GModelRegistryoperator= (const GModelRegistry &registry)
 Assignment operator. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of registered models. More...
 
GModelalloc (const std::string &name) const
 Allocate model of given name. More...
 
std::string name (const int &index) const
 Returns model name. 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 GModelRegistry &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
GModel * > & 
models ()
 

Detailed Description

Interface definition for the model registry class.

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

const GModelXXX      g_XXX_seed;
const GModelRegistry g_XXX_registry(&g_XXX_seed);

at the top of the .cpp file of the model. Here, XXX is a unique name that describes the model.

Definition at line 53 of file GModelRegistry.hpp.

Constructor & Destructor Documentation

GModelRegistry::GModelRegistry ( void  )

Void constructor.

Definition at line 55 of file GModelRegistry.cpp.

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

GModelRegistry::GModelRegistry ( const GModel model)

Model constructor.

Parameters
[in]modelModel.

Construct registry by adding a model to the registry. This is the standard constructor that is used to register a new model to GammaLib.

Definition at line 82 of file GModelRegistry.cpp.

References init_members(), models(), names(), number(), size(), and GModel::type().

GModelRegistry::GModelRegistry ( const GModelRegistry registry)

Copy constructor.

Parameters
[in]registryRegistry.

Definition at line 133 of file GModelRegistry.cpp.

References copy_members(), and init_members().

GModelRegistry::~GModelRegistry ( void  )
virtual

Destructor.

Definition at line 149 of file GModelRegistry.cpp.

References free_members().

Member Function Documentation

GModel * GModelRegistry::alloc ( const std::string &  name) const

Allocate model of given name.

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

Returns a pointer to a void model instance of the specified name. If the name has not been found in the registry, a NULL pointer is returned.

Definition at line 207 of file GModelRegistry.cpp.

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

Referenced by GModels::read().

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

Return class name.

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

Implements GRegistry.

Definition at line 107 of file GModelRegistry.hpp.

void GModelRegistry::copy_members ( const GModelRegistry registry)
protected

Copy class members.

Parameters
[in]registryRegistry.

Definition at line 304 of file GModelRegistry.cpp.

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

void GModelRegistry::free_members ( void  )
protected

Delete class members.

Definition at line 314 of file GModelRegistry.cpp.

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

void GModelRegistry::init_members ( void  )
protected

Initialise class members.

Definition at line 292 of file GModelRegistry.cpp.

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

static GRegistryPointer<const GModel*>& GModelRegistry::models ( )
inlinestaticprivate

Definition at line 94 of file GModelRegistry.hpp.

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

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

Returns model name.

Parameters
[in]indexModel index [0,...,size()[.
Returns
Model name.
Exceptions
GException::out_of_rangeModel index is out of range.

Implements GRegistry.

Definition at line 234 of file GModelRegistry.cpp.

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

Referenced by alloc().

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

Definition at line 89 of file GModelRegistry.hpp.

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

static int& GModelRegistry::number ( void  )
inlinestaticprivate

Definition at line 84 of file GModelRegistry.hpp.

Referenced by GModelRegistry(), and size().

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

Assignment operator.

Parameters
[in]registryRegistry.
Returns
Reference to registry.

Definition at line 171 of file GModelRegistry.cpp.

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

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

Print registry information.

Parameters
[in]chatterChattiness.
Returns
Registry content.

Implements GRegistry.

Definition at line 254 of file GModelRegistry.cpp.

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

int GModelRegistry::size ( void  ) const
inlinevirtual

Return number of registered models.

Returns
Number of registered models.

Returns the number of registered model.

Implements GRegistry.

Definition at line 121 of file GModelRegistry.hpp.

References number().

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


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