mirror of https://github.com/Icinga/icinga2.git
parent
a3fd33f8a1
commit
701961b73b
|
@ -30,7 +30,7 @@ set(base_SOURCES
|
|||
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
|
||||
|
|
|
@ -53,7 +53,7 @@ ConfigObject::ConfigObject(void)
|
|||
|
||||
ConfigType::Ptr ConfigObject::GetType(void) const
|
||||
{
|
||||
return ConfigType::GetByName(GetTypeNameV());
|
||||
return ConfigType::GetByName(GetReflectionType()->GetName());
|
||||
}
|
||||
|
||||
bool ConfigObject::IsActive(void) const
|
||||
|
|
|
@ -77,7 +77,6 @@ abstract class ConfigObject : ConfigObjectBase
|
|||
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;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_PRIMITIVE_TYPE(Object, None, Object::GetPrototype());
|
||||
DEFINE_TYPE_INSTANCE(Object);
|
||||
|
||||
/**
|
||||
* Default constructor for the Object class.
|
||||
|
@ -79,7 +79,7 @@ void Object::InflateMutex(void)
|
|||
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."));
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void Object::SetField(int id, const Value&, bool, const Value&)
|
|||
Value Object::GetField(int id) const
|
||||
{
|
||||
if (id == 0)
|
||||
return Empty;
|
||||
return GetReflectionType()->GetName();
|
||||
else
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/******************************************************************************
|
||||
* 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>;
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/******************************************************************************
|
||||
* 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 */
|
|
@ -135,6 +135,8 @@ int ConsoleCommand::Run(const po::variables_map& vm, const std::vector<std::stri
|
|||
if (vm.count("sandbox"))
|
||||
scriptFrame.Sandboxed = true;
|
||||
|
||||
scriptFrame.Self = scriptFrame.Locals;
|
||||
|
||||
if (!vm.count("eval"))
|
||||
std::cout << "Icinga 2 (version: " << Application::GetAppVersion() << ")\n";
|
||||
|
||||
|
|
|
@ -174,7 +174,6 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue