thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ThePEG::Command< T > Class Template Reference

The CommandBase and its templated Command sub-class defines an interface to a class derived from the InterfacedBase, through which arbitratry command strings can be sent and received. More...

#include <Command.h>

Inheritance diagram for ThePEG::Command< T >:

Public Types

typedef string(T::* ExeFn) (string)
 The declaration of member functions which can be used by this Command interface.
 

Public Member Functions

 Command (string newName, string newDescription, ExeFn newExeFn, bool depSafe=false)
 Standard constructor.
 
virtual string cmd (InterfacedBase &ib, string) const
 Execute the member function.
 
- Public Member Functions inherited from ThePEG::CommandBase
 CommandBase (string newName, string newDescription, string newClassName, const type_info &newTypeInfo, bool depSafe)
 Standard constructor.
 
virtual string exec (InterfacedBase &ib, string action, string arguments) const
 The general interface method overriding the one in InterfaceBase.
 
virtual string doxygenType () const
 Return a string describing the type of interface to be included in the Doxygen documentation.
 
virtual string type () const
 Return a code for the type of this interface.
 
virtual string cmd (InterfacedBase &ib, string c) const =0
 Execute the member function.
 
- 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

ExeFn theExeFn
 The pointer to the member function.
 

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::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<class T>
class ThePEG::Command< T >

The CommandBase and its templated Command sub-class defines an interface to a class derived from the InterfacedBase, through which arbitratry command strings can be sent and received.

Command is templated and is derived from the InterfaceBase class via CommandBase.

For each command interface to be defined for a class T, exactly one static object of the Command<T> must be created and initialized as follows:

Command<T> comint(name, description, &T::memberfn, depsafe);

Where name is an identifier std::string which should only contain letters [a-zA-z0-9_], description is an arbitrary std::string, memberfn should be a non-static member function of T and defined as std::string T::memberfn(std::string). Finally if depsafe is true it can be assumed that a call to the memberfn for an object does not influence other objects which may depend on the first.

The Command class, as all other InterfaceBase classes are mainly used in the BaseRepository class.

See also
InterfacedBase
InterfaceBase
BaseRepository

Definition at line 145 of file Command.h.

Member Typedef Documentation

◆ ExeFn

template<class T >
typedef string(T::* ThePEG::Command< T >::ExeFn) (string)

The declaration of member functions which can be used by this Command interface.

Definition at line 153 of file Command.h.

Constructor & Destructor Documentation

◆ Command()

template<class T >
ThePEG::Command< T >::Command ( string  newName,
string  newDescription,
ExeFn  newExeFn,
bool  depSafe = false 
)
inline

Standard constructor.

Parameters
newNamethe name of the interface, may only contain letters [a-zA-z0-9_].
newDescriptiona brief description of the interface.
newExeFnpointer to the function to be called in the corresponding class.
depSafeset to true if calls to this interface for one object does not influence other objects.

Definition at line 171 of file Command.h.

Member Function Documentation

◆ cmd()

template<class T >
virtual string ThePEG::Command< T >::cmd ( InterfacedBase ib,
string   
) const
virtual

Execute the member function.

For the object ib execute the memberfunction with c as argument and return the return value.

Implements ThePEG::CommandBase.

Member Data Documentation

◆ theExeFn

template<class T >
ExeFn ThePEG::Command< T >::theExeFn
private

The pointer to the member function.

Definition at line 190 of file Command.h.


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