Nemo  2.3.46
simcomponent.h
Go to the documentation of this file.
1 
30 #ifndef SIMCOMPONENT_H
31 #define SIMCOMPONENT_H
32 
33 #include <string>
34 #include "fileservices.h"
35 #include "statservices.h"
36 #include "updaterservices.h"
37 #include "param.h"
38 #include "binarystoragebuffer.h"
39 
45 class SimComponent {
46 protected:
49 
50 public:
51 
52  SimComponent ( ) : _paramSet(0) {}//{ cout << "calling SimComponent()" << endl;}
53  //**Dstor. Deletes the parameter container. */
54  virtual ~SimComponent ( ) {if(_paramSet != NULL) delete _paramSet;}
55 
58 
60  virtual void loadFileServices ( FileServices* loader ) = 0;
61 
64  virtual void loadStatServices ( StatServices* loader ) = 0;
65 
68  virtual void loadUpdaters ( UpdaterServices* loader ) {
69  list<ParamUpdaterBase*> updaters = _paramSet->getUpdaters();
70  //remove duplicates:
71  updaters.unique();
72  for (list<ParamUpdaterBase*>::iterator u = updaters.begin(); u != updaters.end(); u++) {
73  loader->attach( (*u) );
74  }
75  }
77 
80 
82  virtual bool setParameters () = 0;
83 
86  virtual void set_paramset(ParamSet * paramset)
87  { _paramSet = paramset; }
88 
93  virtual void set_paramset (std::string name, bool required, SimComponent* owner ) {
94  if(_paramSet != NULL) delete _paramSet;
95  _paramSet = new ParamSet();
96  _paramSet->setName(name);
97  _paramSet->setIsRequired(required);
98  _paramSet->setOwner(owner);
99  }
100 
103  virtual void set_paramsetFromCopy (const ParamSet &PSet) {
104  if(_paramSet != NULL) delete _paramSet;
105  _paramSet = new ParamSet(PSet);
106  }
108  virtual ParamSet* get_paramset () {return _paramSet;}
109 
112  virtual void add_parameter (Param* param) {_paramSet->add_param(param);}
113 
121  virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded,
122  double low_bnd, double up_bnd)
123  {_paramSet->add_param(Name, Type, isRequired, isBounded, low_bnd, up_bnd, 0);}
124 
133  virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded,
134  double low_bnd, double up_bnd, ParamUpdaterBase* updater)
135  {_paramSet->add_param(Name, Type, isRequired, isBounded, low_bnd, up_bnd, updater);}
136 
139  virtual Param* get_parameter (std::string name) {return _paramSet->get_param(name);}
140 
143  virtual double get_parameter_value (std::string name) {return _paramSet->getValue(name);}
144 
146  virtual string get_name () {return _paramSet->getName();}
148 
149 };
150 
156 
157 public:
159  virtual void store_data ( BinaryStorageBuffer* saver ) = 0;
161  virtual bool retrieve_data ( BinaryStorageBuffer* reader ) = 0;
162 
163  virtual ~StorableComponent ( ) { }
164 
165 };
166 
167 #endif //SIMCOMPONENT_H
168 
virtual ~StorableComponent()
Definition: simcomponent.h:163
Class to update the simulation components' state during a simulation.
Definition: updaterservices.h:64
The Service class used to manage the StatHandler objects.
Definition: statservices.h:50
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:133
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
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:121
virtual void store_data(BinaryStorageBuffer *saver)=0
Interface to store the component data (e.g. gene values) into a binary buffer.
list< ParamUpdaterBase * > getUpdaters()
Collects the parameter updaters from the set of parameters.
Definition: param.cc:564
virtual void set_paramset(std::string name, bool required, SimComponent *owner)
Sets a new ParamSet and name it.
Definition: simcomponent.h:93
virtual void loadFileServices(FileServices *loader)=0
Loads the component's FileHandler onto the FileServices.
void setName(string value)
Sets the container's name.
Definition: param.h:267
Base class of the ParamUpdater class used to handle the temporal parameter argument values...
Definition: param.h:300
SimComponent()
Definition: simcomponent.h:52
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:86
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
param_t
Param's types.
Definition: types.h:77
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:269
virtual ~SimComponent()
Definition: simcomponent.h:54
string getName()
Name accessor.
Definition: param.h:275
virtual bool retrieve_data(BinaryStorageBuffer *reader)=0
Interface to retrieve the same data from the binary buffer.
virtual void attach(Handler *H)
Attach the updater to the stack.
Definition: updaterservices.cc:89
void setOwner(SimComponent *owner)
Sets the pointer to the SimComponents that owns this set.
Definition: param.h:271
virtual string get_name()
Returnd the name of the ParamSet, i.e.
Definition: simcomponent.h:146
Interface to all basic components of a simulation (traits, life cycle events, pop, etc. ).
Definition: simcomponent.h:45
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
virtual void loadUpdaters(UpdaterServices *loader)
Loads the parameters and component updater onto the updater manager.
Definition: simcomponent.h:68
A class to store any kind of data in a char buffer before unloading it in a binary data file...
Definition: binarystoragebuffer.h:40
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
Param * get_param(string name)
Look for a param "name" in its parameters list.
Definition: param.cc:597
double getValue(string name)
Accessor the parameters value.
Definition: param.h:287
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
virtual ParamSet * get_paramset()
ParamSet accessor.
Definition: simcomponent.h:108
virtual void loadStatServices(StatServices *loader)=0
Loads the component's StatHandler onto the StatServices.
virtual void set_paramsetFromCopy(const ParamSet &PSet)
Reset the set of parameters from a another set.
Definition: simcomponent.h:103
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:203
void add_param(Param *param)
Adds the param argument to the list.
Definition: param.h:238
virtual bool setParameters()=0
Default interface needed to initialize the component's variables from its input parameters value...
Provides an interface to binary data saving and uploading.
Definition: simcomponent.h:155

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR