exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp
json-script.cpp loader.cpp logger.cpp logger.thpp math-script.cpp
netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp
- object-script.cpp primitivetype.cpp process.cpp ringbuffer.cpp scriptframe.cpp
+ object-script.cpp objecttype.cpp primitivetype.cpp process.cpp ringbuffer.cpp scriptframe.cpp
function.cpp function-script.cpp functionwrapper.cpp scriptglobal.cpp
scriptutils.cpp serializer.cpp socket.cpp socketevents.cpp stacktrace.cpp
statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp string-script.cpp
ConfigType::Ptr ConfigObject::GetType(void) const
{
- return ConfigType::GetByName(GetTypeNameV());
+ return ConfigType::GetByName(GetReflectionType()->GetName());
}
bool ConfigObject::IsActive(void) const
return m_ShortName;
}}}
};
- [config, get_protected, no_user_modify] String type (TypeNameV);
[config] name(Zone) zone (ZoneName);
[config, no_user_modify] String package;
[config, get_protected, no_user_modify] Array::Ptr templates;
using namespace icinga;
-REGISTER_PRIMITIVE_TYPE(Object, None, Object::GetPrototype());
+DEFINE_TYPE_INSTANCE(Object);
/**
* Default constructor for the Object class.
void Object::SetField(int id, const Value&, bool, const Value&)
{
if (id == 0)
- BOOST_THROW_EXCEPTION(std::runtime_error("Prototype field cannot be set."));
+ BOOST_THROW_EXCEPTION(std::runtime_error("Type field cannot be set."));
else
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
}
Value Object::GetField(int id) const
{
if (id == 0)
- return Empty;
+ return GetReflectionType()->GetName();
else
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
}
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software Foundation *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ******************************************************************************/
+
+#include "base/objecttype.hpp"
+#include "base/initialize.hpp"
+
+using namespace icinga;
+
+static void RegisterObjectType(void)
+{
+ Type::Ptr type = new ObjectType();
+ type->SetPrototype(Object::GetPrototype());
+ Type::Register(type);
+ Object::TypeInstance = type;
+}
+
+INITIALIZE_ONCE(&RegisterObjectType);
+
+ObjectType::ObjectType(void)
+{ }
+
+String ObjectType::GetName(void) const
+{
+ return "Object";
+}
+
+Type::Ptr ObjectType::GetBaseType(void) const
+{
+ return Type::Ptr();
+}
+
+int ObjectType::GetAttributes(void) const
+{
+ return 0;
+}
+
+int ObjectType::GetFieldId(const String& name) const
+{
+ if (name == "type")
+ return 0;
+ else
+ return -1;
+}
+
+Field ObjectType::GetFieldInfo(int id) const
+{
+ if (id == 0)
+ return Field(1, "String", "type", NULL, NULL, 0, 0);
+ else
+ BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
+}
+
+int ObjectType::GetFieldCount(void) const
+{
+ return 1;
+}
+
+ObjectFactory ObjectType::GetFactory(void) const
+{
+ return DefaultObjectFactory<Object>;
+}
+
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software Foundation *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ******************************************************************************/
+
+#ifndef OBJECTTYPE_H
+#define OBJECTTYPE_H
+
+#include "base/i2-base.hpp"
+#include "base/type.hpp"
+#include "base/initialize.hpp"
+
+namespace icinga
+{
+
+class I2_BASE_API ObjectType : public Type
+{
+public:
+ ObjectType(void);
+
+ virtual String GetName(void) const override;
+ virtual Type::Ptr GetBaseType(void) const override;
+ virtual int GetAttributes(void) const override;
+ virtual int GetFieldId(const String& name) const override;
+ virtual Field GetFieldInfo(int id) const override;
+ virtual int GetFieldCount(void) const override;
+
+protected:
+ virtual ObjectFactory GetFactory(void) const override;
+};
+
+}
+
+#endif /* OBJECTTYPE_H */
if (vm.count("sandbox"))
scriptFrame.Sandboxed = true;
+ scriptFrame.Self = scriptFrame.Locals;
+
if (!vm.count("eval"))
std::cout << "Icinga 2 (version: " << Application::GetAppVersion() << ")\n";
ConfigObject::Ptr dobj = static_pointer_cast<ConfigObject>(type->Instantiate());
dobj->SetDebugInfo(m_DebugInfo);
- dobj->SetTypeNameV(m_Type);
dobj->SetZoneName(m_Zone);
dobj->SetPackage(m_Package);
dobj->SetName(m_Name);