#include "base/json.hpp"
#include "base/logger.hpp"
#include "base/objectlock.hpp"
+#include "base/dynamictype.hpp"
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <algorithm>
REGISTER_SCRIPTFUNCTION(typeof, &ScriptUtils::TypeOf);
REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys);
REGISTER_SCRIPTFUNCTION(random, &Utility::Random);
+REGISTER_SCRIPTFUNCTION(__get_object, &ScriptUtils::GetObject);
bool ScriptUtils::Regex(const String& pattern, const String& text)
{
return result;
}
+DynamicObject::Ptr ScriptUtils::GetObject(const String& type, const String& name)
+{
+ DynamicType::Ptr dtype = DynamicType::GetByName(type);
+
+ if (!dtype)
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name"));
+
+ return dtype->GetObject(name);
+}
+
#include "base/array.hpp"
#include "base/dictionary.hpp"
#include "base/type.hpp"
+#include "base/dynamicobject.hpp"
namespace icinga
{
static void Exit(int code);
static Type::Ptr TypeOf(const Value& value);
static Array::Ptr Keys(const Dictionary::Ptr& dict);
+ static DynamicObject::Ptr GetObject(const String& type, const String& name);
private:
ScriptUtils(void);