diff --git a/lib/base/type.cpp b/lib/base/type.cpp index e1e933678..1ca108cd7 100644 --- a/lib/base/type.cpp +++ b/lib/base/type.cpp @@ -18,33 +18,30 @@ ******************************************************************************/ #include "base/type.hpp" +#include "base/scriptvariable.hpp" using namespace icinga; -Type::TypeMap& Type::GetTypes(void) -{ - static TypeMap types; - - return types; -} - void Type::Register(const Type::Ptr& type) { VERIFY(GetByName(type->GetName()) == NULL); - GetTypes()[type->GetName()] = type; + ScriptVariable::Set(type->GetName(), type, true, true); } Type::Ptr Type::GetByName(const String& name) { - std::map::const_iterator it; + ScriptVariable::Ptr svtype = ScriptVariable::GetByName(name); - it = GetTypes().find(name); - - if (it == GetTypes().end()) + if (!svtype) return Type::Ptr(); - return it->second; + Value ptype = svtype->GetData(); + + if (!ptype.IsObjectType()) + return Type::Ptr(); + + return ptype; } Object::Ptr Type::Instantiate(void) const diff --git a/lib/base/type.hpp b/lib/base/type.hpp index 2ae185478..065411361 100644 --- a/lib/base/type.hpp +++ b/lib/base/type.hpp @@ -78,11 +78,6 @@ public: protected: virtual ObjectFactory GetFactory(void) const = 0; - -private: - typedef std::map TypeMap; - - static TypeMap& GetTypes(void); }; template