00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_BaseRepository_H
00010 #define ThePEG_BaseRepository_H
00011
00012
00013 #include "ThePEG/Config/ThePEG.h"
00014 #include "BaseRepository.xh"
00015 #include "ThePEG/Interface/InterfaceBase.fh"
00016 #include "ThePEG/Interface/ClassDocumentation.fh"
00017 #include "ThePEG/Interface/InterfacedBase.h"
00018 #include "ThePEG/Utilities/ClassDescription.fh"
00019
00020 namespace ThePEG {
00021
00045 class BaseRepository {
00046
00047 public:
00048
00050 typedef StringSet DirectorySet;
00051
00053 typedef vector<string> StringVector;
00054
00056 typedef set<const InterfaceBase *> InterfaceSet;
00057
00060 typedef map<const ClassDescriptionBase *, InterfaceSet> TypeInterfaceMap;
00061
00064 typedef map<const ClassDescriptionBase *, const ClassDocumentationBase *>
00065 TypeDocumentationMap;
00066
00067 public:
00068
00075 static string exec(string cmd, ostream &);
00076
00083 static void Register(const InterfaceBase &, const type_info &);
00084
00090 static void Register(const ClassDocumentationBase &, const type_info &);
00091
00098 static void Register(IBPtr);
00099
00106 static void Register(IBPtr, string name);
00107
00112 static void remove(tIBPtr);
00113
00120 static string remove(const ObjectSet & rmset);
00121
00126 static void rename(tIBPtr object, string newName);
00128
00137 static void CreateDirectory(string);
00138
00151 static void CheckObjectDirectory(string);
00152
00163 static void CheckDirectory(string);
00164
00171 static void DirectoryAppend(string &);
00172
00180 static void ChangeDirectory(string name);
00181
00189 static void PushDirectory(string name);
00190
00195 static void PopDirectory();
00196
00200 static vector<string> & globalLibraries();
00201
00203
00206 protected:
00207
00211 static stack<string> & currentReadDirStack();
00212
00216 static vector<string> & readDirs();
00217
00218 public:
00219
00223 static void prependReadDir(string);
00224
00228 static void appendReadDir(string);
00229
00231
00239 template <typename T>
00240 static typename Ptr<T>::pointer GetPtr(const T &);
00241
00247 template <typename PtrType>
00248 static PtrType GetPtr(string);
00249
00258 template <typename PtrType>
00259 static PtrType GetObject(string);
00260
00265 static IBPtr GetPointer(string);
00266
00271 static IVector SearchDirectory(string name, string className = "");
00272
00282 static IBPtr TraceObject(string name);
00283
00288 static string GetInterfacedBaseClasses(const ClassDescriptionBase * cdb);
00289
00296 static IBPtr getObjectFromNoun(string noun);
00298
00305 static IVector GetObjectsReferringTo(IBPtr);
00306
00311 static IVector DirectReferences(IBPtr);
00312
00319 static void addReferences(tIBPtr obj, ObjectSet & refs);
00321
00332 static InterfaceMap getInterfaces(const type_info & ti, bool all = true);
00333
00337 static const InterfaceBase * FindInterface(IBPtr object, string name);
00338
00345 static string getInterfaceFromNoun(string noun);
00346
00353 static string getPosArgFromNoun(string noun);
00355
00361 static void update();
00362
00367 template<typename Cont>
00368 static void clearAll(const Cont & c)
00369 {
00370 for_each(c, mem_fun(&InterfacedBase::clear));
00371 }
00372
00377 template<typename Cont>
00378 static void resetAll(const Cont & c)
00379 {
00380 for_each(c, mem_fun(&InterfacedBase::reset));
00381 }
00382
00387 static void readSetup(tIBPtr ip, istream & is);
00388
00393 static void lock(tIBPtr ip) { ip->lock(); }
00394
00399 static void unlock(tIBPtr ip) { ip->unlock(); }
00401
00407 static const ClassDocumentationBase * getDocumentation(tcIBPtr ip);
00408
00413 static string getModelDescription(tcIBPtr ip);
00414
00419 static string getModelReferences(tcIBPtr ip);
00421
00427 static void cout(ostream & os) { coutp() = &os; }
00428
00432 static ostream & cout() { return *coutp(); }
00433
00437 static void cerr(ostream & os) { cerrp() = &os; }
00438
00442 static ostream & cerr() { return *cerrp(); }
00443
00447 static void clog(ostream & os) { clogp() = &os; }
00448
00452 static ostream & clog() { return *clogp(); }
00454
00455 protected:
00456
00464 template <typename T>
00465 static typename Ptr<T>::pointer clone(const T & t);
00466
00472 template <typename T>
00473 static typename Ptr<T>::pointer fullclone(const T & t);
00474
00483 static void rebind(InterfacedBase & obj, const TranslationMap & trans,
00484 const IVector & defaults);
00486
00487
00492 static void addInterfaces(const ClassDescriptionBase &,
00493 InterfaceMap &, bool all = true);
00494
00501 static ObjectMap & objects();
00502
00506 static ObjectSet & allObjects();
00507
00512 static TypeInterfaceMap & interfaces();
00513
00518 static TypeDocumentationMap & documentations();
00519
00523 static DirectorySet & directories();
00524
00528 static StringVector & directoryStack();
00529
00533 static bool & updating();
00534
00538 static ostream *& coutp();
00539
00543 static ostream *& cerrp();
00547 static ostream *& clogp();
00549
00550 };
00551
00552
00553 }
00554
00555 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
00556 #include "BaseRepository.tcc"
00557 #endif
00558
00559 #endif