From d4015fe21826320e3ca34c8406beac25ec258812 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 2 Aug 2013 17:12:07 +0200 Subject: [PATCH] ido: replace hardcoded objecttype_id with enum --- lib/ido/commanddbobject.cpp | 6 +++--- lib/ido/dbobject.h | 16 ++++++++++++++++ lib/ido/hostdbobject.cpp | 2 +- lib/ido/hostgroupdbobject.cpp | 2 +- lib/ido/servicedbobject.cpp | 2 +- lib/ido/servicegroupdbobject.cpp | 2 +- lib/ido/timeperioddbobject.cpp | 2 +- lib/ido/userdbobject.cpp | 2 +- lib/ido/usergroupdbobject.cpp | 2 +- 9 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/ido/commanddbobject.cpp b/lib/ido/commanddbobject.cpp index 9c742aa41..5e58ed8a7 100644 --- a/lib/ido/commanddbobject.cpp +++ b/lib/ido/commanddbobject.cpp @@ -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) diff --git a/lib/ido/dbobject.h b/lib/ido/dbobject.h index 446b98e7a..5e4d90867 100644 --- a/lib/ido/dbobject.h +++ b/lib/ido/dbobject.h @@ -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. * diff --git a/lib/ido/hostdbobject.cpp b/lib/ido/hostdbobject.cpp index f2d5bea6b..a6b6c2269 100644 --- a/lib/ido/hostdbobject.cpp +++ b/lib/ido/hostdbobject.cpp @@ -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) diff --git a/lib/ido/hostgroupdbobject.cpp b/lib/ido/hostgroupdbobject.cpp index a90079850..fb871f516 100644 --- a/lib/ido/hostgroupdbobject.cpp +++ b/lib/ido/hostgroupdbobject.cpp @@ -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) diff --git a/lib/ido/servicedbobject.cpp b/lib/ido/servicedbobject.cpp index c342e6c4a..2037c1ef0 100644 --- a/lib/ido/servicedbobject.cpp +++ b/lib/ido/servicedbobject.cpp @@ -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) diff --git a/lib/ido/servicegroupdbobject.cpp b/lib/ido/servicegroupdbobject.cpp index 85a3ef69b..6437dc90b 100644 --- a/lib/ido/servicegroupdbobject.cpp +++ b/lib/ido/servicegroupdbobject.cpp @@ -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) diff --git a/lib/ido/timeperioddbobject.cpp b/lib/ido/timeperioddbobject.cpp index 7c27a30ae..4b791f558 100644 --- a/lib/ido/timeperioddbobject.cpp +++ b/lib/ido/timeperioddbobject.cpp @@ -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) diff --git a/lib/ido/userdbobject.cpp b/lib/ido/userdbobject.cpp index bd158d707..e5130f1a6 100644 --- a/lib/ido/userdbobject.cpp +++ b/lib/ido/userdbobject.cpp @@ -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) diff --git a/lib/ido/usergroupdbobject.cpp b/lib/ido/usergroupdbobject.cpp index a043eafe1..3d45d2e6d 100644 --- a/lib/ido/usergroupdbobject.cpp +++ b/lib/ido/usergroupdbobject.cpp @@ -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)