#include <Switch.h>
Public Types | |
typedef map< long, SwitchOption > | OptionMap |
A map with SwitchOptions indexed by their values. | |
typedef map< string, SwitchOption > | StringMap |
A map with SwitchOptions indexed by their names. | |
Public Member Functions | |
SwitchBase (string newName, string newDescription, string newClassName, const type_info &newTypeInfo, bool depSafe, bool readonly) | |
Standard constructor. | |
virtual string | exec (InterfacedBase &ib, string action, string arguments) const |
The general interface method overriding the one in InterfaceBase. | |
virtual string | fullDescription (const InterfacedBase &ib) const |
Return a complete description of this switch. | |
virtual string | type () const |
Return a code for the type of this switch. | |
virtual void | set (InterfacedBase &ib, long val) const =0 |
Set the member variable of ib to val. | |
virtual long | get (const InterfacedBase &ib) const =0 |
Return the value of the member variable of ib. | |
virtual long | def (const InterfacedBase &ib) const =0 |
Return the default value for the member variable of ib. | |
void | setDef (InterfacedBase &i) const |
Set the member variable of ib to its default value. | |
bool | check (long newValue) const |
Check if val is among the listed options. | |
const OptionMap & | options () const |
Return the map relating options to their values. | |
virtual string | doxygenType () const |
Return a string describing the type of interface to be included in the Doxygen documentation. | |
Protected Member Functions | |
void | registerOption (const SwitchOption &o) |
Register a new option. | |
Private Attributes | |
OptionMap | theOptions |
The map relating options to their values. | |
StringMap | theOptionNames |
The map relating options to their names. | |
Friends | |
class | SwitchOption |
SwitchOption is a friend. |
Switch is templated on the type of the integer member variable and the type of the class, and is derived from the InterfaceBase class via SwitchBase
.
The Switch class has a set of Named SwitchOptions, which limits the values possible to set.
For each InterfacedBase class exactly one static Switch object should created for each member variable which should be interfaced. This object will automatically register itself with the BaseRepository class. Also for each Switch object exactly one static SwitchOption object should be created for each valid integer option.
Definition at line 117 of file Switch.h.
typedef map<long, SwitchOption> ThePEG::SwitchBase::OptionMap |
typedef map<string, SwitchOption> ThePEG::SwitchBase::StringMap |
ThePEG::SwitchBase::SwitchBase | ( | string | newName, | |
string | newDescription, | |||
string | newClassName, | |||
const type_info & | newTypeInfo, | |||
bool | depSafe, | |||
bool | readonly | |||
) | [inline] |
Standard constructor.
newName | the name of the interface, may only contain letters [a-zA-z0-9_]. | |
newDescription | a brief description of the interface. | |
newClassName | the name of the corresponding class. | |
newTypeInfo | the type_info object of the corresponding class. | |
depSafe | set to true if calls to this interface for one object does not influence other objects. | |
readonly | if this is set true the interface will not be able to manipulate objects of the corresponding class, but will still be able to access information. |
virtual string ThePEG::SwitchBase::exec | ( | InterfacedBase & | ib, | |
string | action, | |||
string | arguments | |||
) | const [virtual] |
The general interface method overriding the one in InterfaceBase.
For this class, action can be any of "set", "get", "def" and "setdef" and argument should be a something which can be read into an integer variable through a stringstream with the standard '>>' operator.
Implements ThePEG::InterfaceBase.
friend class SwitchOption [friend] |