thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ThePEG::SwitchBase Class Referenceabstract

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:

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.
 
string opttag (long opt) const
 Return a string with the option index and its associated tag.
 
- Public Member Functions inherited from ThePEG::InterfaceBase
 InterfaceBase (string newName, string newDescription, string newClassName, const type_info &newTypeInfo, bool depSafe, bool readonly)
 Standard constructor.
 
virtual ~InterfaceBase ()
 The destructor.
 
string tag (int pos=-1) const
 Create a tag for this interface using its name and optional poisitional argument.
 
virtual string exec (InterfacedBase &ib, string action, string arguments) const =0
 Manipulate an object of the corresponding class.
 
virtual string type () const =0
 Return a code for the type of this interface.
 
virtual bool notDefault (InterfacedBase &) const
 Returns true if the setting for this interface has been changed from its default value.
 
map< string, string > & objectDefaults (InterfacedBase &) const
 Returns the map of objectDefaults of the given object.
 
virtual void rebind (InterfacedBase &, const TranslationMap &, const IVector &=IVector()) const
 Rebind all references in ib according to the translation map.
 
virtual IVector getReferences (const InterfacedBase &) const
 For derived classes interfacing references between Interfaced objects, return the references for this interface.
 
string description () const
 Return the description of this interface.
 
virtual string fullDescription (const InterfacedBase &ib) const
 Return a complete description of this interface.
 
virtual void doxygenDescription (ostream &stream) const
 Print a description to be included in the Doxygen documentation to the given stream.
 
virtual string doxygenType () const =0
 Return a string describing the type of interface to be included in the Doxygen documentation.
 
string className () const
 Return the class name for the class this interface is defined for.
 
bool dependencySafe () const
 Get the flag saying whether changing an object with this interface may change the state of a dependent object .
 
void setDependencySafe ()
 Set the flag saying whether changing an object with this interface may change the state of a dependent object .
 
void setDependencySensitive ()
 Set the flag saying whether changing an object with this interface may change the state of a dependent object .
 
bool readOnly () const
 Get the flag saying whether this interface is allowed to change an object.
 
void setReadOnly ()
 Set the flag saying that this interface is allowed to change an object.
 
void setReadWrite ()
 Unset the flag saying that this interface is allowed to change an object.
 
bool anonymous () const
 Return true if this interface is anonyous, ie.
 
double rank () const
 Get the rank for this interface.
 
void rank (double r)
 Set the rank for this interface.
 
void setHasDefault (bool b)
 Indicate that this interface has a default value.
 
- Public Member Functions inherited from ThePEG::Named
 Named (const string &newName=string())
 Constructor with name.
 
 Named (const Named &)=default
 Explicit default copy-constructor (too avoid compiler warnings)
 
const string & name () const
 Return name.
 
bool operator== (const Named &other) const
 Test for equality.
 
bool operator< (const Named &other) const
 Lexicographical comparison.
 

Protected Member Functions

void registerOption (const SwitchOption &o)
 Register a new option.
 
- Protected Member Functions inherited from ThePEG::Named
const Namedoperator= (const Named &other)
 Assignment.
 
const string & name (const string &newName)
 Set new name.
 

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.
 

Additional Inherited Members

- Static Public Attributes inherited from ThePEG::InterfaceBase
static bool NoReadOnly
 If set to true, all read-only interfaces can be changed.
 
- Protected Attributes inherited from ThePEG::InterfaceBase
bool hasDefault
 A flag indicating whether this interface has a default setting.
 
bool isDependencySafe
 The flag saying whether changing an object with this interface may change the state of a dependent object .
 
bool isReadOnly
 The flag saying whether this interface is allowed to change an object.
 

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 118 of file Switch.h.

Member Typedef Documentation

◆ OptionMap

A map with SwitchOptions indexed by their values.

Definition at line 123 of file Switch.h.

◆ StringMap

A map with SwitchOptions indexed by their names.

Definition at line 125 of file Switch.h.

Constructor & Destructor Documentation

◆ SwitchBase()

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

Standard constructor.

Parameters
newNamethe name of the interface, may only contain letters [a-zA-z0-9_].
newDescriptiona brief description of the interface.
newClassNamethe name of the corresponding class.
newTypeInfothe type_info object of the corresponding class.
depSafeset to true if calls to this interface for one object does not influence other objects.
readonlyif 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 152 of file Switch.h.

Member Function Documentation

◆ check()

bool ThePEG::SwitchBase::check ( long  newValue) const
inline

Check if val is among the listed options.

Definition at line 206 of file Switch.h.

References ThePEG::member(), and theOptions.

◆ def()

virtual long ThePEG::SwitchBase::def ( const InterfacedBase ib) const
pure virtual

Return the default value for the member variable of ib.

Implemented in ThePEG::Switch< T, Int >.

Referenced by setDef().

◆ doxygenType()

virtual string ThePEG::SwitchBase::doxygenType ( ) const
virtual

Return a string describing the type of interface to be included in the Doxygen documentation.

Implements ThePEG::InterfaceBase.

◆ exec()

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.

◆ fullDescription()

virtual string ThePEG::SwitchBase::fullDescription ( const InterfacedBase ib) const
virtual

Return a complete description of this switch.

Reimplemented from ThePEG::InterfaceBase.

◆ get()

virtual long ThePEG::SwitchBase::get ( const InterfacedBase ib) const
pure virtual

Return the value of the member variable of ib.

Implemented in ThePEG::Switch< T, Int >.

◆ options()

const OptionMap & ThePEG::SwitchBase::options ( ) const
inline

Return the map relating options to their values.

Definition at line 211 of file Switch.h.

References theOptions.

◆ registerOption()

void ThePEG::SwitchBase::registerOption ( const SwitchOption o)
inlineprotected

Register a new option.

Definition at line 229 of file Switch.h.

References ThePEG::Named::name(), theOptionNames, theOptions, and ThePEG::SwitchOption::value().

◆ set()

virtual void ThePEG::SwitchBase::set ( InterfacedBase ib,
long  val 
) const
pure virtual

Set the member variable of ib to val.

Implemented in ThePEG::Switch< T, Int >.

Referenced by setDef().

◆ setDef()

void ThePEG::SwitchBase::setDef ( InterfacedBase i) const
inline

Set the member variable of ib to its default value.

Definition at line 199 of file Switch.h.

References def(), and set().

◆ type()

virtual string ThePEG::SwitchBase::type ( ) const
virtual

Return a code for the type of this switch.

Implements ThePEG::InterfaceBase.

Friends And Related Function Documentation

◆ SwitchOption

friend class SwitchOption
friend

SwitchOption is a friend.

Definition at line 128 of file Switch.h.

Member Data Documentation

◆ theOptionNames

StringMap ThePEG::SwitchBase::theOptionNames
private

The map relating options to their names.

Definition at line 244 of file Switch.h.

Referenced by registerOption().

◆ theOptions

OptionMap ThePEG::SwitchBase::theOptions
private

The map relating options to their values.

Definition at line 239 of file Switch.h.

Referenced by check(), options(), and registerOption().


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