thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.1.4

BaseRepository is a purely static class which keeps a set of InterfacedBase objects indexed by their name. More...

#include <BaseRepository.h>

Inheritance diagram for ThePEG::BaseRepository:

Public Types

typedef StringSet DirectorySet
 A set of strings. More...
 
typedef vector< string > StringVector
 A vector of character strings. More...
 
typedef set< const InterfaceBase * > InterfaceSet
 A set of pointers to InterfaceBase objects. More...
 
typedef map< const ClassDescriptionBase *, InterfaceSetTypeInterfaceMap
 A map of sets of IterfaceBase objects indexed by pointers to ClassDescriptionBase objects. More...
 
typedef map< const ClassDescriptionBase *, const ClassDocumentationBase * > TypeDocumentationMap
 A map of ClassDocumentationBase objects indexed by pointers to ClassDescriptionBase objects. More...
 

Static Public Member Functions

static string exec (string cmd, ostream &)
 Interpret the command in cmd and return possible messages. More...
 
Functions for adding and deleting objects and interfaces.
static void Register (const InterfaceBase &, const type_info &)
 Register an interface. More...
 
static void Register (const ClassDocumentationBase &, const type_info &)
 Register a class documentation. More...
 
static void Register (IBPtr)
 Register a new object using the its current name. More...
 
static void Register (IBPtr, string name)
 Register a new object giving it a new name. More...
 
static void remove (tIBPtr)
 Remove the given object from the repository. More...
 
static string remove (const ObjectSet &rmset)
 Remove objects. More...
 
static void rename (tIBPtr object, string newName)
 Rename a given object. More...
 
Access the directory stack.
static void CreateDirectory (string)
 Create a new directory with the given name. More...
 
static void CheckObjectDirectory (string)
 Check if directory exixts. More...
 
static void CheckDirectory (string)
 Check if directory exixts. More...
 
static void DirectoryAppend (string &)
 Return the absolute path. More...
 
static void ChangeDirectory (string name)
 Set the current directory to name. More...
 
static void PushDirectory (string name)
 Set the current directory to name. More...
 
static void PopDirectory ()
 Pop the directory stack. More...
 
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. More...
 
template<typename PtrType >
static PtrType GetPtr (string)
 Return a pointer of the specified type to an object with the given name. More...
 
template<typename PtrType >
static PtrType GetObject (string)
 Return a pointer of the specified type to an object with the given name. More...
 
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. More...
 
static IBPtr TraceObject (string name)
 Find an object. More...
 
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. More...
 
Access references between object in the repository.
static IVector GetObjectsReferringTo (IBPtr)
 Get referring objects. More...
 
static IVector DirectReferences (IBPtr)
 Get direct references. More...
 
static void addReferences (tIBPtr obj, ObjectSet &refs)
 Get all references. More...
 
Access the interfaces of the objects in the repository.
static InterfaceMap getInterfaces (const type_info &ti, bool all=true)
 Get interfaces. More...
 
static const InterfaceBaseFindInterface (IBPtr object, string name)
 Return an interface with the given name to the given object.
 
static string getInterfaceFromNoun (string noun)
 Get an interface name. More...
 
static string getPosArgFromNoun (string noun)
 Get interface index. More...
 
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. More...
 
static void lock (tIBPtr ip)
 Lock the given object. More...
 
static void unlock (tIBPtr ip)
 Unlock the given object. More...
 
Access the documentation of objects.
static const ClassDocumentationBasegetDocumentation (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

static void addInterfaces (const ClassDescriptionBase &, InterfaceMap &, bool all=true)
 Add interfaces to the given map for the class with the given class description. More...
 
Access standard InterfacedBase functions.
template<typename T >
static Ptr< T >::pointer clone (const T &t)
 Return a clone of the given object. More...
 
template<typename T >
static Ptr< T >::pointer fullclone (const T &t)
 Return a clone of the given object. More...
 
static void rebind (InterfacedBase &obj, const TranslationMap &trans, const IVector &defaults)
 Rebind references. More...
 
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 TypeInterfaceMapinterfaces ()
 Sets of InterfaceBase objects mapped to the class description of the class for which they are defined.
 
static TypeDocumentationMapdocumentations ()
 Sets of ClassDocumentationBase objects mapped to the class description of the class for which they are defined.
 
static DirectorySetdirectories ()
 All defined directories.
 
static StringVectordirectoryStack ()
 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.
 

Detailed Description

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).

See also
Repository
InterfacedBase
InterfaceBase
Interfaced

Definition at line 45 of file BaseRepository.h.

Member Typedef Documentation

◆ DirectorySet

A set of strings.

Definition at line 50 of file BaseRepository.h.

◆ InterfaceSet

A set of pointers to InterfaceBase objects.

Definition at line 56 of file BaseRepository.h.

◆ StringVector

typedef vector<string> ThePEG::BaseRepository::StringVector

A vector of character strings.

Definition at line 53 of file BaseRepository.h.

◆ TypeDocumentationMap

A map of ClassDocumentationBase objects indexed by pointers to ClassDescriptionBase objects.

Definition at line 65 of file BaseRepository.h.

◆ TypeInterfaceMap

A map of sets of IterfaceBase objects indexed by pointers to ClassDescriptionBase objects.

Definition at line 60 of file BaseRepository.h.

Member Function Documentation

◆ addInterfaces()

static void ThePEG::BaseRepository::addInterfaces ( const ClassDescriptionBase ,
InterfaceMap &  ,
bool  all = true 
)
staticprotected

Add interfaces to the given map for the class with the given class description.

Recursively do the same with the base classes.

Referenced by clog().

◆ addReferences()

static void ThePEG::BaseRepository::addReferences ( tIBPtr  obj,
ObjectSet &  refs 
)
static

Get all references.

If obj contains references to other objects, either through a Reference or RefVector interface or through the virtual getReferences member function, add these to refs. Do the same to the references recursively.

◆ ChangeDirectory()

static void ThePEG::BaseRepository::ChangeDirectory ( string  name)
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.

Exceptions
RepositoryNoDirectoryif the directory is non-existent.

◆ CheckDirectory()

static void ThePEG::BaseRepository::CheckDirectory ( string  )
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.

Exceptions
RepositoryNoDirectoryif the correspinding directory is non-existent.

◆ CheckObjectDirectory()

static void ThePEG::BaseRepository::CheckObjectDirectory ( string  )
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.

Exceptions
RepositoryNoDirectoryif the correspinding directory is non-existent.

◆ clone()

template<typename T >
static Ptr<T>::pointer ThePEG::BaseRepository::clone ( const T &  t)
staticprotected

Return a clone of the given object.

Calls the InterfacedBase::clone() function of t and casts the resulting pointer to the correct type.

Referenced by clog().

◆ CreateDirectory()

static void ThePEG::BaseRepository::CreateDirectory ( string  )
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.

◆ DirectoryAppend()

static void ThePEG::BaseRepository::DirectoryAppend ( string &  )
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.

◆ DirectReferences()

static IVector ThePEG::BaseRepository::DirectReferences ( IBPtr  )
static

Get direct references.

Return all objects the given object refers to directly through a Reference of RefVector interface.

◆ exec()

static string ThePEG::BaseRepository::exec ( string  cmd,
ostream &   
)
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.

◆ fullclone()

template<typename T >
static Ptr<T>::pointer ThePEG::BaseRepository::fullclone ( const T &  t)
staticprotected

Return a clone of the given object.

Calls the InterfacedBase::fullclone() function of t and casts the resulting pointer to the correct type.

Referenced by clog().

◆ getInterfaceFromNoun()

static string ThePEG::BaseRepository::getInterfaceFromNoun ( string  noun)
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]).

◆ getInterfaces()

static InterfaceMap ThePEG::BaseRepository::getInterfaces ( const type_info &  ti,
bool  all = true 
)
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).

◆ GetObject()

template<typename PtrType >
static PtrType ThePEG::BaseRepository::GetObject ( string  )
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.

Exceptions
RepositoryNotFoundif the object was not found.
RepositoryClassMisMatchif the object exists but is of the wrong class.

◆ getObjectFromNoun()

static IBPtr ThePEG::BaseRepository::getObjectFromNoun ( string  noun)
static

Get an object.

Decompose a string of the form object:interface or object:vector-interface[pos]. Retrun a pointer to the corresponding object.

◆ GetObjectsReferringTo()

static IVector ThePEG::BaseRepository::GetObjectsReferringTo ( IBPtr  )
static

Get referring objects.

Return all object which refers to the given object through a Reference of RefVector interface.

◆ getPosArgFromNoun()

static string ThePEG::BaseRepository::getPosArgFromNoun ( string  noun)
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.

◆ GetPtr() [1/2]

template<typename T >
static Ptr<T>::pointer ThePEG::BaseRepository::GetPtr ( const T &  )
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.

◆ GetPtr() [2/2]

template<typename PtrType >
static PtrType ThePEG::BaseRepository::GetPtr ( string  )
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.

◆ lock()

static void ThePEG::BaseRepository::lock ( tIBPtr  ip)
inlinestatic

Lock the given object.

Locked objects cannot be changed through an interface.

Definition at line 417 of file BaseRepository.h.

◆ PopDirectory()

static void ThePEG::BaseRepository::PopDirectory ( )
static

Pop the directory stack.

Leave the current directory and set the directory which is on top of the popped directory stack.

◆ PushDirectory()

static void ThePEG::BaseRepository::PushDirectory ( string  name)
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.

Exceptions
RepositoryNoDirectoryif the directory is non-existent.

◆ readSetup()

static void ThePEG::BaseRepository::readSetup ( tIBPtr  ip,
istream &  is 
)
static

Setup an object.

Execute the InterfacedBase::readSetup() method of ip with the stream is as argument.

Referenced by resetAll().

◆ rebind()

static void ThePEG::BaseRepository::rebind ( InterfacedBase obj,
const TranslationMap trans,
const IVector defaults 
)
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.

Referenced by clog().

◆ Register() [1/4]

static void ThePEG::BaseRepository::Register ( const InterfaceBase ,
const type_info &   
)
static

Register an interface.

This is called automatically in the InterfaceBase constructor and should never be called explicitly.

◆ Register() [2/4]

static void ThePEG::BaseRepository::Register ( const ClassDocumentationBase ,
const type_info &   
)
static

Register a class documentation.

This is called automatically in the ClassDocumentationBase constructor and should never be called explicitly.

◆ Register() [3/4]

static void ThePEG::BaseRepository::Register ( IBPtr  )
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.

◆ Register() [4/4]

static void ThePEG::BaseRepository::Register ( IBPtr  ,
string  name 
)
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.

◆ remove() [1/2]

static void ThePEG::BaseRepository::remove ( tIBPtr  )
static

Remove the given object from the repository.

If the object was not present nothing will happen.

◆ remove() [2/2]

static string ThePEG::BaseRepository::remove ( const ObjectSet &  rmset)
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.

◆ rename()

static void ThePEG::BaseRepository::rename ( tIBPtr  object,
string  newName 
)
static

Rename a given object.

Syntacticly the same as remove(object); Register(object, newName);.

◆ SearchDirectory()

static IVector ThePEG::BaseRepository::SearchDirectory ( string  name,
string  className = "" 
)
static

Return all objects in the directory name.

Optionally only return objects of class className or of a sub-class thereof.

◆ TraceObject()

static IBPtr ThePEG::BaseRepository::TraceObject ( string  name)
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.)

◆ unlock()

static void ThePEG::BaseRepository::unlock ( tIBPtr  ip)
inlinestatic

Unlock the given object.

Locked objects cannot be changed through an interface.

Definition at line 423 of file BaseRepository.h.

References getDocumentation(), getModelDescription(), and getModelReferences().


The documentation for this class was generated from the following file: