102 Param (
string& Name,
param_t Type,
bool mandatory,
bool bounded,
double low_bnd,
double up_bnd,
117 void setArg (
string value) {_arg = value; _input_arg = value;}
127 void setBounds (
double low_bnd,
double up_bnd) {_bounds[0]=low_bnd; _bounds[1]=up_bnd;}
145 double getBound (
unsigned int i) {
return _bounds[i];}
149 deque< unsigned int > getUpdatingDates ();
151 deque< string > getTemporalArgs();
153 vector< string > getMultiArgs();
160 bool set (
string arg,
string& errmsg);
163 bool update (
unsigned int generation);
172 {
return (_type ==
MAT || (_arg.size() != 0 ? _arg[0] ==
'{' :
false) ); }
180 void getVariableMatrix (vector< vector <double> >* mat);
185 void parse_matrix (
TMatrix* mat);
186 void parse_variable_matrix (vector< vector <double> >* mat);
187 bool parseArgument (
string& arg);
188 bool parseTemporalArgument (
const string& arg);
189 bool parseAgeSpecArgument (
const string& arg);
190 bool parseSubParamArgument (
const string& arg);
191 string checkArgumentForExpansion (
string arg);
192 string getArgumentFromFile (
string file);
219 ParamSet ( ) : _isSet(0), _isRequired(0), _myOwner(0) { }
230 bool check_consistency ( );
234 void print (ofstream& FILE,
bool commentOut =
false);
236 int size ( ) {
return _params.size();}
252 double low_bnd,
double up_bnd)
253 {add_param(Name, Type, mandatory, isBounded, low_bnd, up_bnd, 0);}
255 void add_param (
string Name,
param_t Type,
bool mandatory,
bool isBounded,
263 bool set_param (
string Name,
string Arg);
267 Param* find_param (
string name);
271 Param* get_param (
string name);
276 bool has_param (
string name);
279 bool update_param (
string Name,
unsigned int generation);
293 bool isSet (
string name) {
return (get_param(name))->isSet();}
295 bool isMatrix (
string name) {
return (get_param(name))->isMatrix();}
297 bool isTemporal (
string name) {
return (get_param(name))->isTemporal();}
299 string getArg (
string name) {
return (get_param(name))->getArg();}
301 double getValue (
string name) {
return (get_param(name))->getValue();}
305 list<ParamUpdaterBase*> getUpdaters();
322 typedef list< Param* >::iterator
PIT;
338 virtual bool update (
unsigned int generation) = 0;
344 virtual void reset ( ) {_params.clear();}
364 bool (SC::*_myUpdaterFunction) (void);
371 _myUpdaterFunction = updateFuncPtr;
383 for(
PIT pit = _params.begin(); pit != _params.end(); pit++)
384 if((*pit)->getUpdater() ==
this) (*pit)->setUpdater(0);
390 _myComponent =
dynamic_cast<SC*
> ( (*_params.begin())->getOwner() );
392 for(
PIT pit = ++_params.begin(); pit != _params.end(); pit++)
393 assert(_myComponent == (*pit)->getOwner());
396 virtual bool update (
unsigned int generation)
398 return (((
dynamic_cast<SC*
> (_myComponent))->*_myUpdaterFunction) ());
403 _myUpdaterFunction = updateFuncPtr;
Service handler (an observer).
Definition: handler.h:35
Parameters container, implemented in each SimComponent.
Definition: param.h:205
map< string, Param * > _params
List of parameters indexed by name.
Definition: param.h:213
map< string, Param * > & getAllParams()
Returns the complete list of parameters.
Definition: param.h:238
SimComponent * _myOwner
Pointer to the component that declared this parameter.
Definition: param.h:215
void clear()
Empties the parameter containers (no delete).
Definition: param.h:226
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:303
string getArg(string name)
Accessor to the parameters argument string.
Definition: param.h:299
int size()
Returns the number of parameters contained.
Definition: param.h:236
double getValue(string name)
Accessor the parameters value.
Definition: param.h:301
ParamSet()
Definition: param.h:219
bool _isRequired
Flaf is true if component is required (mandatory) to run a simulation (e.g.
Definition: param.h:211
string getName()
Name accessor.
Definition: param.h:289
string _name
The name of the component.
Definition: param.h:207
bool isSet(string name)
Accessor to the parameters status flag.
Definition: param.h:293
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
bool isMatrix(string name)
Check if the parameter "name" is of matrix type.
Definition: param.h:295
void setOwner(SimComponent *owner)
Sets the pointer to the SimComponents that owns this set.
Definition: param.h:285
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
bool _isSet
Flag is true if all mandatory parameters are correctly set from user's input file.
Definition: param.h:209
bool isSet()
Accessor to the status flag.
Definition: param.h:287
bool isRequired()
Accessor to the mandatory flag.
Definition: param.h:291
void add_param(string Name, param_t Type, bool mandatory, bool isBounded, double low_bnd, double up_bnd)
Adds a new param specified by arguments to the list.
Definition: param.h:251
bool isTemporal(string name)
Check if the parameter "name" has temporal arguments.
Definition: param.h:297
Base class of the ParamUpdater class used to handle the temporal parameter argument values.
Definition: param.h:314
virtual ~ParamUpdaterBase()
Definition: param.h:333
virtual void addParam(Param *param)
Adds a parameter to the stack.
Definition: param.h:342
list< Param * > getParams()
Returns the list of parameters.
Definition: param.h:346
list< Param * >::iterator PIT
Definition: param.h:322
virtual void reset()
Clears the parameters stack.
Definition: param.h:344
virtual SimComponent * getComponent()=0
virtual void update()
Definition: param.h:336
ParamUpdaterBase(const ParamUpdaterBase &PU)
Definition: param.h:328
ParamUpdaterBase()
Definition: param.h:326
virtual bool update(unsigned int generation)=0
Updating procedure.
list< Param * > _params
List of the parameters affected by this updater.
Definition: param.h:318
Implementation of the ParamUpdaterBase interface.
Definition: param.h:362
bool(SC::* _myUpdaterFunction)(void)
Definition: param.h:364
virtual bool update(unsigned int generation)
Calls the SimComponent's updating function using its pointer.
Definition: param.h:396
virtual void init()
Sets the pointer to the SimComponent.
Definition: param.h:388
ParamUpdater(bool(SC::*updateFuncPtr)(void))
Definition: param.h:369
SC * _myComponent
Definition: param.h:365
virtual ~ParamUpdater()
Definition: param.h:381
virtual SC * getComponent()
Accessor to the SimComponent.
Definition: param.h:406
void setFuncPtr(bool(SC::*updateFuncPtr)(void))
Sets the pointer to the updating function.
Definition: param.h:401
ParamUpdater(const ParamUpdater< SC > &PU)
Definition: param.h:374
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
bool hasMultipleArgs()
Definition: param.h:143
bool _hasMultipleArgs
Definition: param.h:89
unsigned int _setAtGeneration
Generation at which the parameter has been set/updated.
Definition: param.h:72
void setArg(string value)
Sets the parameter's argument.
Definition: param.h:117
bool _isSet
Flag set once the parameter has recieved the right argument.
Definition: param.h:63
param_t getType()
Definition: param.h:138
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:171
vector< string > getExternalFiles()
Definition: param.h:155
bool isRequired()
Definition: param.h:141
param_t _type
The type of the argument, must one of DBL, INT, BOOL, STR or MAT (see types.h).
Definition: param.h:61
bool _isRequired
Flag telling if this parameter is mandatory.
Definition: param.h:68
bool isTemporal()
Definition: param.h:142
string getName()
Definition: param.h:136
map< unsigned int, string > _temporalArgs
The temporal arguments.
Definition: param.h:83
bool isBounded()
Definition: param.h:140
SimComponent * _myOwner
Pointer to the component that declared this parameter.
Definition: param.h:74
vector< string > _externalFile
External argument file.
Definition: param.h:79
bool _isBounded
Flag telling if the parameter has a bounded argument value.
Definition: param.h:65
void setBounds(double low_bnd, double up_bnd)
Sets the bounds.
Definition: param.h:127
vector< string > _multiArgs
Multiple arguments.
Definition: param.h:88
double getBound(unsigned int i)
Definition: param.h:145
string _arg
The argument string, set by the ParamsParser upon initialization.
Definition: param.h:57
string getArg()
Definition: param.h:137
void setType(param_t value)
Sets the parameter's type (see types.h)
Definition: param.h:119
ParamUpdaterBase * _myUpdater
Pointer to an ParamUpdater object.
Definition: param.h:76
bool _hasExternalFile
Definition: param.h:80
void setName(string value)
Sets the parameter's name.
Definition: param.h:115
ParamUpdaterBase * getUpdater()
Definition: param.h:147
void setUpdater(ParamUpdaterBase *updater)
Sets the pointer to the updater object.
Definition: param.h:131
string _name
The name of the parameter as read in the init file.
Definition: param.h:55
bool hasExternalFile()
Definition: param.h:144
bool isSet()
Definition: param.h:139
void setIsSet(bool value)
Sets the _isSet flag.
Definition: param.h:121
void setIsBounded(bool value)
Sets the _isBounded flag.
Definition: param.h:123
bool _isTemporal
Flag telling if this parameter has temporal arguments.
Definition: param.h:85
void setAtGeneration(unsigned int generation)
Definition: param.h:133
void setIsRequired(bool value)
Sets the isRequired flag.
Definition: param.h:125
SimComponent * getOwner()
Definition: param.h:146
string _input_arg
The input argument string, kept untouched as a backup for logging.
Definition: param.h:59
void setOwner(SimComponent *owner)
Sets the pointer to owner.
Definition: param.h:129
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:44
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
param_t
Param's types.
Definition: types.h:76
@ MAT
Definition: types.h:77