00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_RefVector_H
00010 #define ThePEG_RefVector_H
00011
00012
00013 #include "ThePEG/Config/ThePEG.h"
00014 #include "InterfaceBase.h"
00015 #include "RefVector.xh"
00016 #include "RefVector.fh"
00017
00018 namespace ThePEG {
00019
00038 class RefVectorBase: public RefInterfaceBase {
00039
00040 public:
00041
00079 RefVectorBase(string newName, string newDescription,
00080 string newClassName,
00081 const type_info & newTypeInfo,
00082 string newRefClassName,
00083 const type_info & newRefTypeInfo,
00084 int newSize, bool depSafe,
00085 bool readonly, bool norebind, bool nullable, bool defnull);
00086
00095 virtual string exec(InterfacedBase & ib, string action,
00096 string arguments) const;
00097
00101 virtual string fullDescription(const InterfacedBase & ib) const;
00102
00106 virtual string type() const;
00107
00112 virtual string doxygenType() const;
00113
00118 virtual void set(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
00119 const = 0;
00120
00125 virtual void insert(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
00126 const = 0;
00127
00131 virtual void erase(InterfacedBase & ib, int i)
00132 const = 0;
00133
00138 virtual IVector get(const InterfacedBase & ib) const
00139 = 0;
00140
00145 virtual bool check(const InterfacedBase & ib, cIBPtr ip, int i) const
00146 = 0;
00147
00154 virtual void rebind(InterfacedBase & ib, const TranslationMap & trans,
00155 const IVector & defs) const;
00156
00160 virtual IVector getReferences(const InterfacedBase & ib) const;
00161
00166 int size() const { return theSize; }
00167
00172 void setSize(int sz) { theSize = sz; }
00173
00178 void setVariableSize() { theSize = 0; }
00179
00180 private:
00181
00185 int theSize;
00186
00187 };
00188
00189
00208 template <class T, class R>
00209 class RefVector: public RefVectorBase {
00210
00211 public:
00212
00214 typedef typename Ptr<R>::pointer RefPtr;
00216 typedef typename Ptr<R>::const_pointer cRefPtr;
00218 typedef void (T::*SetFn)(RefPtr, int);
00220 typedef void (T::*InsFn)(RefPtr, int);
00222 typedef void (T::*DelFn)(int);
00224 typedef bool (T::*CheckFn)(cRefPtr, int) const;
00226 typedef vector<RefPtr> (T::*GetFn)() const;
00231 typedef vector<RefPtr> T::* Member;
00232
00233 public:
00234
00277 RefVector(string newName, string newDescription,
00278 Member newMember, int newSize, bool depSafe = false,
00279 bool readonly = false, bool rebind = true, bool nullable = true,
00280 SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0,
00281 GetFn newGetFn = 0, CheckFn newCheckFn = 0);
00282
00329 RefVector(string newName, string newDescription,
00330 Member newMember, int newSize, bool depSafe,
00331 bool readonly, bool rebind, bool nullable, bool defnull,
00332 SetFn newSetFn = 0, InsFn newInsFn = 0, DelFn newDelFn = 0,
00333 GetFn newGetFn = 0, CheckFn newCheckFn = 0);
00334
00339 virtual void set(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
00340 const;
00341
00346 virtual void insert(InterfacedBase & ib, IBPtr ip, int i, bool chk = true)
00347 const;
00348
00352 virtual void erase(InterfacedBase & ib, int i)
00353 const;
00354
00359 virtual IVector get(const InterfacedBase & ib) const
00360 ;
00361
00366 virtual bool check(const InterfacedBase & ib, cIBPtr, int i) const
00367 ;
00368
00372 void setSetFunction(SetFn sf) { theSetFn = sf; }
00373
00377 void setInsertFunction(InsFn ifn) { theInsFn = ifn; }
00378
00382 void setGetFunction(GetFn gf) { theGetFn = gf; }
00383
00387 void setEraseFunction(DelFn df) { theDelFn = df; }
00388
00392 void setCheckFunction(CheckFn cf) { theCheckFn = cf; }
00393
00394 private:
00395
00399 Member theMember;
00400
00404 SetFn theSetFn;
00405
00409 InsFn theInsFn;
00410
00414 DelFn theDelFn;
00415
00419 GetFn theGetFn;
00420
00424 CheckFn theCheckFn;
00425
00426 };
00427
00428 }
00429
00430 #include "RefVector.tcc"
00431
00432 #endif