thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
Command.h
1 // -*- C++ -*-
2 //
3 // Command.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_Command_H
10 #define ThePEG_Command_H
11 // This is the declaration of the Command and CommandBase classes.
12 
13 #include "ThePEG/Config/ThePEG.h"
14 #include "InterfaceBase.h"
15 #include "Command.fh"
16 #include "Command.xh"
17 
18 namespace ThePEG {
19 
53 class CommandBase: public InterfaceBase {
54 
55 public:
56 
73  CommandBase(string newName, string newDescription, string newClassName,
74  const type_info & newTypeInfo, bool depSafe)
75  : InterfaceBase(newName, newDescription, newClassName,
76  newTypeInfo, depSafe, false) {
77  hasDefault = false;
78  }
79 
86  virtual string
87  exec(InterfacedBase &ib, string action, string arguments) const
88  ;
89 
94  virtual string doxygenType() const;
95 
99  virtual string type() const;
100 
106  virtual string cmd(InterfacedBase & ib, string c) const
107  = 0;
108 
109 };
110 
144 template <class T>
145 class Command: public CommandBase {
146 
147 public:
148 
153  typedef string (T::*ExeFn)(string);
154 
155 public:
156 
171  Command(string newName, string newDescription,
172  ExeFn newExeFn, bool depSafe = false)
173  : CommandBase(newName, newDescription,
174  ClassTraits<T>::className(), typeid(T), depSafe),
175  theExeFn(newExeFn) {}
176 
181  virtual string cmd(InterfacedBase & ib, string)
182  const;
183 
184 
185 private:
186 
190  ExeFn theExeFn;
191 
192 };
193 
194 }
195 
196 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
197 #include "Command.tcc"
198 #endif
199 
200 #endif /* ThePEG_Command_H */
Command(string newName, string newDescription, ExeFn newExeFn, bool depSafe=false)
Standard constructor.
Definition: Command.h:171
virtual string doxygenType() const
Return a string describing the type of interface to be included in the Doxygen documentation.
The InterfaceBase class defines a generic interface to any class derived from the InterfacedBase clas...
Definition: InterfaceBase.h:59
bool hasDefault
A flag indicating whether this interface has a default setting.
CommandBase(string newName, string newDescription, string newClassName, const type_info &newTypeInfo, bool depSafe)
Standard constructor.
Definition: Command.h:73
The CommandBase and its templated Command sub-class defines an interface to a class derived from the ...
Definition: Command.h:53
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
This is the main config header file for ThePEG.
virtual string exec(InterfacedBase &ib, string action, string arguments) const
The general interface method overriding the one in InterfaceBase.
virtual string type() const
Return a code for the type of this interface.
The CommandBase and its templated Command sub-class defines an interface to a class derived from the ...
Definition: Command.h:145
ExeFn theExeFn
The pointer to the member function.
Definition: Command.h:190
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class...
virtual string cmd(InterfacedBase &ib, string c) const =0
Execute the member function.
string className() const
Return the class name for the class this interface is defined for.
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134