thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ThePEG::Switch< T, Int > Class Template 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::Switch< T, Int >:

Public Types

typedef void(T::* SetFn) (Int)
 The declaration of member functions which can be used by this Switch interface for the 'set' action.
 
typedef Int(T::* GetFn) () const
 The declaration of member functions which can be used by this Switch interface for the 'get' action.
 
typedef Int T::* Member
 Declaration of a direct pointer to the member variable.
 
- Public Types inherited from ThePEG::SwitchBase
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

 Switch (string newName, string newDescription, Member newMember, Int newDef, bool depSafe=false, bool readonly=false, SetFn newSetFn=0, GetFn newGetFn=0, GetFn newDefFn=0)
 Standard constructor.
 
virtual void set (InterfacedBase &ib, long val) const
 Set the member variable of ib to val.
 
virtual long get (const InterfacedBase &ib) const
 Return the value of the member variable of ib.
 
virtual long def (const InterfacedBase &ib) const
 Return the default value for the member variable of ib.
 
void setSetFunction (SetFn sf)
 Give a pointer to a member function to be used by 'set()'.
 
void setGetFunction (GetFn gf)
 Give a pointer to a member function to be used by 'get()'.
 
void setDefaultFunction (GetFn df)
 Give a pointer to a member function to be used by 'def()'.
 
virtual void doxygenDescription (ostream &stream) const
 Print a description to be included in the Doxygen documentation to the given stream.
 
- Public Member Functions inherited from ThePEG::SwitchBase
 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.
 

Private Attributes

Member theMember
 The pointer to the member variable.
 
Int theDef
 Default value to be used if no corresponding member function pointers are given.
 
SetFn theSetFn
 A pointer to a member function to be used by 'set()'.
 
GetFn theGetFn
 Pointer to member function to be used by get().
 
GetFn theDefFn
 Pointer to member function to be used by def().
 

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 Member Functions inherited from ThePEG::SwitchBase
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.
 
- 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

template<typename T, typename Int>
class ThePEG::Switch< T, Int >

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 (also enums and bool are allowed) 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 273 of file Switch.h.

Member Typedef Documentation

◆ GetFn

template<typename T , typename Int >
typedef Int(T::* ThePEG::Switch< T, Int >::GetFn) () const

The declaration of member functions which can be used by this Switch interface for the 'get' action.

Definition at line 286 of file Switch.h.

◆ Member

template<typename T , typename Int >
typedef Int T::* ThePEG::Switch< T, Int >::Member

Declaration of a direct pointer to the member variable.

Definition at line 291 of file Switch.h.

◆ SetFn

template<typename T , typename Int >
typedef void(T::* ThePEG::Switch< T, Int >::SetFn) (Int)

The declaration of member functions which can be used by this Switch interface for the 'set' action.

Definition at line 281 of file Switch.h.

Constructor & Destructor Documentation

◆ Switch()

template<typename T , typename Int >
ThePEG::Switch< T, Int >::Switch ( string  newName,
string  newDescription,
Member  newMember,
Int  newDef,
bool  depSafe = false,
bool  readonly = false,
SetFn  newSetFn = 0,
GetFn  newGetFn = 0,
GetFn  newDefFn = 0 
)
inline

Standard constructor.

Parameters
newNamethe name of the interface, may only contain letters [a-zA-z0-9_].
newDescriptiona brief description of the interface.
newMembera pointer to the member variable. May be null if corresponding set/get functions are provided.
newDefthe default value for the member variable.
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.
newSetFnoptional pointer to the member function for the 'set' action.
newGetFnoptional pointer to the member function for the 'get' action.
newDefFnoptional pointer to the member function for the 'def' action.

Definition at line 324 of file Switch.h.

Member Function Documentation

◆ def()

template<typename T , typename Int >
virtual long ThePEG::Switch< T, Int >::def ( const InterfacedBase ib) const
virtual

Return the default value for the member variable of ib.

Implements ThePEG::SwitchBase.

◆ doxygenDescription()

template<typename T , typename Int >
virtual void ThePEG::Switch< T, Int >::doxygenDescription ( ostream &  stream) const
virtual

Print a description to be included in the Doxygen documentation to the given stream.

Reimplemented from ThePEG::InterfaceBase.

◆ get()

template<typename T , typename Int >
virtual long ThePEG::Switch< T, Int >::get ( const InterfacedBase ib) const
virtual

Return the value of the member variable of ib.

Implements ThePEG::SwitchBase.

◆ set()

template<typename T , typename Int >
virtual void ThePEG::Switch< T, Int >::set ( InterfacedBase ib,
long  val 
) const
virtual

Set the member variable of ib to val.

Implements ThePEG::SwitchBase.

◆ setDefaultFunction()

template<typename T , typename Int >
void ThePEG::Switch< T, Int >::setDefaultFunction ( GetFn  df)
inline

Give a pointer to a member function to be used by 'def()'.

Definition at line 362 of file Switch.h.

References ThePEG::Switch< T, Int >::theDefFn.

◆ setGetFunction()

template<typename T , typename Int >
void ThePEG::Switch< T, Int >::setGetFunction ( GetFn  gf)
inline

Give a pointer to a member function to be used by 'get()'.

Definition at line 357 of file Switch.h.

References ThePEG::Switch< T, Int >::theGetFn.

◆ setSetFunction()

template<typename T , typename Int >
void ThePEG::Switch< T, Int >::setSetFunction ( SetFn  sf)
inline

Give a pointer to a member function to be used by 'set()'.

Definition at line 352 of file Switch.h.

References ThePEG::Switch< T, Int >::theSetFn.

Member Data Documentation

◆ theDef

template<typename T , typename Int >
Int ThePEG::Switch< T, Int >::theDef
private

Default value to be used if no corresponding member function pointers are given.

Definition at line 381 of file Switch.h.

◆ theDefFn

template<typename T , typename Int >
GetFn ThePEG::Switch< T, Int >::theDefFn
private

Pointer to member function to be used by def().

Definition at line 396 of file Switch.h.

Referenced by ThePEG::Switch< T, Int >::setDefaultFunction().

◆ theGetFn

template<typename T , typename Int >
GetFn ThePEG::Switch< T, Int >::theGetFn
private

Pointer to member function to be used by get().

Definition at line 391 of file Switch.h.

Referenced by ThePEG::Switch< T, Int >::setGetFunction().

◆ theMember

template<typename T , typename Int >
Member ThePEG::Switch< T, Int >::theMember
private

The pointer to the member variable.

Definition at line 375 of file Switch.h.

◆ theSetFn

template<typename T , typename Int >
SetFn ThePEG::Switch< T, Int >::theSetFn
private

A pointer to a member function to be used by 'set()'.

Definition at line 386 of file Switch.h.

Referenced by ThePEG::Switch< T, Int >::setSetFunction().


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