GammaLib
2.0.0
|
Interface definition for the model registry class. More...
#include <GModelRegistry.hpp>
Public Member Functions | |
GModelRegistry (void) | |
Void constructor. More... | |
GModelRegistry (const GModel *model) | |
Model constructor. More... | |
GModelRegistry (const GModelRegistry ®istry) | |
Copy constructor. More... | |
virtual | ~GModelRegistry (void) |
Destructor. More... | |
GModelRegistry & | operator= (const GModelRegistry ®istry) |
Assignment operator. More... | |
std::string | classname (void) const |
Return class name. More... | |
int | size (void) const |
Return number of registered models. More... | |
GModel * | alloc (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 ®istry) |
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 () |
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.
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.
[in] | model | Model. |
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.
[in] | registry | Registry. |
Definition at line 133 of file GModelRegistry.cpp.
References copy_members(), and init_members().
|
virtual |
GModel * GModelRegistry::alloc | ( | const std::string & | name | ) | const |
Allocate model of given name.
[in] | name | Model name. |
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().
|
inlinevirtual |
Return class name.
Implements GRegistry.
Definition at line 107 of file GModelRegistry.hpp.
|
protected |
Copy class members.
[in] | registry | Registry. |
Definition at line 304 of file GModelRegistry.cpp.
Referenced by GModelRegistry(), and operator=().
|
protected |
Delete class members.
Definition at line 314 of file GModelRegistry.cpp.
Referenced by operator=(), and ~GModelRegistry().
|
protected |
Initialise class members.
Definition at line 292 of file GModelRegistry.cpp.
Referenced by GModelRegistry(), and operator=().
|
inlinestaticprivate |
Definition at line 94 of file GModelRegistry.hpp.
Referenced by alloc(), GModelRegistry(), and print().
|
virtual |
Returns model name.
[in] | index | Model index [0,...,size()[. |
GException::out_of_range | Model index is out of range. |
Implements GRegistry.
Definition at line 234 of file GModelRegistry.cpp.
References G_NAME, names(), and size().
Referenced by alloc().
|
inlinestaticprivate |
Definition at line 89 of file GModelRegistry.hpp.
Referenced by alloc(), GModelRegistry(), name(), and print().
|
inlinestaticprivate |
Definition at line 84 of file GModelRegistry.hpp.
Referenced by GModelRegistry(), and size().
GModelRegistry & GModelRegistry::operator= | ( | const GModelRegistry & | registry | ) |
Assignment operator.
[in] | registry | Registry. |
Definition at line 171 of file GModelRegistry.cpp.
References copy_members(), free_members(), and init_members().
Print registry information.
[in] | chatter | Chattiness. |
Implements GRegistry.
Definition at line 254 of file GModelRegistry.cpp.
References models(), names(), NORMAL, gammalib::parformat(), SILENT, size(), and gammalib::str().
|
inlinevirtual |
Return 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().