thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
InterfaceBase.h
1// -*- C++ -*-
2//
3// InterfaceBase.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_InterfaceBase_H
10#define ThePEG_InterfaceBase_H
11// This is the declaration of the InterfaceBase and RefInterfaceBase classes.
12
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
20namespace ThePEG {
21
59class InterfaceBase: public Named {
60
61public:
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
234private:
235
240
245
250 double theRank;
251
252protected:
253
258
263 mutable bool isDependencySafe;
264
269 mutable bool isReadOnly;
270
271
272};
273
274
281
282public:
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
386
392
393private:
394
400
404 const type_info & theRefTypeInfo;
405
411
417
423
424};
425
428inline double operator/(string,string) { return 0.0; }
429
432inline string operator*(double,string) { return ""; }
433
434}
435
436#endif /* ThePEG_InterfaceBaseH */
This is the main config header file for ThePEG.
The InterfaceBase class defines a generic interface to any class derived from the InterfacedBase clas...
Definition: InterfaceBase.h:59
void rank(double r)
Set the rank for this interface.
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.
double theRank
A rank assigned to this interface.
double rank() const
Get the rank for this interface.
InterfaceBase(string newName, string newDescription, string newClassName, const type_info &newTypeInfo, bool depSafe, bool readonly)
Standard constructor.
static bool NoReadOnly
If set to true, all read-only interfaces can be changed.
void setReadWrite()
Unset the flag saying that this interface is allowed to change an object.
virtual void rebind(InterfacedBase &, const TranslationMap &, const IVector &=IVector()) const
Rebind all references in ib according to the translation map.
virtual string exec(InterfacedBase &ib, string action, string arguments) const =0
Manipulate an object of the corresponding class.
string tag(int pos=-1) const
Create a tag for this interface using its name and optional poisitional argument.
map< string, string > & objectDefaults(InterfacedBase &) const
Returns the map of objectDefaults of the given object.
bool readOnly() const
Get the flag saying whether this interface is allowed to change an object.
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 dependen...
string description() const
Return the description of this interface.
virtual string fullDescription(const InterfacedBase &ib) const
Return a complete description of this interface.
void setReadOnly()
Set the flag saying that this interface is allowed to change an object.
virtual string type() const =0
Return a code for the type of this interface.
virtual void doxygenDescription(ostream &stream) const
Print a description to be included in the Doxygen documentation to the given stream.
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...
string theDescription
The description of this interface.
bool isDependencySafe
The flag saying whether changing an object with this interface may change the state of a dependent ob...
bool hasDefault
A flag indicating whether this interface has a default setting.
virtual IVector getReferences(const InterfacedBase &) const
For derived classes interfacing references between Interfaced objects, return the references for this...
virtual string doxygenType() const =0
Return a string describing the type of interface to be included in the Doxygen documentation.
void setHasDefault(bool b)
Indicate that this interface has a default value.
void setDependencySafe()
Set the flag saying whether changing an object with this interface may change the state of a dependen...
virtual ~InterfaceBase()
The destructor.
Definition: InterfaceBase.h:91
bool anonymous() const
Return true if this interface is anonyous, ie.
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class.
The Named class is a simple concrete base class to used by classes of objects with a name.
Definition: Named.h:24
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
RefInterfaceBase is an abstract base class inheriting from InterfaceBase used for subclasses dealing ...
void setNotNullable()
Set the flag saying that the interface it is not allowed to set the reference to null.
bool noRebind() const
Get the flag saying whether the interface is responsible for rebinding of the corresponding refenerce...
bool theDefaultIfNull
The flag saying wether a null pointer should be replaced by a default of suitable class when rebind i...
const type_info & refTypeInfo() const
Return the type_info object of the class referred to by this interface.
bool noNull() const
Get the flag saying whether the interface is allowed to set the reference to null.
bool defaultIfNull() const
Get the flag saying wether a null pointer should be replaced by a default of suitable class when rebi...
string theRefClassName
The class name of the class referred to by this interface.
void setRebind()
Set the flag saying that the interface is responsible for rebinding refenerces.
void setNullable()
Set the flag saying that the interface it is allowed to set the reference to null.
RefInterfaceBase(string newName, string newDescription, string newClassName, const type_info &newTypeInfo, string newRefClassName, const type_info &newRefTypeInfo, bool depSafe, bool readonly, bool norebind, bool nullable, bool defnull)
Standard constructor.
string refClassName() const
Return the class name of the class referred to by this interface.
void setDefaultIfNull()
Set the flag saying that a null pointer should be replaced by a default of suitable class when rebind...
bool isNullable
The flag saying whether the interface is allowed to set a reference to null.
void setNoDefaultIfNull()
Set the flag saying that a null pointer should not be replaced by a default of suitable class when re...
const type_info & theRefTypeInfo
The type_info object of the class referred to by this interface.
void setNoRebind()
Set the flag saying that the interface is not responsible for rebinding refenerces.
bool dontRebind
The flag saying whether the interface is responsible for rebinding refenerces.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
vector< IBPtr > IVector
A vector of pointers to InterfacedBase objects.
Definition: Containers.h:67