ThePEG 2.3.0
|
BaseRepository is a purely static class which keeps a set of InterfacedBase objects indexed by their name. More...
#include <BaseRepository.h>
Public Types | |
typedef StringSet | DirectorySet |
A set of strings. | |
typedef vector< string > | StringVector |
A vector of character strings. | |
typedef set< const InterfaceBase * > | InterfaceSet |
A set of pointers to InterfaceBase objects. | |
typedef map< const ClassDescriptionBase *, InterfaceSet > | TypeInterfaceMap |
A map of sets of IterfaceBase objects indexed by pointers to ClassDescriptionBase objects. | |
typedef map< const ClassDescriptionBase *, const ClassDocumentationBase * > | TypeDocumentationMap |
A map of ClassDocumentationBase objects indexed by pointers to ClassDescriptionBase objects. | |
Static Public Member Functions | |
static string | exec (string cmd, ostream &) |
Interpret the command in cmd and return possible messages. | |
Functions for adding and deleting objects and interfaces. | |
static void | Register (const InterfaceBase &, const type_info &) |
Register an interface. | |
static void | Register (const ClassDocumentationBase &, const type_info &) |
Register a class documentation. | |
static void | Register (IBPtr) |
Register a new object using the its current name. | |
static void | Register (IBPtr, string name) |
Register a new object giving it a new name. | |
static void | remove (tIBPtr) |
Remove the given object from the repository. | |
static string | remove (const ObjectSet &rmset) |
Remove objects. | |
static void | rename (tIBPtr object, string newName) |
Rename a given object. | |
Access the directory stack. | |
static void | CreateDirectory (string) |
Create a new directory with the given name. | |
static void | CheckObjectDirectory (string) |
Check if directory exixts. | |
static void | CheckDirectory (string) |
Check if directory exixts. | |
static void | DirectoryAppend (string &) |
Return the absolute path. | |
static void | ChangeDirectory (string name) |
Set the current directory to name. | |
static void | PushDirectory (string name) |
Set the current directory to name. | |
static void | PopDirectory () |
Pop the directory stack. | |
static vector< string > & | globalLibraries () |
A list of all globally loaded libraries. | |
Access objects in the repository. | |
template<typename T > | |
static Ptr< T >::pointer | GetPtr (const T &) |
Return a reference counted pointer to the given object. | |
template<typename PtrType > | |
static PtrType | GetPtr (string) |
Return a pointer of the specified type to an object with the given name. | |
template<typename PtrType > | |
static PtrType | GetObject (string) |
Return a pointer of the specified type to an object with the given name. | |
static IBPtr | GetPointer (string) |
Return a pointer to an object with the given name or null if no such object exists. | |
static IVector | SearchDirectory (string name, string className="") |
Return all objects in the directory name. | |
static IBPtr | TraceObject (string name) |
Find an object. | |
static string | GetInterfacedBaseClasses (const ClassDescriptionBase *cdb) |
Return a string containing the name of the given class description and its base classes, one on each line. | |
static IBPtr | getObjectFromNoun (string noun) |
Get an object. | |
Access references between object in the repository. | |
static IVector | GetObjectsReferringTo (IBPtr) |
Get referring objects. | |
static IVector | DirectReferences (IBPtr) |
Get direct references. | |
static void | addReferences (tIBPtr obj, ObjectSet &refs) |
Get all references. | |
Access the interfaces of the objects in the repository. | |
static InterfaceMap | getInterfaces (const type_info &ti, bool all=true) |
Get interfaces. | |
static const InterfaceBase * | FindInterface (IBPtr object, string name) |
Return an interface with the given name to the given object. | |
static string | getInterfaceFromNoun (string noun) |
Get an interface name. | |
static string | getPosArgFromNoun (string noun) |
Get interface index. | |
template<typename Cont > | |
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. | |
Manipulate objects in the repository. | |
static void | update () |
Call the InterfacedBase::update() function of all objects. | |
template<typename Cont > | |
static void | clearAll (const Cont &c) |
Clear the InterfacedBase::touched() flag in all objects in the given container. | |
template<typename Cont > | |
static void | resetAll (const Cont &c) |
Set the status of all objects in the given container to InterfacedBase::uninitialized. | |
static void | readSetup (tIBPtr ip, istream &is) |
Setup an object. | |
static void | lock (tIBPtr ip) |
Lock the given object. | |
static void | unlock (tIBPtr ip) |
Unlock the given object. | |
Access the documentation of objects. | |
static const ClassDocumentationBase * | getDocumentation (tcIBPtr ip) |
Return the class documentation of a given object. | |
static string | getModelDescription (tcIBPtr ip) |
Get the description for the model implemented in the class of the given object. | |
static string | getModelReferences (tcIBPtr ip) |
Get the references for the model implemented in the class of the given object. | |
Manipulate the output streams of the repository. | |
static void | cout (ostream &os) |
Set the standard output stream. | |
static ostream & | cout () |
Get the standard output stream. | |
static void | cerr (ostream &os) |
Set the standard error stream. | |
static ostream & | cerr () |
Get the standard error stream. | |
static void | clog (ostream &os) |
Set the standard log stream. | |
static ostream & | clog () |
Get the standard log stream. | |
Static Protected Member Functions | |
Access standard InterfacedBase functions. | |
template<typename T > | |
static Ptr< T >::pointer | clone (const T &t) |
Return a clone of the given object. | |
template<typename T > | |
static Ptr< T >::pointer | fullclone (const T &t) |
Return a clone of the given object. | |
static void | rebind (InterfacedBase &obj, const TranslationMap &trans, const IVector &defaults) |
Rebind references. | |
static void | addInterfaces (const ClassDescriptionBase &, InterfaceMap &, bool all=true) |
Add interfaces to the given map for the class with the given class description. | |
Functions containing the static instances of objects used | |
by the repository. | |
static ObjectMap & | objects () |
All InterfacedBase objects mapped to their name. | |
static ObjectSet & | allObjects () |
All InterfacedBase objects. | |
static TypeInterfaceMap & | interfaces () |
Sets of InterfaceBase objects mapped to the class description of the class for which they are defined. | |
static TypeDocumentationMap & | documentations () |
Sets of ClassDocumentationBase objects mapped to the class description of the class for which they are defined. | |
static DirectorySet & | directories () |
All defined directories. | |
static StringVector & | directoryStack () |
The current directory stack. | |
static bool & | updating () |
Flag to say if we are in the middle of an update procedure. | |
static ostream *& | coutp () |
The current current standard output stream. | |
static ostream *& | cerrp () |
The current current standard error stream. | |
static ostream *& | clogp () |
The current current standard log stream. | |
Information on where to read input files. | |
static const vector< string > & | listReadDirs () |
Access to list of directories to search for files for the "read" command. | |
static void | prependReadDir (string) |
Add a directory to readDirs(). | |
static void | prependReadDir (const std::vector< std::string > &dirs) |
Add a string vector with directories to readDirs(). | |
static void | appendReadDir (string) |
Add a directory to readDirs(). | |
static void | appendReadDir (const std::vector< std::string > &dirs) |
Add a string vector with directories to readDirs(). | |
static stack< string > & | currentReadDirStack () |
The stack of directories used by the "read" command. | |
static vector< string > & | readDirs () |
List of directories to search for files for the "read" command. | |
BaseRepository is a purely static class which keeps a set of InterfacedBase objects indexed by their name.
The objects and their names are divided up in a tree-like structure inspired by the Unix file system.
The InterfacedBase objects may be manipulated using InterfaceBase objects. This may be done directly or via a simple command interface using the exec() method.
RepositoryBase is closely related to the Repository sub-class. The division may seem unnecessary, but the idea is that BaseRepository is a general repository for administrating and manipulating a set of InterfacedBase objects, while the Repository adds on utilites which are special to ThePEG where the objects are Interfaced (a sub-class of InterfacedBase).
Definition at line 45 of file BaseRepository.h.
typedef StringSet ThePEG::BaseRepository::DirectorySet |
A set of strings.
Definition at line 50 of file BaseRepository.h.
typedef set<const InterfaceBase *> ThePEG::BaseRepository::InterfaceSet |
A set of pointers to InterfaceBase objects.
Definition at line 56 of file BaseRepository.h.
typedef vector<string> ThePEG::BaseRepository::StringVector |
A vector of character strings.
Definition at line 53 of file BaseRepository.h.
typedef map<const ClassDescriptionBase *, const ClassDocumentationBase *> ThePEG::BaseRepository::TypeDocumentationMap |
A map of ClassDocumentationBase objects indexed by pointers to ClassDescriptionBase objects.
Definition at line 65 of file BaseRepository.h.
typedef map<const ClassDescriptionBase *, InterfaceSet> ThePEG::BaseRepository::TypeInterfaceMap |
A map of sets of IterfaceBase objects indexed by pointers to ClassDescriptionBase objects.
Definition at line 60 of file BaseRepository.h.
|
staticprotected |
Add interfaces to the given map for the class with the given class description.
Recursively do the same with the base classes.
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
Set the current directory to name.
name can be aither a relative or absolute path. The new directory replaces the previous current directory on the directory stack.
RepositoryNoDirectory | if the directory is non-existent. |
|
static |
Check if directory exixts.
Check if the name given as argument corresponds to an existing directory. If the given name starts with a /
the name is assumed to be an absolute path, otherwise it is assumed to be a path relative to the current directory.
RepositoryNoDirectory | if the correspinding directory is non-existent. |
|
static |
Check if directory exixts.
Check if the name given as argument corresponds to an existing directory. If the argument string does not end in a /
it is assumed to be the name of an object in a directory, and only the directory part of the name is checked. If the given name starts with a /
the name is assumed to be an absolute path, otherwise it is assumed to be a path relative to the current directory.
RepositoryNoDirectory | if the correspinding directory is non-existent. |
|
inlinestatic |
Clear the InterfacedBase::touched() flag in all objects in the given container.
Definition at line 392 of file BaseRepository.h.
References ThePEG::InterfacedBase::clear(), and ThePEG::for_each().
|
inlinestatic |
Get the standard log stream.
Definition at line 476 of file BaseRepository.h.
References clogp().
Referenced by ThePEG::Throw< Ex >::writeWarning().
|
inlinestatic |
|
staticprotected |
Return a clone of the given object.
Calls the InterfacedBase::clone() function of t and casts the resulting pointer to the correct type.
|
inlinestatic |
Get the standard output stream.
Definition at line 456 of file BaseRepository.h.
References coutp().
|
inlinestatic |
Set the standard output stream.
Definition at line 451 of file BaseRepository.h.
References coutp().
|
static |
Create a new directory with the given name.
If the given name starts with a /
the name is assumed to be an absolute path, otherwise it is assumed to be a path relative to the current directory.
|
static |
Return the absolute path.
If the given name starts with a /
the name is assumed to be an absolute path already, otherwise it is assumed to be a path relative to the current directory, and the absolute path is constructed.
|
static |
Interpret the command in cmd and return possible messages.
This is the main function for the command-line interface. The syntax is described elsewhere. The ostream argument is currently unused.
|
staticprotected |
Return a clone of the given object.
Calls the InterfacedBase::fullclone() function of t and casts the resulting pointer to the correct type.
|
static |
Get an interface name.
Decompose a string of the form object:interface
or object:vector-interface[pos]
. Return the interface name (without the [pos]
).
|
static |
Get interfaces.
Return the interfaces defined for the InterfacedBase class with the given type_info, ti, mapped to their name. If several interfaces with the same name exists only the one which correspond to the most derived class will be given, except if all is true in which case all interfaces are given (prefixed by '+'s to become unique).
|
static |
Return a pointer of the specified type to an object with the given name.
If such an object does not exist an exception will be thrown.
RepositoryNotFound | if the object was not found. |
RepositoryClassMisMatch | if the object exists but is of the wrong class. |
|
static |
Get an object.
Decompose a string of the form object:interface
or object:vector-interface[pos]
. Retrun a pointer to the corresponding object
.
|
static |
Get interface index.
Decompose a string of the form object:interface
or object:vector-interface[pos]
. Return the pos
part or empty string if not present.
|
static |
Return a reference counted pointer to the given object.
This currently not needed when ThePEG is used with the ThePEG::Pointer::RCPtr class of pointers.
|
static |
Return a pointer of the specified type to an object with the given name.
If such an object does not exist, GetPtr will return a null pointer.
|
inlinestatic |
Lock the given object.
Locked objects cannot be changed through an interface.
Definition at line 417 of file BaseRepository.h.
|
static |
Pop the directory stack.
Leave the current directory and set the directory which is on top of the popped directory stack.
|
static |
Set the current directory to name.
name can be aither a relative or absolute path. The new directory is pushed onto the directory stack.
RepositoryNoDirectory | if the directory is non-existent. |
|
static |
Setup an object.
Execute the InterfacedBase::readSetup() method of ip with the stream is as argument.
|
staticprotected |
Rebind references.
For all objects directly referenced by obj, replace them with the translation found in trans. If obj has a Reference or a member of a RefVector interface which is null, and the corresponding interface has the RefInterfaceBase::defaultIfNull() flag set, translate the null pointer to the first acceptable object in defaults.
|
static |
Register a class documentation.
This is called automatically in the ClassDocumentationBase constructor and should never be called explicitly.
|
static |
Register an interface.
This is called automatically in the InterfaceBase constructor and should never be called explicitly.
|
static |
Register a new object using the its current name.
If the object is already in the repository, nothing happens. If another object already exists with the same name, the new object will have #
's appended to its name to make it unique.
|
static |
Register a new object giving it a new name.
If the object is already in the repository, nothing happens. If another object already exists with the same name, the new object will have #
's appended to its name to make it unique.
|
static |
Remove objects.
Remove the objects in rmset if there are no other objects in the repository referring to them, otherwise return an error message and the names of the objects refering to them separated by new-line characters.
|
static |
Remove the given object from the repository.
If the object was not present nothing will happen.
|
static |
Rename a given object.
Syntacticly the same as remove(object); Register(object, newName);
.
|
inlinestatic |
Set the status of all objects in the given container to InterfacedBase::uninitialized.
Definition at line 402 of file BaseRepository.h.
References ThePEG::for_each(), and ThePEG::InterfacedBase::reset().
|
static |
Return all objects in the directory name.
Optionally only return objects of class className or of a sub-class thereof.
|
static |
Find an object.
If the name does not begin with '/', the current directory is prepended. If the string is on the form object:interface
(or object:interface[i]
) and interface
corresponds to an Reference (or RefVector) interface, the corresponding referenced object is returned. (also object:interface:interface
is allowed etc.)
|
inlinestatic |
Unlock the given object.
Locked objects cannot be changed through an interface.
Definition at line 423 of file BaseRepository.h.