RSC
0.7.17
|
A templatized global registry. More...
#include <Registry.h>
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 |
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.
R | type to register called registree. |
Definition at line 58 of file Registry.h.
|
inline |
Definition at line 61 of file Registry.h.
|
inline |
Registers a new registree in the Registry.
This class takes over the ownership of the pointer and manages deleting the pointer when needed.
r | new registree to register |
errorDescription | optional string to add to the message of the exception which is raised when a registree with a same key already exists. |
std::invalid_argument | if 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.
|
inline |
Returns a set with all known registree keys.
Definition at line 117 of file Registry.h.
References rsc::misc::Registry< R >::mutex, and rsc::misc::Registry< R >::registreesByName.
|
inline |
Returns a recursive mutex that can be used to make multiple operations on this class atomic.
Definition at line 149 of file Registry.h.
References rsc::misc::Registry< R >::mutex.
|
inline |
Returns the registree for the provided key.
key | key of the registree |
std::invalid_argument | if 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.
|
inline |
Removes a registree from this registry.
Use this with caution as many clients will assume that system configuration knowledge is static!
name | name of the registree to remove |
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.
|
private |
Definition at line 155 of file Registry.h.
Referenced by rsc::misc::Registry< R >::addRegistree(), rsc::misc::Registry< R >::getKnownRegistryKeys(), rsc::misc::Registry< R >::getMutex(), rsc::misc::Registry< R >::getRegistree(), and rsc::misc::Registry< R >::removeRegistree().
|
private |
Definition at line 156 of file Registry.h.
Referenced by rsc::misc::Registry< R >::addRegistree(), rsc::misc::Registry< R >::getKnownRegistryKeys(), rsc::misc::Registry< R >::getRegistree(), and rsc::misc::Registry< R >::removeRegistree().