summaryrefslogtreecommitdiff
path: root/project2/common/instanceStore.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-10-02 21:25:12 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-10-02 21:25:12 +0100
commitc9382a9c89ce03f1fcde3fadd294a3938b894e47 (patch)
tree7e5de1834f121b44f2485132741a6b3fe8431129 /project2/common/instanceStore.h
parentCompat fix (diff)
parentBig tidy up of loggers and logger factories (diff)
downloadproject2-c9382a9c89ce03f1fcde3fadd294a3938b894e47.tar.bz2
project2-c9382a9c89ce03f1fcde3fadd294a3938b894e47.tar.xz
project2-c9382a9c89ce03f1fcde3fadd294a3938b894e47.zip
Merge branch 'project2-adhoc-plugins'
Diffstat (limited to 'project2/common/instanceStore.h')
-rw-r--r--project2/common/instanceStore.h52
1 files changed, 0 insertions, 52 deletions
diff --git a/project2/common/instanceStore.h b/project2/common/instanceStore.h
deleted file mode 100644
index 4fd4519..0000000
--- a/project2/common/instanceStore.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef INSTANCESTORE_H
-#define INSTANCESTORE_H
-
-#include <boost/function.hpp>
-#include <set>
-#include <map>
-#include <safeMapFind.h>
-
-/// A static collection of any type, specifically with automatically cleaned up storage of a function static variable
-// which makes it safe to use in constructor functions.
-template <class Type, class StoreType>
-class InstanceStore {
- public:
- static const StoreType & GetAll();
- static void Add(const typename StoreType::value_type & p);
-
- protected:
- static void prune();
- static StoreType * & getInstances();
-};
-
-/// Keyed collection of instances
-template <class Type, class KeyType>
-class InstanceMap : public InstanceStore<Type, std::map<KeyType, boost::shared_ptr<Type>>> {
- public:
- typedef std::map<KeyType, boost::shared_ptr<Type>> Store;
- typedef InstanceStore<Type, std::map<KeyType, boost::shared_ptr<Type>>> IStore;
- typedef typename Store::value_type Value;
-
- static void Add(const KeyType & k, Type * p);
- static void Add(const KeyType & k, const boost::shared_ptr<Type> & p);
- static void Remove(const KeyType &);
-
- template <class E> static boost::shared_ptr<Type> Get(const KeyType & n)
- {
- return AdHoc::safeMapLookup<E>(InstanceStore<Type, Store>::GetAll(), n);
- }
-
- static void OnEach(const boost::function<void(const Value &)> & func);
-};
-
-/// Anonymous collection of instances
-template <class Type>
-class InstanceSet : public InstanceStore<Type, std::set<boost::shared_ptr<Type>>> {
- public:
- typedef InstanceStore<Type, std::set<boost::shared_ptr<Type>>> IStore;
- static void OnAll(const boost::function<void(Type *)> & func);
- static void Remove(const boost::shared_ptr<Type> &);
-};
-
-#endif
-