35 #include <boost/noncopyable.hpp>
36 #include <boost/shared_ptr.hpp>
37 #include <boost/static_assert.hpp>
38 #include <boost/thread/recursive_mutex.hpp>
40 #include "rsc/config.h"
41 #include "rsc/rscexports.h"
76 void addRegistree(R* r,
const std::string& errorDescription =
"") {
78 boost::recursive_mutex::scoped_lock lock(
mutex);
81 throw std::invalid_argument(
82 "There already is a registree with key '"
83 + r->getRegistryKey() +
"'. " + errorDescription);
99 boost::recursive_mutex::scoped_lock lock(
mutex);
101 typename std::map<std::string, boost::shared_ptr<R> >::const_iterator it =
104 throw std::invalid_argument(
105 "There is no registree with key '" + key +
"'.");
119 boost::recursive_mutex::scoped_lock lock(
mutex);
121 std::set<std::string> keys;
122 typename std::map<std::string, boost::shared_ptr<R> >::const_iterator it;
125 keys.insert(it->first);
139 boost::recursive_mutex::scoped_lock lock(
mutex);
173 #define CREATE_GLOBAL_REGISTREE(registry, registree, uniqueName) \
174 class Starter##uniqueName { \
176 Starter##uniqueName() { \
177 (registry)->addRegistree(registree); \
180 Starter##uniqueName uniqueName##Starter;
196 #define CREATE_GLOBAL_REGISTREE_MSG(registry, registree, uniqueName, msg) \
197 class Starter##uniqueName { \
199 Starter##uniqueName() { \
200 (registry)->addRegistree(registree, msg); \
203 Starter##uniqueName uniqueName##Starter;
std::map< std::string, boost::shared_ptr< R > > registreesByName
boost::recursive_mutex * getMutex()
Returns a recursive mutex that can be used to make multiple operations on this class atomic...
boost::recursive_mutex mutex
bool removeRegistree(const std::string &name)
Removes a registree from this registry.
A templatized global registry.
boost::shared_ptr< R > getRegistree(const std::string &key)
Returns the registree for the provided key.
void addRegistree(R *r, const std::string &errorDescription="")
Registers a new registree in the Registry.
std::set< std::string > getKnownRegistryKeys()
Returns a set with all known registree keys.