thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
Reference.h
1// -*- C++ -*-
2//
3// Reference.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_Reference_H
10#define ThePEG_Reference_H
11// This is the declaration of the Reference and ReferenceBase classes.
12
14#include "InterfaceBase.h"
15#include "Reference.xh"
16#include "Reference.fh"
17
18namespace ThePEG {
19
38
39public:
40
76 ReferenceBase(string newName, string newDescription,
77 string newClassName,
78 const type_info & newTypeInfo,
79 string newRefClassName,
80 const type_info & newRefTypeInfo, bool depSafe,
81 bool readonly, bool norebind, bool nullable, bool defnull);
82
89 virtual string exec(InterfacedBase & ib, string action,
90 string arguments) const;
91
95 virtual string fullDescription(const InterfacedBase & ib) const;
96
100 virtual string type() const;
101
106 virtual string doxygenType() const;
107
111 virtual void set(InterfacedBase & ib, IBPtr ip, bool chk = true)
112 const = 0;
113
117 virtual IBPtr get(const InterfacedBase & ib)
118 const = 0;
119
124 virtual bool check(const InterfacedBase & ib, cIBPtr ip) const
125 = 0;
126
133 virtual void rebind(InterfacedBase & ib, const TranslationMap & trans,
134 const IVector & defs) const;
135
139 virtual IVector getReferences(const InterfacedBase & ib) const;
140
141};
142
143
161template <class T, class R>
163
164public:
165
167 typedef typename Ptr<R>::pointer RefPtr;
171 typedef void (T::*SetFn)(RefPtr);
173 typedef bool (T::*CheckFn)(cRefPtr) const;
175 typedef RefPtr (T::*GetFn)() const;
177 typedef RefPtr T::* Member;
178
179public:
180
215 Reference(string newName, string newDescription,
216 Member newMember, bool depSafe = false,
217 bool readonly = false, bool rebind = true, bool nullable = true,
218 SetFn newSetFn = 0, GetFn newGetFn = 0,
219 CheckFn newCheckFn = 0)
220 : ReferenceBase(newName, newDescription,
221 ClassTraits<T>::className(), typeid(T),
222 ClassTraits<R>::className(), typeid(R),
223 depSafe, readonly, !rebind, nullable, false),
224 theMember(newMember), theSetFn(newSetFn), theGetFn(newGetFn),
225 theCheckFn(newCheckFn) {}
226
265 Reference(string newName, string newDescription,
266 Member newMember, bool depSafe, bool readonly, bool rebind,
267 bool nullable, bool defnull, SetFn newSetFn = 0, GetFn newGetFn = 0,
268 CheckFn newCheckFn = 0)
269 : ReferenceBase(newName, newDescription,
270 ClassTraits<T>::className(), typeid(T),
271 ClassTraits<R>::className(), typeid(R),
272 depSafe, readonly, !rebind, nullable, defnull),
273 theMember(newMember), theSetFn(newSetFn), theGetFn(newGetFn),
274 theCheckFn(newCheckFn) {}
275
276
280 virtual void set(InterfacedBase & ib, IBPtr ip, bool chk = true) const
281 ;
282
286 virtual IBPtr get(const InterfacedBase & ib) const
287 ;
288
293 virtual bool check(const InterfacedBase & ib, cIBPtr newRef) const
294 ;
295
299 void setSetFunction(SetFn sf) { theSetFn = sf; }
300
304 void setGetFunction(GetFn gf) { theGetFn = gf; }
305
310
311private:
312
317
322
327
332
333
334};
335
336}
337
338#include "Reference.tcc"
339
340#endif /* ThePEG_Reference_H */
This is the main config header file for ThePEG.
string className() const
Return the class name for the class this interface is defined for.
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class.
ConstRCPtr is a reference counted (smart) const pointer.
Definition: RCPtr.h:320
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
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 ...
The Reference class and its base class ReferenceBase defines an interface to a class derived from the...
Definition: Reference.h:37
virtual bool check(const InterfacedBase &ib, cIBPtr ip) const =0
Check if set(ib, ip) will be successfull but do not do anything.
virtual IVector getReferences(const InterfacedBase &ib) const
Return the pointer to another object in ib (in a vector).
virtual IBPtr get(const InterfacedBase &ib) const =0
Return the pointer of ib.
ReferenceBase(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.
virtual string doxygenType() const
Return a string describing the type of interface to be included in the Doxygen documentation.
virtual void rebind(InterfacedBase &ib, const TranslationMap &trans, const IVector &defs) const
In the object ib, replace the pointer in this interface with one of the translated ones provided by t...
virtual string fullDescription(const InterfacedBase &ib) const
Return a complete description of this reference.
virtual string type() const
Return a code for the type of this reference.
virtual void set(InterfacedBase &ib, IBPtr ip, bool chk=true) const =0
Set the pointer of ib to ip.
virtual string exec(InterfacedBase &ib, string action, string arguments) const
The general interface method overriding the one in InterfaceBase.
The Reference and its base class ReferenceBase defines an interface to a class derived from the Inter...
Definition: Reference.h:162
SetFn theSetFn
A pointer to a member function to be used by 'set()'.
Definition: Reference.h:321
Reference(string newName, string newDescription, Member newMember, bool depSafe=false, bool readonly=false, bool rebind=true, bool nullable=true, SetFn newSetFn=0, GetFn newGetFn=0, CheckFn newCheckFn=0)
Standard constructor.
Definition: Reference.h:215
RefPtr(T::* GetFn)() const
A pointer to a menberfunction to be used for the 'get' action.
Definition: Reference.h:175
void(T::* SetFn)(RefPtr)
A pointer to a menberfunction to be used for the 'set' action.
Definition: Reference.h:171
void setGetFunction(GetFn gf)
Give a pointer to a member function to be used by 'get()'.
Definition: Reference.h:304
Ptr< R >::const_pointer cRefPtr
A const pointer to the class of objects referred to.
Definition: Reference.h:169
Member theMember
The pointer to the member variable.
Definition: Reference.h:316
virtual void set(InterfacedBase &ib, IBPtr ip, bool chk=true) const
Set the pointer of ib to ip.
bool(T::* CheckFn)(cRefPtr) const
A pointer to a menberfunction to be used for the 'check' action.
Definition: Reference.h:173
CheckFn theCheckFn
Give a pointer to a member function to be used by 'check()'.
Definition: Reference.h:331
GetFn theGetFn
Give a pointer to a member function to be used by 'get()'.
Definition: Reference.h:326
void setSetFunction(SetFn sf)
Give a pointer to a member function to be used by 'set()'.
Definition: Reference.h:299
Ptr< R >::pointer RefPtr
A pointer to the class of objects referred to.
Definition: Reference.h:167
virtual bool check(const InterfacedBase &ib, cIBPtr newRef) const
Check if set(ib, ip) will be successfull but do not do anything.
virtual IBPtr get(const InterfacedBase &ib) const
Return the pointer of ib.
RefPtr T::* Member
Declaration of a direct pointer to the member variable.
Definition: Reference.h:177
Reference(string newName, string newDescription, Member newMember, bool depSafe, bool readonly, bool rebind, bool nullable, bool defnull, SetFn newSetFn=0, GetFn newGetFn=0, CheckFn newCheckFn=0)
Standard constructor.
Definition: Reference.h:265
void setCheckFunction(CheckFn cf)
Give a pointer to a member function to be used by 'check()'.
Definition: Reference.h:309
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
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134