mirror of https://github.com/Icinga/icinga2.git
parent
7c990eff6e
commit
e546cd854d
|
@ -28,7 +28,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(CheckerComponent);
|
||||
REGISTER_TYPE(CheckerComponent);
|
||||
|
||||
void CheckerComponent::Start(void)
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(ClusterListener);
|
||||
REGISTER_TYPE(ClusterListener);
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Endpoint);
|
||||
REGISTER_TYPE(Endpoint);
|
||||
|
||||
boost::signals2::signal<void (const Endpoint::Ptr&)> Endpoint::OnConnected;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(CheckResultReader);
|
||||
REGISTER_TYPE(CheckResultReader);
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(CompatLogger);
|
||||
REGISTER_TYPE(CompatLogger);
|
||||
REGISTER_SCRIPTFUNCTION(ValidateRotationMethod, &CompatLogger::ValidateRotationMethod);
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(ExternalCommandListener);
|
||||
REGISTER_TYPE(ExternalCommandListener);
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(StatusDataWriter);
|
||||
REGISTER_TYPE(StatusDataWriter);
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(IdoMysqlConnection);
|
||||
REGISTER_TYPE(IdoMysqlConnection);
|
||||
|
||||
#define SCHEMA_VERSION "1.10.0"
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(IdoPgsqlConnection);
|
||||
REGISTER_TYPE(IdoPgsqlConnection);
|
||||
|
||||
#define SCHEMA_VERSION "1.10.0"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Demo);
|
||||
REGISTER_TYPE(Demo);
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
using namespace icinga;
|
||||
using namespace livestatus;
|
||||
|
||||
REGISTER_NTYPE(LivestatusListener);
|
||||
REGISTER_TYPE(LivestatusListener);
|
||||
REGISTER_SCRIPTFUNCTION(ValidateSocketType, &LivestatusListener::ValidateSocketType);
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(NotificationComponent);
|
||||
REGISTER_TYPE(NotificationComponent);
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(GraphiteWriter);
|
||||
REGISTER_TYPE(GraphiteWriter);
|
||||
|
||||
void GraphiteWriter::Start(void)
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(PerfdataWriter);
|
||||
REGISTER_TYPE(PerfdataWriter);
|
||||
|
||||
void PerfdataWriter::Start(void)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Application);
|
||||
REGISTER_TYPE(Application);
|
||||
|
||||
Application *Application::m_Instance = NULL;
|
||||
bool Application::m_ShuttingDown = false;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(ConsoleLogger);
|
||||
REGISTER_TYPE(ConsoleLogger);
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
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::OnStopped;
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
DynamicType::DynamicType(const String& name, const DynamicType::ObjectFactory& factory)
|
||||
: m_Name(name), m_ObjectFactory(factory)
|
||||
DynamicType::DynamicType(const String& name)
|
||||
: m_Name(name)
|
||||
{ }
|
||||
|
||||
DynamicType::Ptr DynamicType::GetByName(const String& name)
|
||||
|
@ -34,9 +34,21 @@ DynamicType::Ptr DynamicType::GetByName(const String& name)
|
|||
|
||||
DynamicType::TypeMap::const_iterator tt = InternalGetTypeMap().find(name);
|
||||
|
||||
if (tt == InternalGetTypeMap().end())
|
||||
if (tt == InternalGetTypeMap().end()) {
|
||||
const Type *type = Type::GetByName(name);
|
||||
|
||||
if (!type || !GetType<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;
|
||||
}
|
||||
|
||||
|
@ -112,36 +124,17 @@ DynamicObject::Ptr DynamicType::GetObject(const String& name) const
|
|||
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)
|
||||
{
|
||||
ASSERT(!OwnsLock());
|
||||
|
||||
ObjectFactory factory;
|
||||
const Type *type = Type::GetByName(m_Name);
|
||||
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
factory = m_ObjectFactory;
|
||||
}
|
||||
|
||||
DynamicObject::Ptr object = factory();
|
||||
Object::Ptr object = type->Instantiate();
|
||||
|
||||
Deserialize(object, serializedUpdate, FAConfig);
|
||||
|
||||
return object;
|
||||
return dynamic_pointer_cast<DynamicObject>(object);
|
||||
}
|
||||
|
||||
boost::mutex& DynamicType::GetStaticMutex(void)
|
||||
|
|
|
@ -36,16 +36,12 @@ class I2_BASE_API DynamicType : public Object
|
|||
public:
|
||||
DECLARE_PTR_TYPEDEFS(DynamicType);
|
||||
|
||||
typedef boost::function<DynamicObject::Ptr (void)> ObjectFactory;
|
||||
|
||||
DynamicType(const String& name, const ObjectFactory& factory);
|
||||
DynamicType(const String& name);
|
||||
|
||||
String GetName(void) const;
|
||||
|
||||
static DynamicType::Ptr GetByName(const String& name);
|
||||
|
||||
static void RegisterType(const DynamicType::Ptr& type);
|
||||
|
||||
DynamicObject::Ptr CreateObject(const Dictionary::Ptr& serializedUpdate);
|
||||
DynamicObject::Ptr GetObject(const String& name) const;
|
||||
|
||||
|
@ -72,7 +68,6 @@ public:
|
|||
|
||||
private:
|
||||
String m_Name;
|
||||
ObjectFactory m_ObjectFactory;
|
||||
|
||||
typedef std::map<String, DynamicObject::Ptr, string_iless> ObjectMap;
|
||||
typedef std::vector<DynamicObject::Ptr> ObjectVector;
|
||||
|
@ -90,46 +85,6 @@ private:
|
|||
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 */
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(FileLogger);
|
||||
REGISTER_TYPE(FileLogger);
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Logger);
|
||||
REGISTER_TYPE(Logger);
|
||||
|
||||
std::set<Logger::Ptr> Logger::m_Loggers;
|
||||
boost::mutex Logger::m_Mutex;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Script);
|
||||
REGISTER_TYPE(Script);
|
||||
|
||||
void Script::Start(void)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(StreamLogger);
|
||||
REGISTER_TYPE(StreamLogger);
|
||||
|
||||
boost::mutex StreamLogger::m_Mutex;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#ifndef _WIN32
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(SyslogLogger);
|
||||
REGISTER_TYPE(SyslogLogger);
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,7 +95,7 @@ struct FactoryHelper
|
|||
}
|
||||
};
|
||||
|
||||
#define REGISTER_NTYPE(type) \
|
||||
#define REGISTER_TYPE(type) \
|
||||
namespace { \
|
||||
void RegisterType(void) \
|
||||
{ \
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(DbConnection);
|
||||
REGISTER_TYPE(DbConnection);
|
||||
|
||||
Timer::Ptr DbConnection::m_ProgramStatusTimer;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Hello);
|
||||
REGISTER_TYPE(Hello);
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(CheckCommand);
|
||||
REGISTER_TYPE(CheckCommand);
|
||||
|
||||
Dictionary::Ptr CheckCommand::Execute(const Service::Ptr& service)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Command);
|
||||
REGISTER_TYPE(Command);
|
||||
|
||||
bool Command::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Domain);
|
||||
REGISTER_TYPE(Domain);
|
||||
|
||||
int Domain::GetPrivileges(const String& instance) const
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(EventCommand);
|
||||
REGISTER_TYPE(EventCommand);
|
||||
|
||||
void EventCommand::Execute(const Service::Ptr& service)
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Host);
|
||||
REGISTER_TYPE(Host);
|
||||
|
||||
void Host::Start(void)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(HostGroup);
|
||||
REGISTER_TYPE(HostGroup);
|
||||
|
||||
std::set<Host::Ptr> HostGroup::GetMembers(void) const
|
||||
|
|
|
@ -32,7 +32,6 @@ using namespace icinga;
|
|||
|
||||
static Timer::Ptr l_RetentionTimer;
|
||||
|
||||
REGISTER_NTYPE(IcingaApplication);
|
||||
REGISTER_TYPE(IcingaApplication);
|
||||
INITIALIZE_ONCE(IcingaApplication, &IcingaApplication::StaticInitialize);
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Notification);
|
||||
REGISTER_TYPE(Notification);
|
||||
|
||||
boost::signals2::signal<void (const Notification::Ptr&, double, const String&)> Notification::OnNextNotificationChanged;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(NotificationCommand);
|
||||
REGISTER_TYPE(NotificationCommand);
|
||||
|
||||
Dictionary::Ptr NotificationCommand::Execute(const Notification::Ptr& notification,
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(PerfdataValue);
|
||||
REGISTER_TYPE(PerfdataValue);
|
||||
|
||||
PerfdataValue::PerfdataValue(void)
|
||||
{ }
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(Service);
|
||||
REGISTER_TYPE(Service);
|
||||
|
||||
boost::signals2::signal<void (const Service::Ptr&, const String&, const String&, AcknowledgementType, double, const String&)> Service::OnAcknowledgementSet;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(ServiceGroup);
|
||||
REGISTER_TYPE(ServiceGroup);
|
||||
|
||||
std::set<Service::Ptr> ServiceGroup::GetMembers(void) const
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(TimePeriod);
|
||||
REGISTER_TYPE(TimePeriod);
|
||||
REGISTER_SCRIPTFUNCTION(EmptyTimePeriod, &TimePeriod::EmptyTimePeriodUpdate);
|
||||
REGISTER_SCRIPTFUNCTION(EvenMinutesTimePeriod, &TimePeriod::EvenMinutesTimePeriodUpdate);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(User);
|
||||
REGISTER_TYPE(User);
|
||||
|
||||
void User::OnConfigLoaded(void)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_NTYPE(UserGroup);
|
||||
REGISTER_TYPE(UserGroup);
|
||||
|
||||
std::set<User::Ptr> UserGroup::GetMembers(void) const
|
||||
|
|
Loading…
Reference in New Issue