ThePEG  1.8.0
Command.h
1 // -*- C++ -*-
2 //
3 // Command.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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 
191 
192 };
193 
194 }
195 
196 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
197 #include "Command.tcc"
198 #endif
199 
200 #endif /* ThePEG_Command_H */