thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.1.5
InterfaceBase.h
1 // -*- C++ -*-
2 //
3 // InterfaceBase.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2017 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_InterfaceBase_H
10 #define ThePEG_InterfaceBase_H
11 // This is the declaration of the InterfaceBase and RefInterfaceBase classes.
12 
13 #include "ThePEG/Config/ThePEG.h"
14 #include "InterfaceBase.fh"
15 #include "InterfaceBase.xh"
16 #include "ThePEG/Utilities/Named.h"
17 #include "ThePEG/Utilities/ClassTraits.h"
18 #include "Interface.h"
19 
20 namespace ThePEG {
21 
59 class InterfaceBase: public Named {
60 
61 public:
62 
83  InterfaceBase(string newName, string newDescription,
84  string newClassName,
85  const type_info & newTypeInfo, bool depSafe,
86  bool readonly);
87 
91  virtual ~InterfaceBase() {}
92 
97  string tag(int pos = -1) const;
98 
104  virtual string
105  exec(InterfacedBase & ib, string action, string arguments) const
106  = 0;
107 
111  virtual string type() const = 0;
112 
117  virtual bool notDefault(InterfacedBase &) const;
118 
122  map<string,string> & objectDefaults(InterfacedBase &) const;
123 
128  virtual void rebind(InterfacedBase &,
129  const TranslationMap &,
130  const IVector & = IVector()) const {}
131 
136  virtual IVector getReferences(const InterfacedBase &) const {
137  return IVector();
138  }
139 
143  string description() const { return theDescription; }
144 
148  virtual string fullDescription(const InterfacedBase & ib) const;
149 
154  virtual void doxygenDescription(ostream & stream) const;
155 
160  virtual string doxygenType() const = 0;
161 
166  string className() const { return theClassName; }
167 
172  bool dependencySafe() const { return isDependencySafe; }
173 
179 
185 
190  bool readOnly() const { return isReadOnly && (!NoReadOnly); }
191 
196  void setReadOnly() { isReadOnly = true; }
197 
202  void setReadWrite() { isReadOnly = false; }
203 
208  bool anonymous() const { return description().empty(); }
209 
214  double rank() const { return theRank; }
215 
220  void rank(double r) { theRank = r; }
221 
225  void setHasDefault(bool b) {
226  hasDefault = b;
227  }
228 
232  static bool NoReadOnly;
233 
234 private:
235 
240 
244  string theClassName;
245 
250  double theRank;
251 
252 protected:
253 
258 
263  mutable bool isDependencySafe;
264 
269  mutable bool isReadOnly;
270 
271 
272 };
273 
274 
281 
282 public:
283 
320  RefInterfaceBase(string newName, string newDescription,
321  string newClassName, const type_info & newTypeInfo,
322  string newRefClassName,
323  const type_info & newRefTypeInfo,
324  bool depSafe, bool readonly,
325  bool norebind, bool nullable, bool defnull);
326 
331  string refClassName() const { return theRefClassName; }
332 
337  const type_info & refTypeInfo() const { return theRefTypeInfo; }
338 
343  bool noRebind() const { return dontRebind; }
344 
349  void setNoRebind() { dontRebind = true; }
350 
355  void setRebind() { dontRebind = false; }
356 
361  bool noNull() const { return !isNullable; }
362 
367  void setNullable() { isNullable = true; }
368 
373  void setNotNullable() { isNullable = false; }
374 
379  bool defaultIfNull() const { return theDefaultIfNull; }
380 
385  void setDefaultIfNull() { theDefaultIfNull = true; }
386 
391  void setNoDefaultIfNull() { theDefaultIfNull = false; }
392 
393 private:
394 
400 
404  const type_info & theRefTypeInfo;
405 
411 
417 
423 
424 };
425 
428 inline double operator/(string,string) { return 0.0; }
429 
432 inline string operator*(double,string) { return ""; }
433 
434 }
435 
436 #endif /* ThePEG_InterfaceBaseH */
virtual void rebind(InterfacedBase &, const TranslationMap &, const IVector &=IVector()) const
Rebind all references in ib according to the translation map.
void setDependencySafe()
Set the flag saying whether changing an object with this interface may change the state of a dependen...
void setNotNullable()
Set the flag saying that the interface it is not allowed to set the reference to null.
bool isDependencySafe
The flag saying whether changing an object with this interface may change the state of a dependent ob...
void setDefaultIfNull()
Set the flag saying that a null pointer should be replaced by a default of suitable class when rebind...
void setNullable()
Set the flag saying that the interface it is allowed to set the reference to null.
virtual string doxygenType() const =0
Return a string describing the type of interface to be included in the Doxygen documentation.
bool dependencySafe() const
Get the flag saying whether changing an object with this interface may change the state of a dependen...
virtual string type() const =0
Return a code for the type of this interface.
bool noNull() const
Get the flag saying whether the interface is allowed to set the reference to null.
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.
string theRefClassName
The class name of the class referred to by this interface.
void setReadWrite()
Unset the flag saying that this interface is allowed to change an object.
virtual IVector getReferences(const InterfacedBase &) const
For derived classes interfacing references between Interfaced objects, return the references for this...
bool theDefaultIfNull
The flag saying wether a null pointer should be replaced by a default of suitable class when rebind i...
bool anonymous() const
Return true if this interface is anonyous, ie.
void setNoDefaultIfNull()
Set the flag saying that a null pointer should not be replaced by a default of suitable class when re...
virtual string fullDescription(const InterfacedBase &ib) const
Return a complete description of this interface.
bool isNullable
The flag saying whether the interface is allowed to set a reference to null.
bool dontRebind
The flag saying whether the interface is responsible for rebinding refenerces.
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
InterfaceBase(string newName, string newDescription, string newClassName, const type_info &newTypeInfo, bool depSafe, bool readonly)
Standard constructor.
virtual ~InterfaceBase()
The destructor.
Definition: InterfaceBase.h:91
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
The Named class is a simple concrete base class to used by classes of objects with a name...
Definition: Named.h:24
This is the main config header file for ThePEG.
virtual void doxygenDescription(ostream &stream) const
Print a description to be included in the Doxygen documentation to the given stream.
double theRank
A rank assigned to this interface.
bool isReadOnly
The flag saying whether this interface is allowed to change an object.
void setDependencySensitive()
Set the flag saying whether changing an object with this interface may change the state of a dependen...
virtual string exec(InterfacedBase &ib, string action, string arguments) const =0
Manipulate an object of the corresponding class.
string theDescription
The description of this interface.
void setRebind()
Set the flag saying that the interface is responsible for rebinding refenerces.
void setReadOnly()
Set the flag saying that this interface is allowed to change an object.
double rank() const
Get the rank for this interface.
string tag(int pos=-1) const
Create a tag for this interface using its name and optional poisitional argument. ...
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class...
RefInterfaceBase is an abstract base class inheriting from InterfaceBase used for subclasses dealing ...
static bool NoReadOnly
If set to true, all read-only interfaces can be changed.
bool readOnly() const
Get the flag saying whether this interface is allowed to change an object.
void setNoRebind()
Set the flag saying that the interface is not responsible for rebinding refenerces.
string theClassName
The class name and for the class this interface is defined for.
virtual bool notDefault(InterfacedBase &) const
Returns true if the setting for this interface has been changed from its default value.
string className() const
Return the class name for the class this interface is defined for.
const type_info & theRefTypeInfo
The type_info object of the class referred to by this interface.
string description() const
Return the description of this interface.
string refClassName() const
Return the class name of the class referred to by this interface.
const type_info & refTypeInfo() const
Return the type_info object of the class referred to by this interface.
bool noRebind() const
Get the flag saying whether the interface is responsible for rebinding of the corresponding refenerce...
void setHasDefault(bool b)
Indicate that this interface has a default value.
vector< IBPtr > IVector
A vector of pointers to InterfacedBase objects.
Definition: Containers.h:67
bool defaultIfNull() const
Get the flag saying wether a null pointer should be replaced by a default of suitable class when rebi...
map< string, string > & objectDefaults(InterfacedBase &) const
Returns the map of objectDefaults of the given object.
void rank(double r)
Set the rank for this interface.