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

ThePEG::SwitchBase ThePEG::InterfaceBase ThePEG::Named

List of all members.

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

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().


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


Constructor & Destructor Documentation

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:
newName the name of the interface, may only contain letters [a-zA-z0-9_].
newDescription a brief description of the interface.
newMember a pointer to the member variable. May be null if corresponding set/get functions are provided.
newDef the default value for the member variable.
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.
newSetFn optional pointer to the member function for the 'set' action.
newGetFn optional pointer to the member function for the 'get' action.
newDefFn optional pointer to the member function for the 'def' action.

Definition at line 318 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