RSC  0.7.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rsc::misc::Registry< R > Class Template Reference

A templatized global registry. More...

#include <Registry.h>

Inheritance diagram for rsc::misc::Registry< R >:
Inheritance graph
Collaboration diagram for rsc::misc::Registry< R >:
Collaboration graph

Public Member Functions

 Registry ()
 
void addRegistree (R *r, const std::string &errorDescription="")
 Registers a new registree in the Registry. More...
 
boost::shared_ptr< R > getRegistree (const std::string &key)
 Returns the registree for the provided key. More...
 
std::set< std::string > getKnownRegistryKeys ()
 Returns a set with all known registree keys. More...
 
bool removeRegistree (const std::string &name)
 Removes a registree from this registry. More...
 
boost::recursive_mutex * getMutex ()
 Returns a recursive mutex that can be used to make multiple operations on this class atomic. More...
 

Private Attributes

boost::recursive_mutex mutex
 
std::map< std::string,
boost::shared_ptr< R > > 
registreesByName
 

Detailed Description

template<class R>
class rsc::misc::Registry< R >

A templatized global registry.

To create a registree, that will be registered on application startup before main use the provided macros. This will work on every supported compiler.

This class is reentrant.

Author
jwienke
Template Parameters
Rtype to register called registree.

Definition at line 58 of file Registry.h.

Constructor & Destructor Documentation

template<class R>
rsc::misc::Registry< R >::Registry ( )
inline

Definition at line 61 of file Registry.h.

Member Function Documentation

template<class R>
void rsc::misc::Registry< R >::addRegistree ( R *  r,
const std::string &  errorDescription = "" 
)
inline

Registers a new registree in the Registry.

This class takes over the ownership of the pointer and manages deleting the pointer when needed.

Parameters
rnew registree to register
errorDescriptionoptional string to add to the message of the exception which is raised when a registree with a same key already exists.
Exceptions
std::invalid_argumentif a registree with the same key is already registered. In this case r is not owned by this registry

Definition at line 76 of file Registry.h.

References rsc::misc::Registry< R >::mutex, and rsc::misc::Registry< R >::registreesByName.

template<class R>
std::set<std::string> rsc::misc::Registry< R >::getKnownRegistryKeys ( )
inline

Returns a set with all known registree keys.

Returns
all known registree keys

Definition at line 117 of file Registry.h.

References rsc::misc::Registry< R >::mutex, and rsc::misc::Registry< R >::registreesByName.

template<class R>
boost::recursive_mutex* rsc::misc::Registry< R >::getMutex ( )
inline

Returns a recursive mutex that can be used to make multiple operations on this class atomic.

Returns
mutex internally used by this class

Definition at line 149 of file Registry.h.

References rsc::misc::Registry< R >::mutex.

template<class R>
boost::shared_ptr<R> rsc::misc::Registry< R >::getRegistree ( const std::string &  key)
inline

Returns the registree for the provided key.

Parameters
keykey of the registree
Returns
registree
Exceptions
std::invalid_argumentif there is no registree with this name

Definition at line 97 of file Registry.h.

References rsc::misc::Registry< R >::mutex, and rsc::misc::Registry< R >::registreesByName.

template<class R>
bool rsc::misc::Registry< R >::removeRegistree ( const std::string &  name)
inline

Removes a registree from this registry.

Use this with caution as many clients will assume that system configuration knowledge is static!

Parameters
namename of the registree to remove
Returns
true if a registree was removed, else false

Definition at line 138 of file Registry.h.

References rsc::misc::Registry< R >::mutex, and rsc::misc::Registry< R >::registreesByName.

Member Data Documentation

template<class R>
std::map<std::string, boost::shared_ptr<R> > rsc::misc::Registry< R >::registreesByName
private

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