[icinga-checkins] icinga.org: icinga2/next: Implement Type::GetBaseType().

git at icinga.org git at icinga.org
Tue Nov 5 08:56:54 CET 2013


Module: icinga2
Branch: next
Commit: b5b56e5438e3596174798d50e6166cc520fefee9
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=b5b56e5438e3596174798d50e6166cc520fefee9

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Tue Nov  5 08:48:45 2013 +0100

Implement Type::GetBaseType().

Refs #4996

---

 lib/base/type.h                 |    1 +
 tools/mkclass/classcompiler.cpp |   14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/lib/base/type.h b/lib/base/type.h
index 80bf242..48e71f7 100644
--- a/lib/base/type.h
+++ b/lib/base/type.h
@@ -46,6 +46,7 @@ struct Field
 class I2_BASE_API Type
 {
 public:
+	virtual Type *GetBaseType(void) const = 0;
 	virtual int GetFieldId(const String& name) const = 0;
 	virtual Field GetFieldInfo(int id) const = 0;
 	virtual int GetFieldCount(void) const = 0;
diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp
index 5ed6f5b..0d651af 100644
--- a/tools/mkclass/classcompiler.cpp
+++ b/tools/mkclass/classcompiler.cpp
@@ -92,6 +92,20 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo& locp)
 		<< "{" << std::endl
 		<< "public:" << std::endl;
 
+	/* GetBaseType */
+	std::cout << "\t" << "virtual Type *GetBaseType(void) const" << std::endl
+		<< "\t" << "{" << std::endl;
+
+	std::cout << "\t\t" << "return ";
+
+	if (!klass.Parent.empty())
+		std::cout << "Singleton<TypeImpl<" << klass.Parent << "> >::GetInstance()";
+	else
+		std::cout << "NULL";
+
+	std::cout << ";" << std::endl
+			  << "\t" << "}" << std::endl << std::endl;
+
 	/* GetFieldId */
 	std::cout << "\t" << "virtual int GetFieldId(const String& name) const" << std::endl
 		<< "\t" << "{" << std::endl





More information about the icinga-checkins mailing list