thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
BaseRepository.h
1// -*- C++ -*-
2//
3// BaseRepository.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_BaseRepository_H
10#define ThePEG_BaseRepository_H
11// This is the declaration of the BaseRepository class.
12
14#include "BaseRepository.xh"
15#include "ThePEG/Interface/InterfaceBase.fh"
16#include "ThePEG/Interface/ClassDocumentation.fh"
17#include "ThePEG/Interface/InterfacedBase.h"
18#include "ThePEG/Utilities/ClassDescription.fh"
19
20namespace ThePEG {
21
46
47public:
48
50 typedef StringSet DirectorySet;
51
53 typedef vector<string> StringVector;
54
56 typedef set<const InterfaceBase *> InterfaceSet;
57
60 typedef map<const ClassDescriptionBase *, InterfaceSet> TypeInterfaceMap;
61
64 typedef map<const ClassDescriptionBase *, const ClassDocumentationBase *>
66
67public:
68
75 static string exec(string cmd, ostream &);
76
83 static void Register(const InterfaceBase &, const type_info &);
84
90 static void Register(const ClassDocumentationBase &, const type_info &);
91
98 static void Register(IBPtr);
99
106 static void Register(IBPtr, string name);
107
112 static void remove(tIBPtr);
113
120 static string remove(const ObjectSet & rmset);
121
126 static void rename(tIBPtr object, string newName);
128
137 static void CreateDirectory(string);
138
151 static void CheckObjectDirectory(string);
152
163 static void CheckDirectory(string);
164
171 static void DirectoryAppend(string &);
172
180 static void ChangeDirectory(string name);
181
189 static void PushDirectory(string name);
190
195 static void PopDirectory();
196
200 static vector<string> & globalLibraries();
201
203
206protected:
207
211 static stack<string> & currentReadDirStack();
212
216 static vector<string> & readDirs();
217
218public:
219
223 static const vector<string> & listReadDirs();
224
228 static void prependReadDir(string);
229
233 static void prependReadDir(const std::vector<std::string>& dirs);
234
238 static void appendReadDir(string);
239
243 static void appendReadDir(const std::vector<std::string>& dirs);
244
246
254 template <typename T>
255 static typename Ptr<T>::pointer GetPtr(const T &);
256
262 template <typename PtrType>
263 static PtrType GetPtr(string);
264
273 template <typename PtrType>
274 static PtrType GetObject(string);
275
280 static IBPtr GetPointer(string);
281
286 static IVector SearchDirectory(string name, string className = "");
287
297 static IBPtr TraceObject(string name);
298
304
311 static IBPtr getObjectFromNoun(string noun);
313
321
327
334 static void addReferences(tIBPtr obj, ObjectSet & refs);
336
347 static InterfaceMap getInterfaces(const type_info & ti, bool all = true);
348
352 static const InterfaceBase * FindInterface(IBPtr object, string name);
353
360 static string getInterfaceFromNoun(string noun);
361
368 static string getPosArgFromNoun(string noun);
369
374 template <typename Cont>
375 static vector< pair<IBPtr, const InterfaceBase *> >
377
379
385 static void update();
386
391 template<typename Cont>
392 static void clearAll(const Cont & c)
393 {
394 for_each(c, mem_fn(&InterfacedBase::clear));
395 }
396
401 template<typename Cont>
402 static void resetAll(const Cont & c)
403 {
404 for_each(c, mem_fn(&InterfacedBase::reset));
405 }
406
411 static void readSetup(tIBPtr ip, istream & is);
412
417 static void lock(tIBPtr ip) { ip->lock(); }
418
423 static void unlock(tIBPtr ip) { ip->unlock(); }
425
432
437 static string getModelDescription(tcIBPtr ip);
438
443 static string getModelReferences(tcIBPtr ip);
445
451 static void cout(ostream & os) { coutp() = &os; }
452
456 static ostream & cout() { return *coutp(); }
457
461 static void cerr(ostream & os) { cerrp() = &os; }
462
466 static ostream & cerr() { return *cerrp(); }
467
471 static void clog(ostream & os) { clogp() = &os; }
472
476 static ostream & clog() { return *clogp(); }
478
479protected:
480
488 template <typename T>
489 static typename Ptr<T>::pointer clone(const T & t);
490
496 template <typename T>
497 static typename Ptr<T>::pointer fullclone(const T & t);
498
507 static void rebind(InterfacedBase & obj, const TranslationMap & trans,
508 const IVector & defaults);
510
511
517 InterfaceMap &, bool all = true);
518
525 static ObjectMap & objects();
526
530 static ObjectSet & allObjects();
531
537
543
548
553
557 static bool & updating();
558
562 static ostream *& coutp();
563
567 static ostream *& cerrp();
571 static ostream *& clogp();
573
574};
575
576
577}
578
579#ifndef ThePEG_TEMPLATES_IN_CC_FILE
580#include "BaseRepository.tcc"
581#endif
582
583#endif /* ThePEG_BaseRepository_H */
This is the main config header file for ThePEG.
BaseRepository is a purely static class which keeps a set of InterfacedBase objects indexed by their ...
static ostream & cout()
Get the standard output stream.
static string remove(const ObjectSet &rmset)
Remove objects.
static void remove(tIBPtr)
Remove the given object from the repository.
static const ClassDocumentationBase * getDocumentation(tcIBPtr ip)
Return the class documentation of a given object.
static StringVector & directoryStack()
The current directory stack.
static vector< string > & readDirs()
List of directories to search for files for the "read" command.
static void CheckDirectory(string)
Check if directory exixts.
static Ptr< T >::pointer fullclone(const T &t)
Return a clone of the given object.
static void Register(IBPtr, string name)
Register a new object giving it a new name.
static void cout(ostream &os)
Set the standard output stream.
static Ptr< T >::pointer clone(const T &t)
Return a clone of the given object.
static DirectorySet & directories()
All defined directories.
static string exec(string cmd, ostream &)
Interpret the command in cmd and return possible messages.
static void update()
Call the InterfacedBase::update() function of all objects.
static ostream *& clogp()
The current current standard log stream.
static TypeDocumentationMap & documentations()
Sets of ClassDocumentationBase objects mapped to the class description of the class for which they ar...
static ostream & clog()
Get the standard log stream.
static InterfaceMap getInterfaces(const type_info &ti, bool all=true)
Get interfaces.
static IVector DirectReferences(IBPtr)
Get direct references.
static IVector GetObjectsReferringTo(IBPtr)
Get referring objects.
static ostream *& coutp()
The current current standard output stream.
static TypeInterfaceMap & interfaces()
Sets of InterfaceBase objects mapped to the class description of the class for which they are defined...
static string getInterfaceFromNoun(string noun)
Get an interface name.
static string GetInterfacedBaseClasses(const ClassDescriptionBase *cdb)
Return a string containing the name of the given class description and its base classes,...
static ostream *& cerrp()
The current current standard error stream.
static void rebind(InterfacedBase &obj, const TranslationMap &trans, const IVector &defaults)
Rebind references.
static void prependReadDir(const std::vector< std::string > &dirs)
Add a string vector with directories to readDirs().
static void lock(tIBPtr ip)
Lock the given object.
StringSet DirectorySet
A set of strings.
static ObjectSet & allObjects()
All InterfacedBase objects.
static void clearAll(const Cont &c)
Clear the InterfacedBase::touched() flag in all objects in the given container.
static void appendReadDir(const std::vector< std::string > &dirs)
Add a string vector with directories to readDirs().
static void Register(IBPtr)
Register a new object using the its current name.
static void PopDirectory()
Pop the directory stack.
static Ptr< T >::pointer GetPtr(const T &)
Return a reference counted pointer to the given object.
static string getModelDescription(tcIBPtr ip)
Get the description for the model implemented in the class of the given object.
static void CheckObjectDirectory(string)
Check if directory exixts.
static void DirectoryAppend(string &)
Return the absolute path.
static void clog(ostream &os)
Set the standard log stream.
static void appendReadDir(string)
Add a directory to readDirs().
static void PushDirectory(string name)
Set the current directory to name.
static void addReferences(tIBPtr obj, ObjectSet &refs)
Get all references.
static string getPosArgFromNoun(string noun)
Get interface index.
static void CreateDirectory(string)
Create a new directory with the given name.
map< const ClassDescriptionBase *, InterfaceSet > TypeInterfaceMap
A map of sets of IterfaceBase objects indexed by pointers to ClassDescriptionBase objects.
vector< string > StringVector
A vector of character strings.
static void readSetup(tIBPtr ip, istream &is)
Setup an object.
static PtrType GetPtr(string)
Return a pointer of the specified type to an object with the given name.
static void ChangeDirectory(string name)
Set the current directory to name.
static vector< string > & globalLibraries()
A list of all globally loaded libraries.
static void Register(const ClassDocumentationBase &, const type_info &)
Register a class documentation.
static IBPtr TraceObject(string name)
Find an object.
static IVector SearchDirectory(string name, string className="")
Return all objects in the directory name.
static void prependReadDir(string)
Add a directory to readDirs().
static bool & updating()
Flag to say if we are in the middle of an update procedure.
static void unlock(tIBPtr ip)
Unlock the given object.
static void cerr(ostream &os)
Set the standard error stream.
set< const InterfaceBase * > InterfaceSet
A set of pointers to InterfaceBase objects.
static vector< pair< IBPtr, const InterfaceBase * > > getNonDefaultInterfaces(const Cont &)
Return a list of the interfaces which do not have their default values for the given objects.
static ostream & cerr()
Get the standard error stream.
static const InterfaceBase * FindInterface(IBPtr object, string name)
Return an interface with the given name to the given object.
static IBPtr getObjectFromNoun(string noun)
Get an object.
static IBPtr GetPointer(string)
Return a pointer to an object with the given name or null if no such object exists.
static void addInterfaces(const ClassDescriptionBase &, InterfaceMap &, bool all=true)
Add interfaces to the given map for the class with the given class description.
static stack< string > & currentReadDirStack()
The stack of directories used by the "read" command.
static ObjectMap & objects()
All InterfacedBase objects mapped to their name.
static const vector< string > & listReadDirs()
Access to list of directories to search for files for the "read" command.
static PtrType GetObject(string)
Return a pointer of the specified type to an object with the given name.
static void rename(tIBPtr object, string newName)
Rename a given object.
map< const ClassDescriptionBase *, const ClassDocumentationBase * > TypeDocumentationMap
A map of ClassDocumentationBase objects indexed by pointers to ClassDescriptionBase objects.
static void Register(const InterfaceBase &, const type_info &)
Register an interface.
static void resetAll(const Cont &c)
Set the status of all objects in the given container to InterfacedBase::uninitialized.
static string getModelReferences(tcIBPtr ip)
Get the references for the model implemented in the class of the given object.
ClassDescriptionBase is the base class for all class description classes.
The ClassDocumentationBase class is used to communicate documetation about an Interfaced class to the...
The InterfaceBase class defines a generic interface to any class derived from the InterfacedBase clas...
Definition: InterfaceBase.h:59
InterfacedBase is the base class of all Interfaced objects to be handled by the BaseRepository class.
void clear()
Calls reset() and unTouch().
void reset()
Set the state of this object to uninitialized.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
TransientConstRCPtr is a simple wrapper around a bare const pointer which can be assigned to and from...
Definition: RCPtr.h:696
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
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
FNC for_each(IteratorRange< Iterator > r, FNC f)
The std::for_each function taking an IteratorRange as argument.
Definition: algorithm.h:79