thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
RefVector.h
1// -*- C++ -*-
2//
3// RefVector.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_RefVector_H
10#define ThePEG_RefVector_H
11// This is the declaration of the RefVector and RefVectorBase classes.
12
14#include "InterfaceBase.h"
15#include "RefVector.xh"
16#include "RefVector.fh"
17
18namespace ThePEG {
19
39
40public:
41
79 RefVectorBase(string newName, string newDescription,
80 string newClassName,
81 const type_info & newTypeInfo,
82 string newRefClassName,
83 const type_info & newRefTypeInfo,
84 int newSize, bool depSafe,
85 bool readonly, bool norebind, bool nullable, bool defnull);
86
95 virtual string exec(InterfacedBase & ib, string action,
96 string arguments) const;
97
101 virtual string fullDescription(const InterfacedBase & ib) const;
102
106 virtual string type() const;
107
112 virtual string doxygenType() const;
113
118 virtual void set(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
119 const = 0;
120
125 virtual void insert(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
126 const = 0;
127
131 virtual void erase(InterfacedBase & ib, int i)
132 const = 0;
133
137 virtual void clear(InterfacedBase & ib)
138 const = 0;
139
144 virtual IVector get(const InterfacedBase & ib) const
145 = 0;
146
151 virtual bool check(const InterfacedBase & ib, cIBPtr ip, int i) const
152 = 0;
153
160 virtual void rebind(InterfacedBase & ib, const TranslationMap & trans,
161 const IVector & defs) const;
162
166 virtual IVector getReferences(const InterfacedBase & ib) const;
167
172 int size() const { return theSize; }
173
178 void setSize(int sz) { theSize = sz; }
179
184 void setVariableSize() { theSize = 0; }
185
186private:
187
192
193};
194
195
214template <class T, class R>
216
217public:
218
220 typedef typename Ptr<R>::pointer RefPtr;
224 typedef void (T::*SetFn)(RefPtr, int);
226 typedef void (T::*InsFn)(RefPtr, int);
228 typedef void (T::*DelFn)(int);
230 typedef bool (T::*CheckFn)(cRefPtr, int) const;
232 typedef vector<RefPtr> (T::*GetFn)() const;
237 typedef vector<RefPtr> T::* Member;
238
239public:
240
283 RefVector(string newName, string newDescription,
284 Member newMember, int newSize, bool depSafe = false,
285 bool readonly = false, bool rebind = true, bool nullable = true,
286 SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0,
287 GetFn newGetFn = 0, CheckFn newCheckFn = 0);
288
335 RefVector(string newName, string newDescription,
336 Member newMember, int newSize, bool depSafe,
337 bool readonly, bool rebind, bool nullable, bool defnull,
338 SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0,
339 GetFn newGetFn = 0, CheckFn newCheckFn = 0);
340
345 virtual void set(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
346 const;
347
352 virtual void insert(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
353 const;
354
358 virtual void erase(InterfacedBase & ib, int i)
359 const;
360
364 virtual void clear(InterfacedBase & ib)
365 const;
366
371 virtual IVector get(const InterfacedBase & ib) const
372 ;
373
378 virtual bool check(const InterfacedBase & ib, cIBPtr, int i) const
379 ;
380
384 void setSetFunction(SetFn sf) { theSetFn = sf; }
385
389 void setInsertFunction(InsFn ifn) { theInsFn = ifn; }
390
394 void setGetFunction(GetFn gf) { theGetFn = gf; }
395
399 void setEraseFunction(DelFn df) { theDelFn = df; }
400
405
406private:
407
412
417
422
427
432
437
438};
439
440}
441
442#include "RefVector.tcc"
443
444#endif /* ThePEG_RefVector_H */
This is the main config header file for ThePEG.
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 RefVector and its base class RefVectorBase defines an interface to a class derived from the Inter...
Definition: RefVector.h:38
virtual void erase(InterfacedBase &ib, int i) const =0
Remove the i'th element of a container of pointers of ib.
virtual string exec(InterfacedBase &ib, string action, string arguments) const
The general interface method overriding the one in InterfaceBase.
virtual void set(InterfacedBase &ib, IBPtr ip, int i, bool chk=true) const =0
Set the i'th element of a container of pointers of ib to ip.
void setVariableSize()
Set the size of the container being interfaced to -1, i.e.
Definition: RefVector.h:184
int theSize
The size of the container being interfaced.
Definition: RefVector.h:191
virtual IVector get(const InterfacedBase &ib) const =0
Return a vector of pointers corresponding to the container of pointers of ib.
virtual void insert(InterfacedBase &ib, IBPtr ip, int i, bool chk=true) const =0
Insert a new pointer before the i'th element of a container of pointers of ib and set it to ip.
int size() const
Get the size of the container being interfaced.
Definition: RefVector.h:172
void setSize(int sz)
Set the size of the container being interfaced.
Definition: RefVector.h:178
virtual void rebind(InterfacedBase &ib, const TranslationMap &trans, const IVector &defs) const
In the object ib, replace all pointers to objects in this interface with the translated ones provided...
virtual bool check(const InterfacedBase &ib, cIBPtr ip, int i) const =0
Check if set(ib, ip, i) will be successfull but do not do anything.
virtual void clear(InterfacedBase &ib) const =0
Clear the container of pointers of ib.
RefVectorBase(string newName, string newDescription, string newClassName, const type_info &newTypeInfo, string newRefClassName, const type_info &newRefTypeInfo, int newSize, 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 IVector getReferences(const InterfacedBase &ib) const
Return pointers to other objects in ib.
virtual string fullDescription(const InterfacedBase &ib) const
Return a complete description of this reference vector.
virtual string type() const
Return a code for the type of this reference.
The RefVector and its base class RefVectorBase defines an interface to a class derived from the Inter...
Definition: RefVector.h:215
CheckFn theCheckFn
Give a pointer to a member function to be used by 'check()'.
Definition: RefVector.h:436
bool(T::* CheckFn)(cRefPtr, int) const
A pointer to a menberfunction to be used for the 'check' action.
Definition: RefVector.h:230
virtual void insert(InterfacedBase &ib, IBPtr ip, int i, bool chk=true) const
Insert a new pointer before the i'th element of a container of pointers of ib and set it to ip.
Ptr< R >::pointer RefPtr
A pointer to the class of objects referred to.
Definition: RefVector.h:220
void setGetFunction(GetFn gf)
Give a pointer to a member function to be used by 'get()'.
Definition: RefVector.h:394
InsFn theInsFn
Give a pointer to a member function to be used by 'insert()'.
Definition: RefVector.h:421
virtual bool check(const InterfacedBase &ib, cIBPtr, int i) const
Check if set(ib, ip, i) will be successfull but do not do anything.
Ptr< R >::const_pointer cRefPtr
A const pointer to the class of objects referred to.
Definition: RefVector.h:222
RefVector(string newName, string newDescription, Member newMember, int newSize, bool depSafe=false, bool readonly=false, bool rebind=true, bool nullable=true, SetFn newSetFn=0, InsFn newInsFn=0, DelFn newDelFn=0, GetFn newGetFn=0, CheckFn newCheckFn=0)
Standard constructor.
void(T::* DelFn)(int)
A pointer to a menberfunction to be used for the 'erase' action.
Definition: RefVector.h:228
SetFn theSetFn
A pointer to a member function to be used by 'set()'.
Definition: RefVector.h:416
RefVector(string newName, string newDescription, Member newMember, int newSize, bool depSafe, bool readonly, bool rebind, bool nullable, bool defnull, SetFn newSetFn=0, InsFn newInsFn=0, DelFn newDelFn=0, GetFn newGetFn=0, CheckFn newCheckFn=0)
Standard constructor.
vector< RefPtr > T::* Member
Declaration of a direct pointer to the member variable in case it is a vector.
Definition: RefVector.h:237
vector< RefPtr >(T::* GetFn)() const
A pointer to a menberfunction to be used for the 'get' action.
Definition: RefVector.h:232
DelFn theDelFn
Give a pointer to a member function to be used by 'erase()'.
Definition: RefVector.h:426
virtual void clear(InterfacedBase &ib) const
Clear the container of pointers of ib.
GetFn theGetFn
Give a pointer to a member function to be used by 'get()'.
Definition: RefVector.h:431
void(T::* InsFn)(RefPtr, int)
A pointer to a menberfunction to be used for the 'insert' action.
Definition: RefVector.h:226
void setInsertFunction(InsFn ifn)
Give a pointer to a member function to be used by 'insert()'.
Definition: RefVector.h:389
void setSetFunction(SetFn sf)
Give a pointer to a member function to be used by 'set()'.
Definition: RefVector.h:384
virtual void erase(InterfacedBase &ib, int i) const
Remove the i'th element of a container of pointers of ib.
void setEraseFunction(DelFn df)
Give a pointer to a member function to be used by 'erase()'.
Definition: RefVector.h:399
virtual void set(InterfacedBase &ib, IBPtr ip, int i, bool chk=true) const
Set the i'th element of a container of pointers of ib to ip.
void(T::* SetFn)(RefPtr, int)
A pointer to a menberfunction to be used for the 'set' action.
Definition: RefVector.h:224
Member theMember
The pointer to the member variable.
Definition: RefVector.h:411
void setCheckFunction(CheckFn cf)
Give a pointer to a member function to be used by 'check()'.
Definition: RefVector.h:404
virtual IVector get(const InterfacedBase &ib) const
Return a vector of pointers corresponding to the container of pointers of ib.
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