[icinga-checkins] icinga.org: icinga2/feature/incremental-ido-updates-12435: Replace GetType ()->GetName() calls with GetReflectionType()->GetName()

git at icinga.org git at icinga.org
Mon Aug 15 14:42:49 CEST 2016


Module: icinga2
Branch: feature/incremental-ido-updates-12435
Commit: ebaf239d3b90c76e0c3b6308417cf704c8dcdc5c
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=ebaf239d3b90c76e0c3b6308417cf704c8dcdc5c

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Aug 15 14:39:33 2016 +0200

Replace GetType()->GetName() calls with GetReflectionType()->GetName()

fixes #12438

---

 lib/base/configobject.cpp             |    4 ++--
 lib/db_ido/dbobject.cpp               |   11 +++++++----
 lib/icinga/compatutility.cpp          |    7 ++++---
 lib/remote/apilistener-configsync.cpp |    4 ++--
 lib/remote/apilistener.cpp            |    2 +-
 5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp
index 520e4b2..f52eee3 100644
--- a/lib/base/configobject.cpp
+++ b/lib/base/configobject.cpp
@@ -384,7 +384,7 @@ void ConfigObject::Start(bool runtimeCreated)
 
 void ConfigObject::Activate(bool runtimeCreated)
 {
-	CONTEXT("Activating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
+	CONTEXT("Activating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
 
 	{
 		ObjectLock olock(this);
@@ -413,7 +413,7 @@ void ConfigObject::Stop(bool runtimeRemoved)
 
 void ConfigObject::Deactivate(bool runtimeRemoved)
 {
-	CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
+	CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
 
 	{
 		ObjectLock olock(this);
diff --git a/lib/db_ido/dbobject.cpp b/lib/db_ido/dbobject.cpp
index de7c92c..2f3974f 100644
--- a/lib/db_ido/dbobject.cpp
+++ b/lib/db_ido/dbobject.cpp
@@ -23,6 +23,9 @@
 #include "icinga/customvarobject.hpp"
 #include "icinga/service.hpp"
 #include "icinga/compatutility.hpp"
+#include "icinga/checkcommand.hpp"
+#include "icinga/eventcommand.hpp"
+#include "icinga/notificationcommand.hpp"
 #include "remote/endpoint.hpp"
 #include "base/configobject.hpp"
 #include "base/configtype.hpp"
@@ -288,7 +291,7 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object)
 	if (dbobj)
 		return dbobj;
 
-	DbType::Ptr dbtype = DbType::GetByName(object->GetType()->GetName());
+	DbType::Ptr dbtype = DbType::GetByName(object->GetReflectionType()->GetName());
 
 	if (!dbtype)
 		return DbObject::Ptr();
@@ -304,9 +307,9 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object)
 		name1 = service->GetHost()->GetName();
 		name2 = service->GetShortName();
 	} else {
-		if (object->GetType() == ConfigType::GetByName("CheckCommand") ||
-		    object->GetType() == ConfigType::GetByName("EventCommand") ||
-		    object->GetType() == ConfigType::GetByName("NotificationCommand")) {
+		if (object->GetReflectionType() == CheckCommand::TypeInstance ||
+		    object->GetReflectionType() == EventCommand::TypeInstance ||
+		    object->GetReflectionType() == NotificationCommand::TypeInstance) {
 			Command::Ptr command = dynamic_pointer_cast<Command>(object);
 			name1 = CompatUtility::GetCommandName(command);
 		}
diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp
index e2aeeb3..20c1f6f 100644
--- a/lib/icinga/compatutility.cpp
+++ b/lib/icinga/compatutility.cpp
@@ -20,6 +20,7 @@
 #include "icinga/compatutility.hpp"
 #include "icinga/checkcommand.hpp"
 #include "icinga/eventcommand.hpp"
+#include "icinga/notificationcommand.hpp"
 #include "icinga/pluginutility.hpp"
 #include "icinga/service.hpp"
 #include "base/utility.hpp"
@@ -62,11 +63,11 @@ String CompatUtility::GetCommandNamePrefix(const Command::Ptr command)
 		return Empty;
 
 	String prefix;
-	if (command->GetType() == ConfigType::GetByName("CheckCommand"))
+	if (command->GetReflectionType() == CheckCommand::TypeInstance)
 		prefix = "check_";
-	else if (command->GetType() == ConfigType::GetByName("NotificationCommand"))
+	else if (command->GetReflectionType() == NotificationCommand::TypeInstance)
 		prefix = "notification_";
-	else if (command->GetType() == ConfigType::GetByName("EventCommand"))
+	else if (command->GetReflectionType() == EventCommand::TypeInstance)
 		prefix = "event_";
 
 	return prefix;
diff --git a/lib/remote/apilistener-configsync.cpp b/lib/remote/apilistener-configsync.cpp
index 189f705..aaee8d9 100644
--- a/lib/remote/apilistener-configsync.cpp
+++ b/lib/remote/apilistener-configsync.cpp
@@ -291,7 +291,7 @@ void ApiListener::UpdateConfigObject(const ConfigObject::Ptr& object, const Mess
 
 	Dictionary::Ptr params = new Dictionary();
 	params->Set("name", object->GetName());
-	params->Set("type", object->GetType()->GetName());
+	params->Set("type", object->GetReflectionType()->GetName());
 	params->Set("version", object->GetVersion());
 
 	if (object->GetPackage() == "_api") {
@@ -370,7 +370,7 @@ void ApiListener::DeleteConfigObject(const ConfigObject::Ptr& object, const Mess
 
 	Dictionary::Ptr params = new Dictionary();
 	params->Set("name", object->GetName());
-	params->Set("type", object->GetType()->GetName());
+	params->Set("type", object->GetReflectionType()->GetName());
 	params->Set("version", object->GetVersion());
 
 	message->Set("params", params);
diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp
index 5103235..227fe50 100644
--- a/lib/remote/apilistener.cpp
+++ b/lib/remote/apilistener.cpp
@@ -651,7 +651,7 @@ void ApiListener::PersistMessage(const Dictionary::Ptr& message, const ConfigObj
 
 	if (secobj) {
 		Dictionary::Ptr secname = new Dictionary();
-		secname->Set("type", secobj->GetType()->GetName());
+		secname->Set("type", secobj->GetReflectionType()->GetName());
 		secname->Set("name", secobj->GetName());
 		pmessage->Set("secobj", secname);
 	}



More information about the icinga-checkins mailing list