thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ThePEG::BaseRepository Class Reference

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.
 
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 *, InterfaceSetTypeInterfaceMap
 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 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.
 
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 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

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

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

◆ cerr() [1/2]

static ostream & ThePEG::BaseRepository::cerr ( )
inlinestatic

Get the standard error stream.

Definition at line 466 of file BaseRepository.h.

References cerrp().

◆ cerr() [2/2]

static void ThePEG::BaseRepository::cerr ( ostream &  os)
inlinestatic

Set the standard error stream.

Definition at line 461 of file BaseRepository.h.

References cerrp().

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

◆ clearAll()

template<typename Cont >
static void ThePEG::BaseRepository::clearAll ( const Cont &  c)
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().

◆ clog() [1/2]

static ostream & ThePEG::BaseRepository::clog ( )
inlinestatic

Get the standard log stream.

Definition at line 476 of file BaseRepository.h.

References clogp().

Referenced by ThePEG::Throw< Ex >::writeWarning().

◆ clog() [2/2]

static void ThePEG::BaseRepository::clog ( ostream &  os)
inlinestatic

Set the standard log stream.

Definition at line 471 of file BaseRepository.h.

References clogp().

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

◆ cout() [1/2]

static ostream & ThePEG::BaseRepository::cout ( )
inlinestatic

Get the standard output stream.

Definition at line 456 of file BaseRepository.h.

References coutp().

◆ cout() [2/2]

static void ThePEG::BaseRepository::cout ( ostream &  os)
inlinestatic

Set the standard output stream.

Definition at line 451 of file BaseRepository.h.

References coutp().

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

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

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

◆ Register() [1/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() [2/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() [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 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.

◆ remove() [2/2]

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

Remove the given object from the repository.

If the object was not present nothing will happen.

◆ rename()

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

Rename a given object.

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

◆ resetAll()

template<typename Cont >
static void ThePEG::BaseRepository::resetAll ( const Cont &  c)
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().

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


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