1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "base/i2-base.hpp"
7 #include "base/object.hpp"
8 #include "base/type.hpp"
9 #include "base/dictionary.hpp"
10 #include <boost/thread/mutex.hpp>
20 virtual ~ConfigType();
22 intrusive_ptr<ConfigObject> GetObject(const String& name) const;
24 void RegisterObject(const intrusive_ptr<ConfigObject>& object);
25 void UnregisterObject(const intrusive_ptr<ConfigObject>& object);
27 std::vector<intrusive_ptr<ConfigObject> > GetObjects() const;
30 static TypeImpl<T> *Get()
32 typedef TypeImpl<T> ObjType;
33 return static_cast<ObjType *>(T::TypeInstance.get());
37 static std::vector<intrusive_ptr<T> > GetObjectsByType()
39 std::vector<intrusive_ptr<ConfigObject> > objects = GetObjectsHelper(T::TypeInstance.get());
40 std::vector<intrusive_ptr<T> > result;
41 result.reserve(objects.size());
42 for (const auto& object : objects) {
43 result.push_back(static_pointer_cast<T>(object));
48 int GetObjectCount() const;
51 typedef std::map<String, intrusive_ptr<ConfigObject> > ObjectMap;
52 typedef std::vector<intrusive_ptr<ConfigObject> > ObjectVector;
54 mutable boost::mutex m_Mutex;
55 ObjectMap m_ObjectMap;
56 ObjectVector m_ObjectVector;
58 static std::vector<intrusive_ptr<ConfigObject> > GetObjectsHelper(Type *type);
63 #endif /* CONFIGTYPE_H */