thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
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
14#include "InterfaceBase.h"
15#include "Command.fh"
16#include "Command.xh"
17
18namespace ThePEG {
19
54
55public:
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
144template <class T>
145class Command: public CommandBase {
146
147public:
148
153 typedef string (T::*ExeFn)(string);
154
155public:
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
185private:
186
191
192};
193
194}
195
196#ifndef ThePEG_TEMPLATES_IN_CC_FILE
197#include "Command.tcc"
198#endif
199
200#endif /* ThePEG_Command_H */
This is the main config header file for ThePEG.
The CommandBase and its templated Command sub-class defines an interface to a class derived from the ...
Definition: Command.h:53
virtual string cmd(InterfacedBase &ib, string c) const =0
Execute the member function.
virtual string doxygenType() const
Return a string describing the type of interface to be included in the Doxygen documentation.
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.
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:145
string(T::* ExeFn)(string)
The declaration of member functions which can be used by this Command interface.
Definition: Command.h:153
virtual string cmd(InterfacedBase &ib, string) const
Execute the member function.
ExeFn theExeFn
The pointer to the member function.
Definition: Command.h:190
Command(string newName, string newDescription, ExeFn newExeFn, bool depSafe=false)
Standard constructor.
Definition: Command.h:171
The InterfaceBase class defines a generic interface to any class derived from the InterfacedBase clas...
Definition: InterfaceBase.h:59
string className() const
Return the class name for the class this interface is defined for.
bool hasDefault
A flag indicating whether this interface has a default setting.
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134