00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_Reference_H
00010 #define ThePEG_Reference_H
00011
00012
00013 #include "ThePEG/Config/ThePEG.h"
00014 #include "InterfaceBase.h"
00015 #include "Reference.xh"
00016 #include "Reference.fh"
00017
00018 namespace ThePEG {
00019
00037 class ReferenceBase: public RefInterfaceBase {
00038
00039 public:
00040
00076 ReferenceBase(string newName, string newDescription,
00077 string newClassName,
00078 const type_info & newTypeInfo,
00079 string newRefClassName,
00080 const type_info & newRefTypeInfo, bool depSafe,
00081 bool readonly, bool norebind, bool nullable, bool defnull);
00082
00089 virtual string exec(InterfacedBase & ib, string action,
00090 string arguments) const;
00091
00095 virtual string fullDescription(const InterfacedBase & ib) const;
00096
00100 virtual string type() const;
00101
00106 virtual string doxygenType() const;
00107
00111 virtual void set(InterfacedBase & ib, IBPtr ip, bool chk = true)
00112 const = 0;
00113
00117 virtual IBPtr get(const InterfacedBase & ib)
00118 const = 0;
00119
00124 virtual bool check(const InterfacedBase & ib, cIBPtr ip) const
00125 = 0;
00126
00133 virtual void rebind(InterfacedBase & ib, const TranslationMap & trans,
00134 const IVector & defs) const;
00135
00139 virtual IVector getReferences(const InterfacedBase & ib) const;
00140
00141 };
00142
00143
00161 template <class T, class R>
00162 class Reference: public ReferenceBase {
00163
00164 public:
00165
00167 typedef typename Ptr<R>::pointer RefPtr;
00169 typedef typename Ptr<R>::const_pointer cRefPtr;
00171 typedef void (T::*SetFn)(RefPtr);
00173 typedef bool (T::*CheckFn)(cRefPtr) const;
00175 typedef RefPtr (T::*GetFn)() const;
00177 typedef RefPtr T::* Member;
00178
00179 public:
00180
00215 Reference(string newName, string newDescription,
00216 Member newMember, bool depSafe = false,
00217 bool readonly = false, bool rebind = true, bool nullable = true,
00218 SetFn newSetFn = 0, GetFn newGetFn = 0,
00219 CheckFn newCheckFn = 0)
00220 : ReferenceBase(newName, newDescription,
00221 ClassTraits<T>::className(), typeid(T),
00222 ClassTraits<R>::className(), typeid(R),
00223 depSafe, readonly, !rebind, nullable, false),
00224 theMember(newMember), theSetFn(newSetFn), theGetFn(newGetFn),
00225 theCheckFn(newCheckFn) {}
00226
00265 Reference(string newName, string newDescription,
00266 Member newMember, bool depSafe, bool readonly, bool rebind,
00267 bool nullable, bool defnull, SetFn newSetFn = 0, GetFn newGetFn = 0,
00268 CheckFn newCheckFn = 0)
00269 : ReferenceBase(newName, newDescription,
00270 ClassTraits<T>::className(), typeid(T),
00271 ClassTraits<R>::className(), typeid(R),
00272 depSafe, readonly, !rebind, nullable, defnull),
00273 theMember(newMember), theSetFn(newSetFn), theGetFn(newGetFn),
00274 theCheckFn(newCheckFn) {}
00275
00276
00280 virtual void set(InterfacedBase & ib, IBPtr ip, bool chk = true) const
00281 ;
00282
00286 virtual IBPtr get(const InterfacedBase & ib) const
00287 ;
00288
00293 virtual bool check(const InterfacedBase & ib, cIBPtr newRef) const
00294 ;
00295
00299 void setSetFunction(SetFn sf) { theSetFn = sf; }
00300
00304 void setGetFunction(GetFn gf) { theGetFn = gf; }
00305
00309 void setCheckFunction(CheckFn cf) { theCheckFn = cf; }
00310
00311 private:
00312
00316 Member theMember;
00317
00321 SetFn theSetFn;
00322
00326 GetFn theGetFn;
00327
00331 CheckFn theCheckFn;
00332
00333
00334 };
00335
00336 }
00337
00338 #include "Reference.tcc"
00339
00340 #endif