Nemo  2.2.0
Public Member Functions | Protected Attributes
SimComponent Class Reference

Interface to all basic components of a simulation (traits, life cycle events, pop, etc. ). More...

#include <simcomponent.h>

+ Inheritance diagram for SimComponent:
+ Collaboration diagram for SimComponent:

List of all members.

Public Member Functions

 SimComponent ()
virtual ~SimComponent ()
Services interface
virtual void loadFileServices (FileServices *loader)=0
 Loads the component's FileHandler onto the FileServices.
virtual void loadStatServices (StatServices *loader)=0
 Loads the component's StatHandler onto the StatServices.
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager.
Parameters handling
virtual bool setParameters ()=0
 Default interface needed to initialize the component's variables from its input parameters value.
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member.
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it.
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set.
virtual ParamSetget_paramset ()
 ParamSet accessor.
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set.
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set.
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set.
virtual Paramget_parameter (std::string name)
 Param getter.
virtual double get_parameter_value (std::string name)
 Param value getter.
virtual string get_name ()
 Returnd the name of the ParamSet, i.e.

Protected Attributes

ParamSet_paramSet
 The parameters container.

Detailed Description

Interface to all basic components of a simulation (traits, life cycle events, pop, etc. ).

Implements the interface to handle the files and stats handler, the parameter updaters, and the parameters container. Contains the component's parameters and declares the interface to interact with its parameters.

Definition at line 45 of file simcomponent.h.


Constructor & Destructor Documentation

SimComponent::SimComponent ( ) [inline]

Definition at line 52 of file simcomponent.h.

: _paramSet(0) {}//{ cout << "calling SimComponent()" << endl;}
virtual SimComponent::~SimComponent ( ) [inline, virtual]

Definition at line 54 of file simcomponent.h.

References _paramSet.

{if(_paramSet != NULL) delete _paramSet;}

Member Function Documentation

virtual void SimComponent::add_parameter ( Param param) [inline, virtual]
virtual void SimComponent::add_parameter ( std::string  Name,
param_t  Type,
bool  isRequired,
bool  isBounded,
double  low_bnd,
double  up_bnd 
) [inline, virtual]

Interface to add a parameter to the set.

Parameters:
NameThe param string name as read in the init file
TypeThe type of the argument (DBL=double, INT=integer, BOOL=boolean, STR=string, etc., see type.h)
isRequiredTrue if the parameter is mandatory
isBoundedTrue if the parameter takes bounded values as argument
low_bndThe lower value the argument can take
up_bndThe upper value the argument can take

Definition at line 121 of file simcomponent.h.

References _paramSet, and ParamSet::add_param().

  {_paramSet->add_param(Name, Type, isRequired, isBounded, low_bnd, up_bnd, 0);}
virtual void SimComponent::add_parameter ( std::string  Name,
param_t  Type,
bool  isRequired,
bool  isBounded,
double  low_bnd,
double  up_bnd,
ParamUpdaterBase updater 
) [inline, virtual]

Interface to add a parameter and its updater to the set.

Parameters:
NameThe param string name as read in the init file
TypeThe type of the argument (DBL=double, INT=integer, BOOL=boolean, STR=string, etc., see type.h)
isRequiredTrue if the parameter is mandatory
isBoundedTrue if the parameter takes bounded values as argument
low_bndThe lower value the argument can take
up_bndThe upper value the argument can take
updatera pointer to a ParamUpdaterBase object used to reset its value during a simulation

Definition at line 133 of file simcomponent.h.

References _paramSet, and ParamSet::add_param().

  {_paramSet->add_param(Name, Type, isRequired, isBounded, low_bnd, up_bnd, updater);}
virtual string SimComponent::get_name ( ) [inline, virtual]

Returnd the name of the ParamSet, i.e.

the name of the component.

Definition at line 146 of file simcomponent.h.

References _paramSet, and ParamSet::getName().

{return _paramSet->getName();}
virtual Param* SimComponent::get_parameter ( std::string  name) [inline, virtual]
virtual double SimComponent::get_parameter_value ( std::string  name) [inline, virtual]
virtual ParamSet* SimComponent::get_paramset ( ) [inline, virtual]
virtual void SimComponent::loadFileServices ( FileServices loader) [pure virtual]
virtual void SimComponent::loadStatServices ( StatServices loader) [pure virtual]
virtual void SimComponent::loadUpdaters ( UpdaterServices loader) [inline, virtual]

Loads the parameters and component updater onto the updater manager.

Parameters:
loaderthe updater manager

Reimplemented in LCE_ParamUpdaterNotifier.

Definition at line 68 of file simcomponent.h.

References _paramSet, UpdaterServices::attach(), and ParamSet::getUpdaters().

Referenced by UpdaterServices::load().

                                                         {
    list<ParamUpdaterBase*> updaters = _paramSet->getUpdaters();
    //remove duplicates:
    updaters.unique();
    for (list<ParamUpdaterBase*>::iterator u = updaters.begin(); u != updaters.end(); u++) {
      loader->attach( (*u) );
    }
  }
virtual void SimComponent::set_paramset ( ParamSet paramset) [inline, virtual]
virtual void SimComponent::set_paramset ( std::string  name,
bool  required,
SimComponent owner 
) [inline, virtual]

Sets a new ParamSet and name it.

Parameters:
namethe name of the parameters container
requiredtag whether the component is required to run a simulation
ownera reference to the owner of the ParamSet (should be this).

Reimplemented in LifeCycleEvent.

Definition at line 93 of file simcomponent.h.

References _paramSet, ParamSet::setIsRequired(), ParamSet::setName(), and ParamSet::setOwner().

                                                                                  {
    if(_paramSet != NULL) delete _paramSet;
    _paramSet = new ParamSet(); 
    _paramSet->setName(name);
    _paramSet->setIsRequired(required);
    _paramSet->setOwner(owner);
  }
virtual void SimComponent::set_paramsetFromCopy ( const ParamSet PSet) [inline, virtual]

Reset the set of parameters from a another set.

Parameters:
PSetthe parameter set to copy parameters from

Definition at line 103 of file simcomponent.h.

References _paramSet.

Referenced by Metapop::loadPopFromTraitFile().

                                                           {
    if(_paramSet != NULL) delete _paramSet;
    _paramSet = new ParamSet(PSet); 
  }
virtual bool SimComponent::setParameters ( ) [pure virtual]

Member Data Documentation


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

Generated for Nemo v2.2.0 by  doxygen 1.7.5.1 -- Nemo is hosted by  SourceForge.net Logo