ThePEG::SwitchBase Class Reference

The Switch class and its base class SwitchBase defines an interface to a class derived from the InterfacedBase, through which simple integer member variables can be manuipulated and set to a pre-defined set of values (options). More...

#include <Switch.h>

Inheritance diagram for ThePEG::SwitchBase:

ThePEG::InterfaceBase ThePEG::Named ThePEG::Switch< T, Int >

List of all members.

Public Types

typedef map< long, SwitchOptionOptionMap
 A map with SwitchOptions indexed by their values.
typedef map< string, SwitchOptionStringMap
 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 OptionMapoptions () 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.


Detailed Description

The Switch class and its base class SwitchBase defines an interface to a class derived from the InterfacedBase, through which simple integer member variables can be manuipulated and set to a pre-defined set of values (options).

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.

See also:
InterfacedBase

InterfacedBase

Named

Definition at line 117 of file Switch.h.


Member Typedef Documentation

A map with SwitchOptions indexed by their values.

Definition at line 122 of file Switch.h.

A map with SwitchOptions indexed by their names.

Definition at line 124 of file Switch.h.


Constructor & Destructor Documentation

ThePEG::SwitchBase::SwitchBase ( string  newName,
string  newDescription,
string  newClassName,
const type_info &  newTypeInfo,
bool  depSafe,
bool  readonly 
) [inline]

Standard constructor.

Parameters:
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.

Definition at line 151 of file Switch.h.


Member Function Documentation

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.


Friends And Related Function Documentation

friend class SwitchOption [friend]

SwitchOption is a friend.

Definition at line 127 of file Switch.h.


The documentation for this class was generated from the following file:

Generated on Thu Apr 29 12:43:09 2010 for ThePEG by  doxygen 1.5.5