******************************************************************************/
#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<String, Type::Ptr>::const_iterator it;
+ ScriptVariable::Ptr svtype = ScriptVariable::GetByName(name);
+
+ if (!svtype)
+ return Type::Ptr();
- it = GetTypes().find(name);
+ Value ptype = svtype->GetData();
- if (it == GetTypes().end())
+ if (!ptype.IsObjectType<Type>())
return Type::Ptr();
- return it->second;
+ return ptype;
}
Object::Ptr Type::Instantiate(void) const
protected:
virtual ObjectFactory GetFactory(void) const = 0;
-
-private:
- typedef std::map<String, Type::Ptr> TypeMap;
-
- static TypeMap& GetTypes(void);
};
template<typename T>