aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/ObjectRegistry.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/ObjectRegistry.hh')
-rw-r--r--src/FbTk/ObjectRegistry.hh63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/FbTk/ObjectRegistry.hh b/src/FbTk/ObjectRegistry.hh
deleted file mode 100644
index 4f47b77..0000000
--- a/src/FbTk/ObjectRegistry.hh
+++ /dev/null
@@ -1,63 +0,0 @@
1// ObjectRegistry.hh for FbTk
2// Copyright (c) 2007 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#ifndef OBJECTREGISTRY_HH
23#define OBJECTREGISTRY_HH
24
25#include <map>
26#include <string>
27
28namespace FbTk {
29
30template <typename Creator>
31class ObjectRegistry {
32public:
33 typedef std::map<std::string, Creator> CreatorMap;
34
35 static ObjectRegistry<Creator> &instance() {
36 static ObjectRegistry<Creator> s_instance;
37 return s_instance;
38 }
39
40 Creator lookup(const std::string &name) {
41 typename CreatorMap::const_iterator it = m_creators.find(name);
42 if (it == m_creators.end())
43 return 0;
44 return it->second;
45 }
46
47 bool registerObject(const std::string &name, Creator creator) {
48 m_creators[name] = creator;
49 return true;
50 }
51
52 const CreatorMap creatorMap() const { return m_creators; }
53
54private:
55 ObjectRegistry() {}
56 ~ObjectRegistry() {}
57
58 CreatorMap m_creators;
59};
60
61} // end namespace FbTk
62
63#endif // OBJECTREGISTRY_HH