107 Param (
string& Name,
param_t Type,
bool mandatory,
bool bounded,
double low_bnd,
double up_bnd,
122 void setArg (
string value) {_arg = value; _input_arg = value;}
132 void setBounds (
double low_bnd,
double up_bnd) {_bounds[0]=low_bnd; _bounds[1]=up_bnd;}
154 double getBound (
unsigned int i) {
return _bounds[i];}
158 deque< unsigned int > getUpdatingDates ();
160 deque< string > getTemporalArgs();
162 vector< string > getMultiArgs();
169 bool set (
string arg,
string& errmsg);
172 bool update (
unsigned int generation);
181 {
return (_type ==
MAT || (_arg.size() != 0 ? _arg[0] ==
'{' :
false) ); }
189 void getVariableMatrix (vector< vector <double> >* mat);
194 void parse_matrix (
TMatrix* mat);
195 void parse_variable_matrix (vector< vector <double> >* mat);
196 bool parseArgument (
string& arg);
197 bool parseTemporalArgument (
const string& arg);
198 bool parseAgeSpecArgument (
const string& arg);
199 bool parseSubParamArgument (
const string& arg);
200 string checkArgumentForExpansion (
string arg);
201 string getArgumentFromFile (
string file);
228 ParamSet ( ) : _isSet(0), _isRequired(0), _myOwner(0) { }
239 bool check_consistency ( );
243 void print (ofstream& FILE,
bool commentOut =
false);
245 int size ( ) {
return _params.size();}
261 double low_bnd,
double up_bnd)
262 {add_param(Name, Type, mandatory, isBounded, low_bnd, up_bnd, 0);}
264 void add_param (
string Name,
param_t Type,
bool mandatory,
bool isBounded,
272 bool set_param (
string Name,
string Arg);
276 Param* find_param (
string name);
280 Param* get_param (
string name);
285 bool has_param (
string name);
288 bool update_param (
string Name,
unsigned int generation);
302 bool isSet (
string name) {
return (get_param(name))->isSet();}
304 bool isMatrix (
string name) {
return (get_param(name))->isMatrix();}
306 bool isTemporal (
string name) {
return (get_param(name))->isTemporal();}
308 string getArg (
string name) {
return (get_param(name))->getArg();}
310 double getValue (
string name) {
return (get_param(name))->getValue();}
314 list<ParamUpdaterBase*> getUpdaters();
331 typedef list< Param* >::iterator
PIT;
347 virtual bool update (
unsigned int generation) = 0;
353 virtual void reset ( ) {_params.clear();}
373 bool (SC::*_myUpdaterFunction) (void);
380 _myUpdaterFunction = updateFuncPtr;
392 for(
PIT pit = _params.begin(); pit != _params.end(); pit++)
393 if((*pit)->getUpdater() ==
this) (*pit)->setUpdater(0);
399 _myComponent =
dynamic_cast<SC*
> ( (*_params.begin())->getOwner() );
401 for(
PIT pit = ++_params.begin(); pit != _params.end(); pit++)
402 assert(_myComponent == (*pit)->getOwner());
405 virtual bool update (
unsigned int generation)
407 return (((
dynamic_cast<SC*
> (_myComponent))->*_myUpdaterFunction) ());
412 _myUpdaterFunction = updateFuncPtr;
Service handler (an observer).
Definition: handler.h:34
Parameters container, implemented in each SimComponent.
Definition: param.h:214
map< string, Param * > _params
List of parameters indexed by name.
Definition: param.h:222
map< string, Param * > & getAllParams()
Returns the complete list of parameters.
Definition: param.h:247
SimComponent * _myOwner
Pointer to the component that declared this parameter.
Definition: param.h:224
void clear()
Empties the parameter containers (no delete).
Definition: param.h:235
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:312
string getArg(string name)
Accessor to the parameters argument string.
Definition: param.h:308
int size()
Returns the number of parameters contained.
Definition: param.h:245
double getValue(string name)
Accessor the parameters value.
Definition: param.h:310
ParamSet()
Definition: param.h:228
bool _isRequired
Flaf is true if component is required (mandatory) to run a simulation (e.g.
Definition: param.h:220
string getName()
Name accessor.
Definition: param.h:298
string _name
The name of the component.
Definition: param.h:216
bool isSet(string name)
Accessor to the parameters status flag.
Definition: param.h:302
void add_param(Param *param)
Adds the param argument to the list.
Definition: param.h:251
void setName(string value)
Sets the container's name.
Definition: param.h:290
bool isMatrix(string name)
Check if the parameter "name" is of matrix type.
Definition: param.h:304
void setOwner(SimComponent *owner)
Sets the pointer to the SimComponents that owns this set.
Definition: param.h:294
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:292
bool _isSet
Flag is true if all mandatory parameters are correctly set from user's input file.
Definition: param.h:218
bool isSet()
Accessor to the status flag.
Definition: param.h:296
bool isRequired()
Accessor to the mandatory flag.
Definition: param.h:300
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:260
bool isTemporal(string name)
Check if the parameter "name" has temporal arguments.
Definition: param.h:306
Base class of the ParamUpdater class used to handle the temporal parameter argument values.
Definition: param.h:323
virtual ~ParamUpdaterBase()
Definition: param.h:342
virtual void addParam(Param *param)
Adds a parameter to the stack.
Definition: param.h:351
list< Param * > getParams()
Returns the list of parameters.
Definition: param.h:355
list< Param * >::iterator PIT
Definition: param.h:331
virtual void reset()
Clears the parameters stack.
Definition: param.h:353
virtual SimComponent * getComponent()=0
virtual void update()
Definition: param.h:345
ParamUpdaterBase(const ParamUpdaterBase &PU)
Definition: param.h:337
ParamUpdaterBase()
Definition: param.h:335
virtual bool update(unsigned int generation)=0
Updating procedure.
list< Param * > _params
List of the parameters affected by this updater.
Definition: param.h:327
Implementation of the ParamUpdaterBase interface.
Definition: param.h:371
bool(SC::* _myUpdaterFunction)(void)
Definition: param.h:373
virtual bool update(unsigned int generation)
Calls the SimComponent's updating function using its pointer.
Definition: param.h:405
virtual void init()
Sets the pointer to the SimComponent.
Definition: param.h:397
ParamUpdater(bool(SC::*updateFuncPtr)(void))
Definition: param.h:378
SC * _myComponent
Definition: param.h:374
virtual ~ParamUpdater()
Definition: param.h:390
virtual SC * getComponent()
Accessor to the SimComponent.
Definition: param.h:415
void setFuncPtr(bool(SC::*updateFuncPtr)(void))
Sets the pointer to the updating function.
Definition: param.h:410
ParamUpdater(const ParamUpdater< SC > &PU)
Definition: param.h:383
This structure stores one parameter, its definition and its string argument.
Definition: param.h:52
bool hasMultipleArgs()
Definition: param.h:150
bool _hasMultipleArgs
Definition: param.h:88
unsigned int _setAtGeneration
Generation at which the parameter has been set/updated.
Definition: param.h:71
bool _hasPreservedMacro
Flag telling if this parameter's argument holds a macro preserved by the P() macro,...
Definition: param.h:94
void setArg(string value)
Sets the parameter's argument.
Definition: param.h:122
bool _isSet
Flag set once the parameter has recieved the right argument.
Definition: param.h:62
param_t getType()
Definition: param.h:145
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:180
vector< string > getExternalFiles()
Definition: param.h:164
bool isRequired()
Definition: param.h:148
param_t _type
The type of the argument, must one of DBL, INT, BOOL, STR or MAT (see types.h).
Definition: param.h:60
bool _isRequired
Flag telling if this parameter is mandatory.
Definition: param.h:67
bool isTemporal()
Definition: param.h:149
string getName()
Definition: param.h:141
map< unsigned int, string > _temporalArgs
The temporal arguments.
Definition: param.h:82
bool isBounded()
Definition: param.h:147
void clearPreservedMacro()
Definition: param.h:152
SimComponent * _myOwner
Pointer to the component that declared this parameter.
Definition: param.h:73
vector< string > _externalFile
External argument file.
Definition: param.h:78
bool _isBounded
Flag telling if the parameter has a bounded argument value.
Definition: param.h:64
void setBounds(double low_bnd, double up_bnd)
Sets the bounds.
Definition: param.h:132
vector< string > _multiArgs
Multiple arguments.
Definition: param.h:87
double getBound(unsigned int i)
Definition: param.h:154
string _arg
The argument string, set by the ParamsParser upon initialization.
Definition: param.h:56
string getArg()
Definition: param.h:142
void setType(param_t value)
Sets the parameter's type (see types.h)
Definition: param.h:124
string getInputArg()
Returns the original, untouched input argument string (for logging).
Definition: param.h:144
ParamUpdaterBase * _myUpdater
Pointer to an ParamUpdater object.
Definition: param.h:75
bool _hasExternalFile
Definition: param.h:79
void setName(string value)
Sets the parameter's name.
Definition: param.h:120
ParamUpdaterBase * getUpdater()
Definition: param.h:156
void setUpdater(ParamUpdaterBase *updater)
Sets the pointer to the updater object.
Definition: param.h:136
string _name
The name of the parameter as read in the init file.
Definition: param.h:54
bool hasExternalFile()
Definition: param.h:153
bool isSet()
Definition: param.h:146
void setIsSet(bool value)
Sets the _isSet flag.
Definition: param.h:126
void setIsBounded(bool value)
Sets the _isBounded flag.
Definition: param.h:128
bool _isTemporal
Flag telling if this parameter has temporal arguments.
Definition: param.h:84
void setAtGeneration(unsigned int generation)
Definition: param.h:138
void setIsRequired(bool value)
Sets the isRequired flag.
Definition: param.h:130
SimComponent * getOwner()
Definition: param.h:155
string _input_arg
The input argument string, kept untouched as a backup for logging.
Definition: param.h:58
void setOwner(SimComponent *owner)
Sets the pointer to owner.
Definition: param.h:134
bool hasPreservedMacro()
Definition: param.h:151
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:43
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:48
param_t
Param's types.
Definition: types.h:75
@ MAT
Definition: types.h:76