Nemo  2.4.0
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
simcomponent.h
Go to the documentation of this file.
1 
29 #ifndef SIMCOMPONENT_H
30 #define SIMCOMPONENT_H
31 
32 #include <string>
33 #include "fileservices.h"
34 #include "statservices.h"
35 #include "updaterservices.h"
36 #include "param.h"
37 #include "binarystoragebuffer.h"
38 
44 class SimComponent {
45 protected:
48 
49 public:
50 
51  SimComponent ( ) : _paramSet(0) {}//{ cout << "calling SimComponent()" << endl;}
52  //**Dstor. Deletes the parameter container. */
53  virtual ~SimComponent ( ) {if(_paramSet != NULL) delete _paramSet;}
54 
57 
59  virtual void loadFileServices ( FileServices* loader ) = 0;
60 
63  virtual void loadStatServices ( StatServices* loader ) = 0;
64 
67  virtual void loadUpdaters ( UpdaterServices* loader ) {
68  list<ParamUpdaterBase*> updaters = _paramSet->getUpdaters();
69  //remove duplicates:
70  updaters.unique();
71  for (list<ParamUpdaterBase*>::iterator u = updaters.begin(); u != updaters.end(); u++) {
72  loader->attach( (*u) );
73  }
74  }
76 
79 
81  virtual bool setParameters () = 0;
82 
85  virtual void set_paramset(ParamSet * paramset)
86  { _paramSet = paramset; }
87 
92  virtual void set_paramset (std::string name, bool required, SimComponent* owner ) {
93  if(_paramSet != NULL) delete _paramSet;
94  _paramSet = new ParamSet();
95  _paramSet->setName(name);
96  _paramSet->setIsRequired(required);
97  _paramSet->setOwner(owner);
98  }
99 
102  virtual void set_paramsetFromCopy (const ParamSet &PSet) {
103  if(_paramSet != NULL) delete _paramSet;
104  _paramSet = new ParamSet(PSet);
105  }
107  virtual ParamSet* get_paramset () {return _paramSet;}
108 
111  virtual void add_parameter (Param* param) {_paramSet->add_param(param);}
112 
120  virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded,
121  double low_bnd, double up_bnd)
122  {_paramSet->add_param(Name, Type, isRequired, isBounded, low_bnd, up_bnd, 0);}
123 
132  virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded,
133  double low_bnd, double up_bnd, ParamUpdaterBase* updater)
134  {_paramSet->add_param(Name, Type, isRequired, isBounded, low_bnd, up_bnd, updater);}
135 
138  virtual Param* get_parameter (std::string name) {return _paramSet->get_param(name);}
139 
142  virtual double get_parameter_value (std::string name) {return _paramSet->getValue(name);}
143 
145  virtual string get_name () {return _paramSet->getName();}
146 
149  virtual bool has_parameter (std::string name) {return _paramSet->has_param(name);}
150 
151 
152  virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) = 0;
154 
155 };
156 
162 
163 public:
165  virtual void store_data ( BinaryStorageBuffer* saver ) = 0;
166 
168  virtual bool retrieve_data ( BinaryStorageBuffer* reader ) = 0;
169 
170  virtual ~StorableComponent ( ) { }
171 
172 };
173 
174 #endif //SIMCOMPONENT_H
175 
A class to store any kind of data in a char buffer before unloading it in a binary data file.
Definition: binarystoragebuffer.h:43
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:51
Parameters container, implemented in each SimComponent.
Definition: param.h:205
double getValue(string name)
Accessor the parameters value.
Definition: param.h:301
string getName()
Name accessor.
Definition: param.h:289
bool has_param(string name)
Look for a param "name" in its parameters list.
Definition: param.cc:680
void add_param(Param *param)
Adds the param argument to the list.
Definition: param.h:242
void setName(string value)
Sets the container's name.
Definition: param.h:281
void setOwner(SimComponent *owner)
Sets the pointer to the SimComponents that owns this set.
Definition: param.h:285
Param * get_param(string name)
Look for a param "name" in its parameters list.
Definition: param.cc:666
void setIsRequired(bool value)
Sets the _isRequired flag meaning this container is mandatory and must be set in order to run a simul...
Definition: param.h:283
list< ParamUpdaterBase * > getUpdaters()
Collects the parameter updaters from the set of parameters.
Definition: param.cc:621
Base class of the ParamUpdater class used to handle the temporal parameter argument values.
Definition: param.h:314
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:44
virtual void set_paramsetFromCopy(const ParamSet &PSet)
Reset the set of parameters from a another set.
Definition: simcomponent.h:102
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.
Definition: simcomponent.h:67
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)=0
virtual ~SimComponent()
Definition: simcomponent.h:53
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:142
SimComponent()
Definition: simcomponent.h:51
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.
Definition: simcomponent.h:132
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:85
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:138
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.
Definition: simcomponent.h:120
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:111
virtual void loadFileServices(FileServices *loader)=0
Loads the component's FileHandler onto the FileServices.
virtual bool has_parameter(std::string name)
Param getter.
Definition: simcomponent.h:149
virtual string get_name()
Returnd the name of the ParamSet, i.e.
Definition: simcomponent.h:145
virtual ParamSet * get_paramset()
ParamSet accessor.
Definition: simcomponent.h:107
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:47
virtual bool setParameters()=0
Default interface needed to initialize the component's variables from its input parameters value.
virtual void set_paramset(std::string name, bool required, SimComponent *owner)
Sets a new ParamSet and name it.
Definition: simcomponent.h:92
The Service class used to manage the StatHandler objects.
Definition: statservices.h:49
Provides an interface to binary data saving and uploading.
Definition: simcomponent.h:161
virtual bool retrieve_data(BinaryStorageBuffer *reader)=0
Interface to retrieve the same data from the binary buffer.
virtual ~StorableComponent()
Definition: simcomponent.h:170
virtual void store_data(BinaryStorageBuffer *saver)=0
Interface to store the component data (e.g. gene values) into a binary buffer.
Class to update the simulation components' state during a simulation.
Definition: updaterservices.h:63
virtual void attach(Handler *H)
Attach the updater to the stack.
Definition: updaterservices.cc:88
Nemo2.
param_t
Param's types.
Definition: types.h:76

Generated for Nemo v2.4.0 by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR