mirror of https://github.com/Icinga/icinga2.git
commit
a95a0985b7
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(CheckerComponent);
|
|
||||||
REGISTER_TYPE(CheckerComponent);
|
REGISTER_TYPE(CheckerComponent);
|
||||||
|
|
||||||
void CheckerComponent::Start(void)
|
void CheckerComponent::Start(void)
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(ClusterListener);
|
|
||||||
REGISTER_TYPE(ClusterListener);
|
REGISTER_TYPE(ClusterListener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Endpoint);
|
|
||||||
REGISTER_TYPE(Endpoint);
|
REGISTER_TYPE(Endpoint);
|
||||||
|
|
||||||
boost::signals2::signal<void (const Endpoint::Ptr&)> Endpoint::OnConnected;
|
boost::signals2::signal<void (const Endpoint::Ptr&)> Endpoint::OnConnected;
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(CheckResultReader);
|
|
||||||
REGISTER_TYPE(CheckResultReader);
|
REGISTER_TYPE(CheckResultReader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(CompatLogger);
|
|
||||||
REGISTER_TYPE(CompatLogger);
|
REGISTER_TYPE(CompatLogger);
|
||||||
REGISTER_SCRIPTFUNCTION(ValidateRotationMethod, &CompatLogger::ValidateRotationMethod);
|
REGISTER_SCRIPTFUNCTION(ValidateRotationMethod, &CompatLogger::ValidateRotationMethod);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(ExternalCommandListener);
|
|
||||||
REGISTER_TYPE(ExternalCommandListener);
|
REGISTER_TYPE(ExternalCommandListener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(StatusDataWriter);
|
|
||||||
REGISTER_TYPE(StatusDataWriter);
|
REGISTER_TYPE(StatusDataWriter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(IdoMysqlConnection);
|
|
||||||
REGISTER_TYPE(IdoMysqlConnection);
|
REGISTER_TYPE(IdoMysqlConnection);
|
||||||
|
|
||||||
#define SCHEMA_VERSION "1.10.0"
|
#define SCHEMA_VERSION "1.10.0"
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(IdoPgsqlConnection);
|
|
||||||
REGISTER_TYPE(IdoPgsqlConnection);
|
REGISTER_TYPE(IdoPgsqlConnection);
|
||||||
|
|
||||||
#define SCHEMA_VERSION "1.10.0"
|
#define SCHEMA_VERSION "1.10.0"
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Demo);
|
|
||||||
REGISTER_TYPE(Demo);
|
REGISTER_TYPE(Demo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
using namespace livestatus;
|
using namespace livestatus;
|
||||||
|
|
||||||
REGISTER_NTYPE(LivestatusListener);
|
|
||||||
REGISTER_TYPE(LivestatusListener);
|
REGISTER_TYPE(LivestatusListener);
|
||||||
REGISTER_SCRIPTFUNCTION(ValidateSocketType, &LivestatusListener::ValidateSocketType);
|
REGISTER_SCRIPTFUNCTION(ValidateSocketType, &LivestatusListener::ValidateSocketType);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(NotificationComponent);
|
|
||||||
REGISTER_TYPE(NotificationComponent);
|
REGISTER_TYPE(NotificationComponent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(GraphiteWriter);
|
|
||||||
REGISTER_TYPE(GraphiteWriter);
|
REGISTER_TYPE(GraphiteWriter);
|
||||||
|
|
||||||
void GraphiteWriter::Start(void)
|
void GraphiteWriter::Start(void)
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(PerfdataWriter);
|
|
||||||
REGISTER_TYPE(PerfdataWriter);
|
REGISTER_TYPE(PerfdataWriter);
|
||||||
|
|
||||||
void PerfdataWriter::Start(void)
|
void PerfdataWriter::Start(void)
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Application);
|
REGISTER_TYPE(Application);
|
||||||
|
|
||||||
Application *Application::m_Instance = NULL;
|
Application *Application::m_Instance = NULL;
|
||||||
bool Application::m_ShuttingDown = false;
|
bool Application::m_ShuttingDown = false;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(ConsoleLogger);
|
|
||||||
REGISTER_TYPE(ConsoleLogger);
|
REGISTER_TYPE(ConsoleLogger);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(DynamicObject);
|
REGISTER_TYPE(DynamicObject);
|
||||||
|
|
||||||
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStarted;
|
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStarted;
|
||||||
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStopped;
|
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnStopped;
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
DynamicType::DynamicType(const String& name, const DynamicType::ObjectFactory& factory)
|
DynamicType::DynamicType(const String& name)
|
||||||
: m_Name(name), m_ObjectFactory(factory)
|
: m_Name(name)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
DynamicType::Ptr DynamicType::GetByName(const String& name)
|
DynamicType::Ptr DynamicType::GetByName(const String& name)
|
||||||
|
@ -34,8 +34,20 @@ DynamicType::Ptr DynamicType::GetByName(const String& name)
|
||||||
|
|
||||||
DynamicType::TypeMap::const_iterator tt = InternalGetTypeMap().find(name);
|
DynamicType::TypeMap::const_iterator tt = InternalGetTypeMap().find(name);
|
||||||
|
|
||||||
if (tt == InternalGetTypeMap().end())
|
if (tt == InternalGetTypeMap().end()) {
|
||||||
return DynamicType::Ptr();
|
const Type *type = Type::GetByName(name);
|
||||||
|
|
||||||
|
if (!type || !Type::GetByName("DynamicObject")->IsAssignableFrom(type)
|
||||||
|
|| type->IsAbstract())
|
||||||
|
return DynamicType::Ptr();
|
||||||
|
|
||||||
|
DynamicType::Ptr dtype = make_shared<DynamicType>(name);
|
||||||
|
|
||||||
|
InternalGetTypeMap()[type->GetName()] = dtype;
|
||||||
|
InternalGetTypeVector().push_back(dtype);
|
||||||
|
|
||||||
|
return dtype;
|
||||||
|
}
|
||||||
|
|
||||||
return tt->second;
|
return tt->second;
|
||||||
}
|
}
|
||||||
|
@ -112,36 +124,17 @@ DynamicObject::Ptr DynamicType::GetObject(const String& name) const
|
||||||
return nt->second;
|
return nt->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicType::RegisterType(const DynamicType::Ptr& type)
|
|
||||||
{
|
|
||||||
boost::mutex::scoped_lock lock(GetStaticMutex());
|
|
||||||
|
|
||||||
DynamicType::TypeMap::const_iterator tt = InternalGetTypeMap().find(type->GetName());
|
|
||||||
|
|
||||||
if (tt != InternalGetTypeMap().end())
|
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Cannot register class for type '" +
|
|
||||||
type->GetName() + "': Objects of this type already exist."));
|
|
||||||
|
|
||||||
InternalGetTypeMap()[type->GetName()] = type;
|
|
||||||
InternalGetTypeVector().push_back(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUpdate)
|
DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUpdate)
|
||||||
{
|
{
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
ObjectFactory factory;
|
const Type *type = Type::GetByName(m_Name);
|
||||||
|
|
||||||
{
|
Object::Ptr object = type->Instantiate();
|
||||||
ObjectLock olock(this);
|
|
||||||
factory = m_ObjectFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicObject::Ptr object = factory();
|
|
||||||
|
|
||||||
Deserialize(object, serializedUpdate, FAConfig);
|
Deserialize(object, serializedUpdate, FAConfig);
|
||||||
|
|
||||||
return object;
|
return dynamic_pointer_cast<DynamicObject>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::mutex& DynamicType::GetStaticMutex(void)
|
boost::mutex& DynamicType::GetStaticMutex(void)
|
||||||
|
|
|
@ -36,16 +36,12 @@ class I2_BASE_API DynamicType : public Object
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(DynamicType);
|
DECLARE_PTR_TYPEDEFS(DynamicType);
|
||||||
|
|
||||||
typedef boost::function<DynamicObject::Ptr (void)> ObjectFactory;
|
DynamicType(const String& name);
|
||||||
|
|
||||||
DynamicType(const String& name, const ObjectFactory& factory);
|
|
||||||
|
|
||||||
String GetName(void) const;
|
String GetName(void) const;
|
||||||
|
|
||||||
static DynamicType::Ptr GetByName(const String& name);
|
static DynamicType::Ptr GetByName(const String& name);
|
||||||
|
|
||||||
static void RegisterType(const DynamicType::Ptr& type);
|
|
||||||
|
|
||||||
DynamicObject::Ptr CreateObject(const Dictionary::Ptr& serializedUpdate);
|
DynamicObject::Ptr CreateObject(const Dictionary::Ptr& serializedUpdate);
|
||||||
DynamicObject::Ptr GetObject(const String& name) const;
|
DynamicObject::Ptr GetObject(const String& name) const;
|
||||||
|
|
||||||
|
@ -72,7 +68,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_Name;
|
String m_Name;
|
||||||
ObjectFactory m_ObjectFactory;
|
|
||||||
|
|
||||||
typedef std::map<String, DynamicObject::Ptr, string_iless> ObjectMap;
|
typedef std::map<String, DynamicObject::Ptr, string_iless> ObjectMap;
|
||||||
typedef std::vector<DynamicObject::Ptr> ObjectVector;
|
typedef std::vector<DynamicObject::Ptr> ObjectVector;
|
||||||
|
@ -90,46 +85,6 @@ private:
|
||||||
static std::vector<DynamicObject::Ptr> GetObjects(const String& type);
|
static std::vector<DynamicObject::Ptr> GetObjects(const String& type);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A registry for DynamicType objects.
|
|
||||||
*
|
|
||||||
* @ingroup base
|
|
||||||
*/
|
|
||||||
class DynamicTypeRegistry : public Registry<DynamicTypeRegistry, DynamicType::Ptr>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper class for registering DynamicObject implementation classes.
|
|
||||||
*
|
|
||||||
* @ingroup base
|
|
||||||
*/
|
|
||||||
class RegisterTypeHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RegisterTypeHelper(const String& name, const DynamicType::ObjectFactory& factory)
|
|
||||||
{
|
|
||||||
DynamicType::Ptr type = make_shared<DynamicType>(name, factory);
|
|
||||||
DynamicType::RegisterType(type);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory function for DynamicObject-based classes.
|
|
||||||
*
|
|
||||||
* @ingroup base
|
|
||||||
*/
|
|
||||||
template<typename T>
|
|
||||||
shared_ptr<T> DynamicObjectFactory(void)
|
|
||||||
{
|
|
||||||
return make_shared<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define REGISTER_TYPE_ALIAS(type, alias) \
|
|
||||||
I2_EXPORT icinga::RegisterTypeHelper g_RegisterDT_ ## type(alias, DynamicObjectFactory<type>);
|
|
||||||
|
|
||||||
#define REGISTER_TYPE(type) \
|
|
||||||
REGISTER_TYPE_ALIAS(type, #type)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* DYNAMICTYPE_H */
|
#endif /* DYNAMICTYPE_H */
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(FileLogger);
|
|
||||||
REGISTER_TYPE(FileLogger);
|
REGISTER_TYPE(FileLogger);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,8 +34,10 @@ inline bool InitializeOnceHelper(InitializeFunc func)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INITIALIZE_ONCE(name, func) \
|
#define INITIALIZE_ONCE(func) \
|
||||||
I2_EXPORT bool l_InitializeOnce ## name(InitializeOnceHelper(func))
|
namespace { \
|
||||||
|
I2_EXPORT bool l_InitializeOnce(InitializeOnceHelper(func)); \
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Logger);
|
REGISTER_TYPE(Logger);
|
||||||
|
|
||||||
std::set<Logger::Ptr> Logger::m_Loggers;
|
std::set<Logger::Ptr> Logger::m_Loggers;
|
||||||
boost::mutex Logger::m_Mutex;
|
boost::mutex Logger::m_Mutex;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Script);
|
|
||||||
REGISTER_TYPE(Script);
|
REGISTER_TYPE(Script);
|
||||||
|
|
||||||
void Script::Start(void)
|
void Script::Start(void)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(StreamLogger);
|
REGISTER_TYPE(StreamLogger);
|
||||||
|
|
||||||
boost::mutex StreamLogger::m_Mutex;
|
boost::mutex StreamLogger::m_Mutex;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(SyslogLogger);
|
|
||||||
REGISTER_TYPE(SyslogLogger);
|
REGISTER_TYPE(SyslogLogger);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,9 +54,10 @@ Object::Ptr Type::Instantiate(void) const
|
||||||
|
|
||||||
bool Type::IsAssignableFrom(const Type *other) const
|
bool Type::IsAssignableFrom(const Type *other) const
|
||||||
{
|
{
|
||||||
for (const Type *t = other; t; t = t->GetBaseType())
|
for (const Type *t = other; t; t = t->GetBaseType()) {
|
||||||
if (t == this)
|
if (t == this)
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,6 @@ class TypeImpl
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
Type *GetType(void)
|
|
||||||
{
|
|
||||||
return TypeImpl<T>::GetInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
shared_ptr<T> ObjectFactory(void)
|
shared_ptr<T> ObjectFactory(void)
|
||||||
{
|
{
|
||||||
|
@ -95,16 +89,16 @@ struct FactoryHelper
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REGISTER_NTYPE(type) \
|
#define REGISTER_TYPE(type) \
|
||||||
namespace { \
|
namespace { \
|
||||||
void RegisterType(void) \
|
void RegisterType(void) \
|
||||||
{ \
|
{ \
|
||||||
icinga::Type *t = icinga::GetType<type>(); \
|
icinga::Type *t = new TypeImpl<type>(); \
|
||||||
t->SetFactory(FactoryHelper<type>().GetFactory()); \
|
t->SetFactory(FactoryHelper<type>().GetFactory()); \
|
||||||
icinga::Type::Register(GetType<type>()); \
|
icinga::Type::Register(t); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
INITIALIZE_ONCE(type, RegisterType); \
|
INITIALIZE_ONCE(RegisterType); \
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,19 @@ ValueType Value::GetType(void) const
|
||||||
return static_cast<ValueType>(m_Value.which());
|
return static_cast<ValueType>(m_Value.which());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Value::operator==(bool rhs)
|
||||||
|
{
|
||||||
|
if (!IsScalar())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return static_cast<double>(*this) == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Value::operator!=(bool rhs)
|
||||||
|
{
|
||||||
|
return !(*this == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
bool Value::operator==(int rhs)
|
bool Value::operator==(int rhs)
|
||||||
{
|
{
|
||||||
if (!IsScalar())
|
if (!IsScalar())
|
||||||
|
|
|
@ -73,6 +73,9 @@ public:
|
||||||
operator double(void) const;
|
operator double(void) const;
|
||||||
operator String(void) const;
|
operator String(void) const;
|
||||||
|
|
||||||
|
bool operator==(bool rhs);
|
||||||
|
bool operator!=(bool rhs);
|
||||||
|
|
||||||
bool operator==(int rhs);
|
bool operator==(int rhs);
|
||||||
bool operator!=(int rhs);
|
bool operator!=(int rhs);
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(DbConnection);
|
REGISTER_TYPE(DbConnection);
|
||||||
|
|
||||||
Timer::Ptr DbConnection::m_ProgramStatusTimer;
|
Timer::Ptr DbConnection::m_ProgramStatusTimer;
|
||||||
|
|
||||||
INITIALIZE_ONCE(DbConnection, &DbConnection::StaticInitialize);
|
INITIALIZE_ONCE(&DbConnection::StaticInitialize);
|
||||||
|
|
||||||
void DbConnection::Start(void)
|
void DbConnection::Start(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ using namespace icinga;
|
||||||
|
|
||||||
boost::signals2::signal<void (const DbQuery&)> DbObject::OnQuery;
|
boost::signals2::signal<void (const DbQuery&)> DbObject::OnQuery;
|
||||||
|
|
||||||
INITIALIZE_ONCE(DbObject, &DbObject::StaticInitialize);
|
INITIALIZE_ONCE(&DbObject::StaticInitialize);
|
||||||
|
|
||||||
DbObject::DbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2)
|
DbObject::DbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2)
|
||||||
: m_Name1(name1), m_Name2(name2), m_Type(type), m_LastConfigUpdate(0), m_LastStatusUpdate(0)
|
: m_Name1(name1), m_Name2(name2), m_Type(type), m_LastConfigUpdate(0), m_LastStatusUpdate(0)
|
||||||
|
|
|
@ -38,7 +38,7 @@ using namespace icinga;
|
||||||
|
|
||||||
REGISTER_DBTYPE(Service, "service", DbObjectTypeService, "service_object_id", ServiceDbObject);
|
REGISTER_DBTYPE(Service, "service", DbObjectTypeService, "service_object_id", ServiceDbObject);
|
||||||
|
|
||||||
INITIALIZE_ONCE(ServiceDbObject, &ServiceDbObject::StaticInitialize);
|
INITIALIZE_ONCE(&ServiceDbObject::StaticInitialize);
|
||||||
|
|
||||||
void ServiceDbObject::StaticInitialize(void)
|
void ServiceDbObject::StaticInitialize(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Hello);
|
|
||||||
REGISTER_TYPE(Hello);
|
REGISTER_TYPE(Hello);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(CheckCommand);
|
|
||||||
REGISTER_TYPE(CheckCommand);
|
REGISTER_TYPE(CheckCommand);
|
||||||
|
|
||||||
Dictionary::Ptr CheckCommand::Execute(const Service::Ptr& service)
|
Dictionary::Ptr CheckCommand::Execute(const Service::Ptr& service)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Command);
|
REGISTER_TYPE(Command);
|
||||||
|
|
||||||
bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Domain);
|
|
||||||
REGISTER_TYPE(Domain);
|
REGISTER_TYPE(Domain);
|
||||||
|
|
||||||
int Domain::GetPrivileges(const String& instance) const
|
int Domain::GetPrivileges(const String& instance) const
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(EventCommand);
|
|
||||||
REGISTER_TYPE(EventCommand);
|
REGISTER_TYPE(EventCommand);
|
||||||
|
|
||||||
void EventCommand::Execute(const Service::Ptr& service)
|
void EventCommand::Execute(const Service::Ptr& service)
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Host);
|
|
||||||
REGISTER_TYPE(Host);
|
REGISTER_TYPE(Host);
|
||||||
|
|
||||||
void Host::Start(void)
|
void Host::Start(void)
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(HostGroup);
|
|
||||||
REGISTER_TYPE(HostGroup);
|
REGISTER_TYPE(HostGroup);
|
||||||
|
|
||||||
std::set<Host::Ptr> HostGroup::GetMembers(void) const
|
std::set<Host::Ptr> HostGroup::GetMembers(void) const
|
||||||
|
|
|
@ -32,9 +32,8 @@ using namespace icinga;
|
||||||
|
|
||||||
static Timer::Ptr l_RetentionTimer;
|
static Timer::Ptr l_RetentionTimer;
|
||||||
|
|
||||||
REGISTER_NTYPE(IcingaApplication);
|
|
||||||
REGISTER_TYPE(IcingaApplication);
|
REGISTER_TYPE(IcingaApplication);
|
||||||
INITIALIZE_ONCE(IcingaApplication, &IcingaApplication::StaticInitialize);
|
INITIALIZE_ONCE(&IcingaApplication::StaticInitialize);
|
||||||
|
|
||||||
void IcingaApplication::StaticInitialize(void)
|
void IcingaApplication::StaticInitialize(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Notification);
|
|
||||||
REGISTER_TYPE(Notification);
|
REGISTER_TYPE(Notification);
|
||||||
|
|
||||||
boost::signals2::signal<void (const Notification::Ptr&, double, const String&)> Notification::OnNextNotificationChanged;
|
boost::signals2::signal<void (const Notification::Ptr&, double, const String&)> Notification::OnNextNotificationChanged;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(NotificationCommand);
|
|
||||||
REGISTER_TYPE(NotificationCommand);
|
REGISTER_TYPE(NotificationCommand);
|
||||||
|
|
||||||
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
|
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012-2013 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 "icinga/perfdatavalue.h"
|
#include "icinga/perfdatavalue.h"
|
||||||
#include "base/convert.h"
|
#include "base/convert.h"
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
|
@ -6,7 +25,7 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(PerfdataValue);
|
REGISTER_TYPE(PerfdataValue);
|
||||||
|
|
||||||
PerfdataValue::PerfdataValue(void)
|
PerfdataValue::PerfdataValue(void)
|
||||||
{ }
|
{ }
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Icinga 2 *
|
||||||
|
* Copyright (C) 2012-2013 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 PERFDATAVALUE_H
|
#ifndef PERFDATAVALUE_H
|
||||||
#define PERFDATAVALUE_H
|
#define PERFDATAVALUE_H
|
||||||
|
|
||||||
|
|
|
@ -58,4 +58,4 @@ void Service::ExecuteEventHandler(void)
|
||||||
ec->Execute(GetSelf());
|
ec->Execute(GetSelf());
|
||||||
|
|
||||||
OnEventCommandExecuted(GetSelf());
|
OnEventCommandExecuted(GetSelf());
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(Service);
|
|
||||||
REGISTER_TYPE(Service);
|
REGISTER_TYPE(Service);
|
||||||
|
|
||||||
boost::signals2::signal<void (const Service::Ptr&, const String&, const String&, AcknowledgementType, double, const String&)> Service::OnAcknowledgementSet;
|
boost::signals2::signal<void (const Service::Ptr&, const String&, const String&, AcknowledgementType, double, const String&)> Service::OnAcknowledgementSet;
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(ServiceGroup);
|
|
||||||
REGISTER_TYPE(ServiceGroup);
|
REGISTER_TYPE(ServiceGroup);
|
||||||
|
|
||||||
std::set<Service::Ptr> ServiceGroup::GetMembers(void) const
|
std::set<Service::Ptr> ServiceGroup::GetMembers(void) const
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(TimePeriod);
|
|
||||||
REGISTER_TYPE(TimePeriod);
|
REGISTER_TYPE(TimePeriod);
|
||||||
REGISTER_SCRIPTFUNCTION(EmptyTimePeriod, &TimePeriod::EmptyTimePeriodUpdate);
|
REGISTER_SCRIPTFUNCTION(EmptyTimePeriod, &TimePeriod::EmptyTimePeriodUpdate);
|
||||||
REGISTER_SCRIPTFUNCTION(EvenMinutesTimePeriod, &TimePeriod::EvenMinutesTimePeriodUpdate);
|
REGISTER_SCRIPTFUNCTION(EvenMinutesTimePeriod, &TimePeriod::EvenMinutesTimePeriodUpdate);
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(User);
|
|
||||||
REGISTER_TYPE(User);
|
REGISTER_TYPE(User);
|
||||||
|
|
||||||
void User::OnConfigLoaded(void)
|
void User::OnConfigLoaded(void)
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_NTYPE(UserGroup);
|
|
||||||
REGISTER_TYPE(UserGroup);
|
REGISTER_TYPE(UserGroup);
|
||||||
|
|
||||||
std::set<User::Ptr> UserGroup::GetMembers(void) const
|
std::set<User::Ptr> UserGroup::GetMembers(void) const
|
||||||
|
|
|
@ -47,6 +47,10 @@ add_boost_test(base
|
||||||
base_object/construct
|
base_object/construct
|
||||||
base_object/getself
|
base_object/getself
|
||||||
base_object/weak
|
base_object/weak
|
||||||
|
base_serialize/scalar
|
||||||
|
base_serialize/array
|
||||||
|
base_serialize/dictionary
|
||||||
|
base_serialize/object
|
||||||
base_shellescape/escape_basic
|
base_shellescape/escape_basic
|
||||||
base_shellescape/escape_quoted
|
base_shellescape/escape_quoted
|
||||||
base_stacktrace/stacktrace
|
base_stacktrace/stacktrace
|
||||||
|
|
|
@ -43,11 +43,8 @@ BOOST_AUTO_TEST_CASE(todouble)
|
||||||
BOOST_AUTO_TEST_CASE(tostring)
|
BOOST_AUTO_TEST_CASE(tostring)
|
||||||
{
|
{
|
||||||
BOOST_CHECK(Convert::ToString(7) == "7");
|
BOOST_CHECK(Convert::ToString(7) == "7");
|
||||||
BOOST_CHECK(Convert::ToString(7.3) == "7.3");
|
BOOST_CHECK(Convert::ToString(7.5) == "7.5");
|
||||||
BOOST_CHECK(Convert::ToString("hello") == "hello");
|
BOOST_CHECK(Convert::ToString("hello") == "hello");
|
||||||
|
|
||||||
Object::Ptr object = make_shared<Object>();
|
|
||||||
BOOST_CHECK(Convert::ToString(object) == "Object of type 'icinga::Object'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(tobool)
|
BOOST_AUTO_TEST_CASE(tobool)
|
||||||
|
|
|
@ -32,15 +32,15 @@ BOOST_AUTO_TEST_SUITE(base_type)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(gettype)
|
BOOST_AUTO_TEST_CASE(gettype)
|
||||||
{
|
{
|
||||||
const Type *t = GetType<Application>();
|
const Type *t = Type::GetByName("Application");
|
||||||
|
|
||||||
BOOST_CHECK(t);
|
BOOST_CHECK(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(assign)
|
BOOST_AUTO_TEST_CASE(assign)
|
||||||
{
|
{
|
||||||
const Type *t1 = GetType<Application>();
|
const Type *t1 = Type::GetByName("Application");
|
||||||
const Type *t2 = GetType<DynamicObject>();
|
const Type *t2 = Type::GetByName("DynamicObject");
|
||||||
|
|
||||||
BOOST_CHECK(t1->IsAssignableFrom(t1));
|
BOOST_CHECK(t1->IsAssignableFrom(t1));
|
||||||
BOOST_CHECK(t2->IsAssignableFrom(t1));
|
BOOST_CHECK(t2->IsAssignableFrom(t1));
|
||||||
|
|
|
@ -88,7 +88,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
||||||
/* TypeImpl */
|
/* TypeImpl */
|
||||||
std::cout << "template<>" << std::endl
|
std::cout << "template<>" << std::endl
|
||||||
<< "class TypeImpl<" << klass.Name << ">"
|
<< "class TypeImpl<" << klass.Name << ">"
|
||||||
<< " : public Type, public Singleton<TypeImpl<" << klass.Name << "> >" << std::endl
|
<< " : public Type" << std::endl
|
||||||
<< "{" << std::endl
|
<< "{" << std::endl
|
||||||
<< "public:" << std::endl;
|
<< "public:" << std::endl;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
||||||
std::cout << "\t\t" << "return ";
|
std::cout << "\t\t" << "return ";
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << "Singleton<TypeImpl<" << klass.Parent << "> >::GetInstance()";
|
std::cout << "Type::GetByName(\"" << klass.Parent << "\")";
|
||||||
else
|
else
|
||||||
std::cout << "NULL";
|
std::cout << "NULL";
|
||||||
|
|
||||||
|
@ -168,25 +168,31 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
||||||
std::cout << "\t\t" << "int real_id = id - " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
|
std::cout << "\t\t" << "int real_id = id - " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
|
||||||
<< "\t\t" << "if (real_id < 0) { return " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
|
<< "\t\t" << "if (real_id < 0) { return " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
|
||||||
|
|
||||||
std::cout << "\t\t" << "switch (";
|
if (klass.Fields.size() > 0) {
|
||||||
|
std::cout << "\t\t" << "switch (";
|
||||||
|
|
||||||
if (!klass.Parent.empty())
|
if (!klass.Parent.empty())
|
||||||
std::cout << "real_id";
|
std::cout << "real_id";
|
||||||
else
|
else
|
||||||
std::cout << "id";
|
std::cout << "id";
|
||||||
|
|
||||||
std::cout << ") {" << std::endl;
|
std::cout << ") {" << std::endl;
|
||||||
|
|
||||||
num = 0;
|
num = 0;
|
||||||
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
|
||||||
std::cout << "\t\t\t" << "case " << num << ":" << std::endl
|
std::cout << "\t\t\t" << "case " << num << ":" << std::endl
|
||||||
<< "\t\t\t\t" << "return Field(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
|
<< "\t\t\t\t" << "return Field(" << num << ", \"" << it->Name << "\", " << it->Attributes << ");" << std::endl;
|
||||||
num++;
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\t\t\t" << "default:" << std::endl
|
||||||
|
<< "\t\t";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\t\t\t" << "default:" << std::endl
|
std::cout << "\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl;
|
||||||
<< "\t\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
|
|
||||||
<< "\t\t" << "}" << std::endl;
|
if (klass.Fields.size() > 0)
|
||||||
|
std::cout << "\t\t" << "}" << std::endl;
|
||||||
|
|
||||||
std::cout << "\t" << "}" << std::endl << std::endl;
|
std::cout << "\t" << "}" << std::endl << std::endl;
|
||||||
|
|
||||||
|
@ -220,7 +226,7 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
|
||||||
/* GetReflectionType */
|
/* GetReflectionType */
|
||||||
std::cout << "\t" << "virtual const Type *GetReflectionType(void) const" << std::endl
|
std::cout << "\t" << "virtual const Type *GetReflectionType(void) const" << std::endl
|
||||||
<< "\t" << "{" << std::endl
|
<< "\t" << "{" << std::endl
|
||||||
<< "\t\t" << "return TypeImpl<" << klass.Name << ">::GetInstance();" << std::endl
|
<< "\t\t" << "return Type::GetByName(\"" << klass.Name << "\");" << std::endl
|
||||||
<< "\t" << "}" << std::endl << std::endl;
|
<< "\t" << "}" << std::endl << std::endl;
|
||||||
|
|
||||||
if (!klass.Fields.empty()) {
|
if (!klass.Fields.empty()) {
|
||||||
|
@ -408,7 +414,6 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream *stream)
|
||||||
|
|
||||||
std::cout << "#include \"base/object.h\"" << std::endl
|
std::cout << "#include \"base/object.h\"" << std::endl
|
||||||
<< "#include \"base/type.h\"" << std::endl
|
<< "#include \"base/type.h\"" << std::endl
|
||||||
<< "#include \"base/singleton.h\"" << std::endl
|
|
||||||
<< "#include \"base/debug.h\"" << std::endl
|
<< "#include \"base/debug.h\"" << std::endl
|
||||||
<< "#include \"base/value.h\"" << std::endl
|
<< "#include \"base/value.h\"" << std::endl
|
||||||
<< "#include \"base/array.h\"" << std::endl
|
<< "#include \"base/array.h\"" << std::endl
|
||||||
|
|
Loading…
Reference in New Issue