ido: replace hardcoded objecttype_id with enum

This commit is contained in:
Michael Friedrich 2013-08-02 17:12:07 +02:00
parent 2b0fd9e34b
commit d4015fe218
9 changed files with 26 additions and 10 deletions

View File

@ -27,9 +27,9 @@
using namespace icinga;
REGISTER_DBTYPE(CheckCommand, "command", 12, "object_id", CommandDbObject);
REGISTER_DBTYPE(EventCommand, "command", 12, "object_id", CommandDbObject);
REGISTER_DBTYPE(NotificationCommand, "command", 12, "object_id", CommandDbObject);
REGISTER_DBTYPE(CheckCommand, "command", DbObjectTypeCommand, "object_id", CommandDbObject);
REGISTER_DBTYPE(EventCommand, "command", DbObjectTypeCommand, "object_id", CommandDbObject);
REGISTER_DBTYPE(NotificationCommand, "command", DbObjectTypeCommand, "object_id", CommandDbObject);
CommandDbObject::CommandDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
: DbObject(type, name1, name2)

View File

@ -34,6 +34,22 @@ enum DbObjectUpdateType
DbObjectRemoved
};
enum DbObjectType
{
DbObjectTypeHost = 1,
DbObjectTypeService = 2,
DbObjectTypeHostGroup = 3,
DbObjectTypeServiceGroup = 4,
DbObjectTypeHostEscalation = 5,
DbObjectTypeServiceEscalation = 6,
DbObjectTypeHostDependency = 7,
DbObjectTypeServiceDependency = 8,
DbObjectTypeTimePeriod = 9,
DbObjectTypeContact = 10,
DbObjectTypeContactGroup = 11,
DbObjectTypeCommand = 12,
};
/**
* A database object.
*

View File

@ -31,7 +31,7 @@
using namespace icinga;
REGISTER_DBTYPE(Host, "host", 1, "host_object_id", HostDbObject);
REGISTER_DBTYPE(Host, "host", DbObjectTypeHost, "host_object_id", HostDbObject);
HostDbObject::HostDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
: DbObject(type, name1, name2)

View File

@ -28,7 +28,7 @@
using namespace icinga;
REGISTER_DBTYPE(HostGroup, "hostgroup", 3, "hostgroup_object_id", HostGroupDbObject);
REGISTER_DBTYPE(HostGroup, "hostgroup", DbObjectTypeHostGroup, "hostgroup_object_id", HostGroupDbObject);
INITIALIZE_ONCE(HostGroupDbObject, &HostGroupDbObject::StaticInitialize);
HostGroupDbObject::HostGroupDbObject(const DbType::Ptr& type, const String& name1, const String& name2)

View File

@ -29,7 +29,7 @@
using namespace icinga;
REGISTER_DBTYPE(Service, "service", 2, "service_object_id", ServiceDbObject);
REGISTER_DBTYPE(Service, "service", DbObjectTypeService, "service_object_id", ServiceDbObject);
ServiceDbObject::ServiceDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
: DbObject(type, name1, name2)

View File

@ -26,7 +26,7 @@
using namespace icinga;
REGISTER_DBTYPE(ServiceGroup, "servicegroup", 4, "servicegroup_object_id", ServiceGroupDbObject);
REGISTER_DBTYPE(ServiceGroup, "servicegroup", DbObjectTypeServiceGroup, "servicegroup_object_id", ServiceGroupDbObject);
ServiceGroupDbObject::ServiceGroupDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
: DbObject(type, name1, name2)

View File

@ -26,7 +26,7 @@
using namespace icinga;
REGISTER_DBTYPE(TimePeriod, "timeperiod", 9, "timeperiod_object_id", TimePeriodDbObject);
REGISTER_DBTYPE(TimePeriod, "timeperiod", DbObjectTypeTimePeriod, "timeperiod_object_id", TimePeriodDbObject);
TimePeriodDbObject::TimePeriodDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
: DbObject(type, name1, name2)

View File

@ -26,7 +26,7 @@
using namespace icinga;
REGISTER_DBTYPE(User, "contact", 10, "contact_object_id", UserDbObject);
REGISTER_DBTYPE(User, "contact", DbObjectTypeContact, "contact_object_id", UserDbObject);
UserDbObject::UserDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
: DbObject(type, name1, name2)

View File

@ -26,7 +26,7 @@
using namespace icinga;
REGISTER_DBTYPE(UserGroup, "contactgroup", 11, "contactgroup_object_id", UserGroupDbObject);
REGISTER_DBTYPE(UserGroup, "contactgroup", DbObjectTypeContactGroup, "contactgroup_object_id", UserGroupDbObject);
UserGroupDbObject::UserGroupDbObject(const DbType::Ptr& type, const String& name1, const String& name2)
: DbObject(type, name1, name2)