Abstact class for configurable objects. More...
#include <configurable.h>
Inherited by AbstractController, AbstractModel, AbstractRobot, OdeConfig, Simulation, MotorNoiseWiring, and QLearning.
Classes | |
struct | matchId |
nice predicate function for finding by ID More... | |
Public Types | |
typedef std::string | paramkey |
typedef std::string | paramdescr |
typedef double | paramval |
typedef std::list< std::pair < paramkey, paramval > > | paramlist |
typedef std::map< paramkey, paramval * > | parammap |
typedef bool | parambool |
typedef std::list< std::pair < paramkey, parambool > > | paramboollist |
typedef std::map< paramkey, parambool * > | paramboolmap |
typedef int | paramint |
typedef std::list< std::pair < paramkey, paramint > > | paramintlist |
typedef std::map< paramkey, paramint * > | paramintmap |
typedef std::map< paramkey, paramdescr > | paramdescrmap |
Public Member Functions | |
Configurable () | |
Configurable (const std::string &name, const std::string &revision) | |
intialise with name and revision (use "$ID$") | |
virtual | ~Configurable () |
int | getId () const |
return the id of the configurable objects, which is created by random on initialisation | |
virtual paramkey | getName () const |
return the name of the object | |
virtual paramkey | getRevision () const |
returns the revision of the object | |
virtual void | setName (const paramkey &name) |
stes the name of the object | |
virtual void | setRevision (const paramkey &revision) |
sets the revision Hint: { return "$ID$"; } | |
virtual paramval | getParam (const paramkey &key) const |
returns the value of the requested parameter or 0 (+ error message to stderr) if unknown. | |
virtual bool | setParam (const paramkey &key, paramval val) |
sets the value of the given parameter or does nothing if unknown. | |
virtual paramlist | getParamList () const |
The list of all parameters with there value as allocated lists. | |
virtual std::list< paramkey > | getAllParamNames () |
returns all names that are configureable | |
virtual paramdescr | getParamDescr (const paramkey &key) const |
returns the description for the given parameter | |
virtual void | setParamDescr (const paramkey &key, const paramdescr &descr) |
sets a description for the given parameter | |
virtual void | addParameter (const paramkey &key, paramval *val, const paramdescr &descr=paramdescr()) |
This is the new style for adding configurable parameters. | |
virtual void | addParameter (const paramkey &key, parambool *val, const paramdescr &descr=paramdescr()) |
See addParameter(const paramkey& key, paramval* val) but for bool values. | |
virtual void | addParameter (const paramkey &key, paramint *val, const paramdescr &descr=paramdescr()) |
See addParameter(const paramkey& key, paramval* val) but for int values. | |
virtual void | addParameterDef (const paramkey &key, paramval *val, paramval def, const paramdescr &descr=paramdescr()) |
This function is only provided for convenience. | |
virtual void | addParameterDef (const paramkey &key, parambool *val, parambool def, const paramdescr &descr=paramdescr()) |
See addParameterDef(const paramkey&, paramval*, paramval). | |
virtual void | addParameterDef (const paramkey &key, paramint *val, paramint def, const paramdescr &descr=paramdescr()) |
See addParameterDef(const paramkey&, paramval*, paramval). | |
virtual bool | storeCfg (const char *filenamestem, const std::list< std::string > &comments=std::list< std::string >()) |
stores the key values paires into the file : filenamestem.cfg including the comments given in the list | |
virtual bool | restoreCfg (const char *filenamestem) |
restores the key values paires from the file : filenamestem.cfg | |
void | print (FILE *f, const char *prefix, int columns=90) const |
prints the keys, values and descriptions to the file. Each line is prefixed | |
void | printdescr (FILE *f, const char *prefix, const paramkey &key, int columns, int indent) const |
void | parse (FILE *f) |
Static Public Member Functions | |
static void | insertCVSInfo (paramkey &str, const char *file, const char *revision) |
This is a utility function for inserting the filename and the revision number at the beginning of the given string buffer str and terminates it. |
Abstact class for configurable objects.
Sort of Hashmap interface. Parameters are double, int or boolean values
The Configurator is a (planned) external tool that can be used for changing the values of configurable objects.
Protocoll for Configurator:
To Configurator (BNF notation): Conf := <Comp>* Comp := <CompName> <Pair>* CompName := [<string>][<int>]<newline> Pair := <alphanum>=<double><newline>
the remaining tags are self explanatory
Example
[Component name which can contain spaces and digits and .,- ][ID1] key1 = value1 key2 = value2 . . [Other Component name which can contain spaces and digits and .,- ][ID2] key3 = value3
Answer: (from Communicator to Simulation environment)
1. On change of a parameter:
[ID] key=newvalue
or
key=newvalue
the latter one means that the parameter is changed in all components
2. Request of the description as defined above.
#Something I don\'t care
typedef bool parambool |
typedef std::list<std::pair<paramkey, parambool> > paramboollist |
typedef std::map<paramkey, parambool*> paramboolmap |
typedef std::string paramdescr |
typedef std::map<paramkey, paramdescr> paramdescrmap |
typedef int paramint |
typedef std::list<std::pair<paramkey, paramint> > paramintlist |
typedef std::map<paramkey, paramint*> paramintmap |
typedef std::string paramkey |
typedef double paramval |
Configurable | ( | ) | [inline] |
Configurable | ( | const std::string & | name, | |
const std::string & | revision | |||
) | [inline] |
intialise with name and revision (use "$ID$")
virtual ~Configurable | ( | ) | [inline, virtual] |
virtual void addParameter | ( | const paramkey & | key, | |
paramint * | val, | |||
const paramdescr & | descr = paramdescr() | |||
) | [inline, virtual] |
See addParameter(const paramkey& key, paramval* val) but for int values.
virtual void addParameter | ( | const paramkey & | key, | |
parambool * | val, | |||
const paramdescr & | descr = paramdescr() | |||
) | [inline, virtual] |
See addParameter(const paramkey& key, paramval* val) but for bool values.
virtual void addParameter | ( | const paramkey & | key, | |
paramval * | val, | |||
const paramdescr & | descr = paramdescr() | |||
) | [inline, virtual] |
This is the new style for adding configurable parameters.
Just call this function for each parameter and you are done. If you need to do some special treatment for setting (or getting) of the parameter you can handle this by overloading getParam and setParam
virtual void addParameterDef | ( | const paramkey & | key, | |
paramint * | val, | |||
paramint | def, | |||
const paramdescr & | descr = paramdescr() | |||
) | [inline, virtual] |
See addParameterDef(const paramkey&, paramval*, paramval).
virtual void addParameterDef | ( | const paramkey & | key, | |
parambool * | val, | |||
parambool | def, | |||
const paramdescr & | descr = paramdescr() | |||
) | [inline, virtual] |
See addParameterDef(const paramkey&, paramval*, paramval).
virtual void addParameterDef | ( | const paramkey & | key, | |
paramval * | val, | |||
paramval | def, | |||
const paramdescr & | descr = paramdescr() | |||
) | [inline, virtual] |
This function is only provided for convenience.
It does the same as addParameter but set the variable to the default value
std::list< Configurable::paramkey > getAllParamNames | ( | ) | [virtual] |
returns all names that are configureable
int getId | ( | ) | const [inline] |
return the id of the configurable objects, which is created by random on initialisation
virtual paramkey getName | ( | ) | const [inline, virtual] |
return the name of the object
Reimplemented in Elman, InvertNChannelController, OneLayerFFNN, and Arm.
Configurable::paramval getParam | ( | const paramkey & | key | ) | const [virtual] |
returns the value of the requested parameter or 0 (+ error message to stderr) if unknown.
Reimplemented in AbstractControllerAdapter, ClassicReinforce, FFNNController, InvertController, InvertMotorBigModel, MutualInformationController, use_java_controller, MyRobot, OdeConfig, Arm, Arm2Segm, DefaultCaterPillar, DefaultWheelie, Hand, HurlingSnake, MuscledArm, Schlange, SliderWheelie, Uwo, and VierBeiner.
Configurable::paramdescr getParamDescr | ( | const paramkey & | key | ) | const [virtual] |
returns the description for the given parameter
virtual paramlist getParamList | ( | ) | const [inline, virtual] |
The list of all parameters with there value as allocated lists.
Note that these are only parameters that are managed manually (with setParam, getParam)
Reimplemented in AbstractControllerAdapter, ClassicReinforce, FFNNController, InvertController, InvertMotorBigModel, MutualInformationController, OneLayerFFNN, use_java_controller, MyRobot, OdeConfig, Arm, Arm2Segm, DefaultCaterPillar, DefaultWheelie, Hand, HurlingSnake, MuscledArm, Schlange, SliderWheelie, Uwo, and VierBeiner.
virtual paramkey getRevision | ( | ) | const [inline, virtual] |
returns the revision of the object
void insertCVSInfo | ( | paramkey & | str, | |
const char * | file, | |||
const char * | revision | |||
) | [static] |
This is a utility function for inserting the filename and the revision number at the beginning of the given string buffer str and terminates it.
str | buffer (call by reference) that should have space for file+revision+2 characters | |
file | filename given by CVS i.e. |
revision | revision number given by CVS i.e. |
void parse | ( | FILE * | f | ) |
void print | ( | FILE * | f, | |
const char * | prefix, | |||
int | columns = 90 | |||
) | const |
prints the keys, values and descriptions to the file. Each line is prefixed
void printdescr | ( | FILE * | f, | |
const char * | prefix, | |||
const paramkey & | key, | |||
int | columns, | |||
int | indent | |||
) | const |
bool restoreCfg | ( | const char * | filenamestem | ) | [virtual] |
restores the key values paires from the file : filenamestem.cfg
virtual void setName | ( | const paramkey & | name | ) | [inline, virtual] |
stes the name of the object
sets the value of the given parameter or does nothing if unknown.
Reimplemented in AbstractControllerAdapter, AbstractIAFController, BasicController, ClassicReinforce, FFNNController, InvertController, InvertMotorBigModel, MutualInformationController, use_java_controller, MyRobot, OdeConfig, Arm, Arm2Segm, CaterPillar, DefaultCaterPillar, DefaultWheelie, Hand, HurlingSnake, MuscledArm, Schlange, SchlangeServo, SchlangeServo2, SliderWheelie, Uwo, VierBeiner, and Wheelie.
virtual void setParamDescr | ( | const paramkey & | key, | |
const paramdescr & | descr | |||
) | [inline, virtual] |
sets a description for the given parameter
virtual void setRevision | ( | const paramkey & | revision | ) | [inline, virtual] |
sets the revision Hint: { return "$ID$"; }
bool storeCfg | ( | const char * | filenamestem, | |
const std::list< std::string > & | comments = std::list<std::string>() | |||
) | [virtual] |
stores the key values paires into the file : filenamestem.cfg including the comments given in the list