#include <param.h>

Public Member Functions | |
| ParamSet () | |
| ParamSet (const ParamSet &PS) | |
| ~ParamSet () | |
| void | reset () |
| Put the container in the unset state, reset each Param it contains. | |
| void | clear () |
| Empties the parameter containers (no delete). | |
| bool | check_consistency () |
| Checks for the status of the required parameters. | |
| void | show_up () |
| print info to stdout. | |
| void | print (ofstream &FILE) |
| print all set parameters to the outpout file stream | |
| int | size () |
| Returns the number of parameters contained. | |
| map< string, Param * > & | getAllParams () |
| Returns the complete list of parameters. | |
| ParamSet & | operator= (const ParamSet &PS) |
Accessors to Param members. | |
| void | add_param (Param *param) |
| Adds the param argument to the list. | |
| 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. | |
| void | add_param (string Name, param_t Type, bool mandatory, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater) |
| bool | set_param (string Name, string Arg) |
| Look for a param named "Name" and try to set it with the "Arg" argument string. | |
| Param * | get_param (string name) |
| Look for a param "name" in its parameters list. | |
| bool | update_param (string Name, unsigned int generation) |
| Calls the updating procedure of each of its Param. | |
| void | setName (string value) |
| Sets the container's name. | |
| void | setIsRequired (bool value) |
| Sets the _isRequired flag meaning this container is mandatory and must be set in order to run a simulation. | |
| void | setOwner (SimComponent *owner) |
| Sets the pointer to the SimComponents that owns this set. | |
| bool | isSet () |
| Accessor to the status flag. | |
| string | getName () |
| Name accessor. | |
| bool | isRequired () |
| Accessor to the mandatory flag. | |
| bool | isSet (string name) |
| Accessor to the parameters status flag. | |
| bool | isMatrix (string name) |
| Check if the parameter "name" is of matrix type. | |
| string | getArg (string name) |
| Accessor to the parameters argument string. | |
| double | getValue (string name) |
| Accessor the parameters value. | |
| void | getMatrix (string name, TMatrix *mat) |
| Accessor to the parameters matrix. | |
| list< ParamUpdaterBase * > | getUpdaters () |
| Collects the parameter updaters from the set of parameters. | |
Private Attributes | |
| string | _name |
| bool | _isSet |
| bool | _isRequired |
| map< string, Param * > | _params |
| SimComponent * | _myOwner |
| Pointer to the component that declared this parameter. | |
A SimComponent is added to the set of active components of a simulation only if all its required parameters are set (isSet = true).
Definition at line 180 of file param.h.
| ParamSet::ParamSet | ( | ) | [inline] |
| ParamSet::ParamSet | ( | const ParamSet & | PS | ) |
Definition at line 367 of file param.cc.
00368 : _name(PS._name), _isSet(PS._isSet), _isRequired(PS._isRequired) 00369 { 00370 map<string, Param*>::iterator param; 00371 00372 if( _params.size() ) { 00373 param = _params.begin(); 00374 while(param != _params.end()) { 00375 delete param->second; 00376 param++; 00377 } 00378 _params.clear(); 00379 } 00380 map<string, Param*> PS_params = PS._params; 00381 param = PS_params.begin(); 00382 while(param != PS_params.end()) { 00383 _params[param->first] = new Param( *param->second ); 00384 param++; 00385 } 00386 00387 }
| ParamSet::~ParamSet | ( | ) |
| void ParamSet::add_param | ( | string | Name, | |
| param_t | Type, | |||
| bool | mandatory, | |||
| bool | isBounded, | |||
| double | low_bnd, | |||
| double | up_bnd, | |||
| ParamUpdaterBase * | updater | |||
| ) |
| void ParamSet::add_param | ( | string | Name, | |
| param_t | Type, | |||
| bool | mandatory, | |||
| bool | isBounded, | |||
| double | low_bnd, | |||
| double | up_bnd | |||
| ) | [inline] |
Adds a new param specified by arguments to the list.
| Name | the name of the parameter | |
| Type | the type of the parameter | |
| mandatory | specifies if this parameter is required and must be set for the container to gain the "set" status | |
| isBounded | specified whether this parameter is bounded | |
| low_bnd | the lower value the parameter can take, used if isBounded is true | |
| up_bnd | the upper value the parameter can take, used if isBounded is true |
Definition at line 224 of file param.h.
Referenced by add_param().
00226 {add_param(Name, Type, mandatory, isBounded, low_bnd, up_bnd, 0);}
| void ParamSet::add_param | ( | Param * | param | ) | [inline] |
Adds the param argument to the list.
Definition at line 215 of file param.h.
Referenced by SimComponent::add_parameter(), and ParamManager::ParamManager().
| bool ParamSet::check_consistency | ( | ) |
Checks for the status of the required parameters.
Definition at line 482 of file param.cc.
00483 { 00484 map<string, Param*>::iterator param = _params.begin(); 00485 bool isOK = true; 00486 bool touched = false; 00487 00488 while(param != _params.end()) { 00489 //check if all required field have been set properly 00490 if(param->second->isRequired()) 00491 isOK &= param->second->isSet(); 00492 //else we don't care.. 00493 //check if at least one param has been set 00494 touched |= param->second->isSet(); 00495 param++; 00496 } 00497 _isSet = isOK; 00498 //return isOk or check if _isRequired in case no params are set (untouched params) 00499 return ( isOK | (!_isRequired));// & !touched) ); 00500 }
| void ParamSet::clear | ( | ) | [inline] |
| Param * ParamSet::get_param | ( | string | name | ) |
Look for a param "name" in its parameters list.
Definition at line 459 of file param.cc.
Referenced by SimComponent::get_parameter(), getArg(), getMatrix(), getValue(), isMatrix(), and isSet().
00460 { 00461 map<string, Param*>::iterator param = _params.find(Name); 00462 00463 if(param != _params.end()) 00464 return param->second; 00465 else 00466 fatal("parameter \"%s\" is not a member of \"%s\".\n", Name.c_str(), _name.c_str()); 00467 //return NULL; 00468 return NULL; 00469 }
| map<string, Param*>& ParamSet::getAllParams | ( | ) | [inline] |
| string ParamSet::getArg | ( | string | name | ) | [inline] |
Accessor to the parameters argument string.
Definition at line 260 of file param.h.
Referenced by LCE_Resize::execute(), SimRunner::init(), LCE_Selection_base::set_fit_model(), LCE_Selection_base::set_sel_model(), LCE_StatServiceNotifier::setParameters(), LCE_Patch_Extinction::setParameters(), LCE_Disperse_EvolDisp::setParameters(), TProtoDeletMutations_bitstring::setSelectionParameters(), Metapop::setSourceParameters(), and LCE_Resize::updateParameters().
00260 {return (get_param(name))->getArg();}
| void ParamSet::getMatrix | ( | string | name, | |
| TMatrix * | mat | |||
| ) | [inline] |
Accessor to the parameters matrix.
Definition at line 264 of file param.h.
Referenced by LCE_Resize::setParameters(), LCE_Disperse_base::setParameters(), Metapop::setPatchCapacities(), LCE_Selection_base::setSelectionMatrix(), LCE_Selection_base::setSpatialMatrix(), and LCE_Resize::updateParameters().
00264 {return (get_param(name))->getMatrix(mat);}
| string ParamSet::getName | ( | ) | [inline] |
Name accessor.
Definition at line 252 of file param.h.
Referenced by SimComponent::get_name().
00252 {return _name;}
| list< ParamUpdaterBase * > ParamSet::getUpdaters | ( | ) |
Collects the parameter updaters from the set of parameters.
Definition at line 426 of file param.cc.
Referenced by SimComponent::loadUpdaters().
00427 { 00428 list<ParamUpdaterBase*> updaters; 00429 map<string, Param*>::iterator param = _params.begin(); 00430 for(;param != _params.end(); param++) { 00431 if(param->second->getUpdater() != 0) 00432 updaters.push_back(param->second->getUpdater()); 00433 } 00434 return updaters; 00435 }
| double ParamSet::getValue | ( | string | name | ) | [inline] |
Accessor the parameters value.
Definition at line 262 of file param.h.
Referenced by SimComponent::get_parameter_value(), SimRunner::init(), SimRunner::init_random_seed(), LCE_Breed_base::setMatingSystem(), LCE_StatServiceNotifier::setParameters(), LCE_Disperse_EvolDisp::setParameters(), LCE_Disperse_base::setParameters(), Metapop::setPopulationParameters(), and Metapop::setSourceParameters().
00262 {return (get_param(name))->getValue();}
| bool ParamSet::isMatrix | ( | string | name | ) | [inline] |
Check if the parameter "name" is of matrix type.
Definition at line 258 of file param.h.
Referenced by LCE_Resize::setParameters(), and Metapop::setPopulationParameters().
00258 {return (get_param(name))->isMatrix();}
| bool ParamSet::isRequired | ( | ) | [inline] |
| bool ParamSet::isSet | ( | string | name | ) | [inline] |
| bool ParamSet::isSet | ( | ) | [inline] |
Accessor to the status flag.
Definition at line 250 of file param.h.
Referenced by SimRunner::init(), Metapop::init(), SimRunner::init_random_seed(), LCE_Selection_base::set_fit_model(), LCE_Selection_base::set_sel_model(), LCE_Disperse_base::setIsland_PropagulePool_Matrix(), LCE_Disperse_base::setLatticeMatrix(), LCE_Breed_base::setMatingSystem(), LCE_Disperse_EvolDisp::setParameters(), LCE_Disperse_base::setParameters(), Metapop::setPopulationParameters(), Metapop::setSourceParameters(), and LCE_Selection_base::setSpatialMatrix().
00250 {return _isSet;}
Definition at line 504 of file param.cc.
00505 { 00506 if(this != &PS) { 00507 _name = PS._name; 00508 _isSet = PS._isSet; 00509 _isRequired = PS._isRequired; 00510 00511 map<string, Param*>::iterator param; 00512 00513 if( _params.size() ) { 00514 param = _params.begin(); 00515 while(param != _params.end()) { 00516 delete param->second; 00517 param++; 00518 } 00519 _params.clear(); 00520 } 00521 map<string, Param*> PS_params = PS._params; 00522 param = PS_params.begin(); 00523 while(param != PS_params.end()) { 00524 _params[param->first] = new Param( *param->second ); 00525 param++; 00526 } 00527 } 00528 return *this; 00529 }
| void ParamSet::print | ( | ofstream & | FILE | ) |
print all set parameters to the outpout file stream
Definition at line 545 of file param.cc.
00546 { 00547 // FILE<<_name<<endl; 00548 map<string, Param*>::iterator param = _params.begin(); 00549 while(param != _params.end()) { 00550 if(param->second->isSet()){ 00551 // FILE.width(20); 00552 // FILE.setf(ios::left,ios::adjustfield); 00553 FILE<<param->second->getName()<<" "<<param->second->getArg()<<endl; 00554 } 00555 param++; 00556 } 00557 }
| void ParamSet::reset | ( | ) |
| bool ParamSet::set_param | ( | string | Name, | |
| string | Arg | |||
| ) |
Look for a param named "Name" and try to set it with the "Arg" argument string.
FALSE otherwise
| Name | the name of the parameter to find in the list | |
| Arg | the argument string as found in the init params |
Definition at line 439 of file param.cc.
Referenced by LCE_Resize::execute().
00440 { 00441 map<string, Param*>::iterator param = _params.find(Name); 00442 string error_msg; 00443 00444 if(param == _params.end()) { 00445 // error("could not set \"%s\": parameter not found.\n",Name.c_str()); 00446 //exist silently 00447 return false; 00448 } 00449 00450 if( !param->second->set(Arg, error_msg) ) { 00451 error("could not set \"%s\": %s.\n", Name.c_str(), error_msg.c_str()); 00452 return false; 00453 } else 00454 return true; 00455 }
| void ParamSet::setIsRequired | ( | bool | value | ) | [inline] |
Sets the _isRequired flag meaning this container is mandatory and must be set in order to run a simulation.
Definition at line 246 of file param.h.
Referenced by ParamManager::ParamManager(), and SimComponent::set_paramset().
00246 {_isRequired = value;}
| void ParamSet::setName | ( | string | value | ) | [inline] |
Sets the container's name.
Definition at line 244 of file param.h.
Referenced by ParamManager::ParamManager(), and SimComponent::set_paramset().
00244 {_name = value;}
| void ParamSet::setOwner | ( | SimComponent * | owner | ) | [inline] |
Sets the pointer to the SimComponents that owns this set.
Definition at line 248 of file param.h.
Referenced by ParamManager::ParamManager(), and SimComponent::set_paramset().
00248 {_myOwner = owner;}
| void ParamSet::show_up | ( | ) |
| int ParamSet::size | ( | ) | [inline] |
| bool ParamSet::update_param | ( | string | Name, | |
| unsigned int | generation | |||
| ) |
bool ParamSet::_isRequired [private] |
bool ParamSet::_isSet [private] |
SimComponent* ParamSet::_myOwner [private] |
Pointer to the component that declared this parameter.
Definition at line 188 of file param.h.
Referenced by setOwner().
string ParamSet::_name [private] |
map<string, Param*> ParamSet::_params [private] |
Definition at line 186 of file param.h.
Referenced by add_param(), clear(), getAllParams(), and size().
1.5.8 -- Nemo is hosted by