[icinga-checkins] icinga.org: icinga2/feature/dtype-5036: Use anonymous namespaces for INITIALIZE_ONCE().

git at icinga.org git at icinga.org
Fri Nov 8 21:49:36 CET 2013


Module: icinga2
Branch: feature/dtype-5036
Commit: 2a6151e935e30d27f3d6941f82e2fc6eb871234c
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=2a6151e935e30d27f3d6941f82e2fc6eb871234c

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Fri Nov  8 21:12:47 2013 +0100

Use anonymous namespaces for INITIALIZE_ONCE().

Refs #5036

---

 lib/base/initialize.h            |    6 ++++--
 lib/base/type.h                  |    2 +-
 lib/db_ido/dbconnection.cpp      |    2 +-
 lib/db_ido/dbobject.cpp          |    2 +-
 lib/db_ido/servicedbobject.cpp   |    2 +-
 lib/icinga/icingaapplication.cpp |    2 +-
 6 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/base/initialize.h b/lib/base/initialize.h
index 120b2bf..f465176 100644
--- a/lib/base/initialize.h
+++ b/lib/base/initialize.h
@@ -34,8 +34,10 @@ inline bool InitializeOnceHelper(InitializeFunc func)
 	return true;
 }
 
-#define INITIALIZE_ONCE(name, func) \
-	I2_EXPORT bool l_InitializeOnce ## name(InitializeOnceHelper(func))
+#define INITIALIZE_ONCE(func) \
+	namespace { \
+		I2_EXPORT bool l_InitializeOnce(InitializeOnceHelper(func)); \
+	}
 
 }
 
diff --git a/lib/base/type.h b/lib/base/type.h
index 0588ef4..af82212 100644
--- a/lib/base/type.h
+++ b/lib/base/type.h
@@ -104,7 +104,7 @@ struct FactoryHelper
 			icinga::Type::Register(GetType<type>()); \
 		} \
 		\
-		INITIALIZE_ONCE(type, RegisterType); \
+		INITIALIZE_ONCE(RegisterType); \
 	}
 
 }
diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp
index e938249..b20c6b2 100644
--- a/lib/db_ido/dbconnection.cpp
+++ b/lib/db_ido/dbconnection.cpp
@@ -35,7 +35,7 @@ REGISTER_TYPE(DbConnection);
 
 Timer::Ptr DbConnection::m_ProgramStatusTimer;
 
-INITIALIZE_ONCE(DbConnection, &DbConnection::StaticInitialize);
+INITIALIZE_ONCE(&DbConnection::StaticInitialize);
 
 void DbConnection::Start(void)
 {
diff --git a/lib/db_ido/dbobject.cpp b/lib/db_ido/dbobject.cpp
index df7afaa..e85856c 100644
--- a/lib/db_ido/dbobject.cpp
+++ b/lib/db_ido/dbobject.cpp
@@ -32,7 +32,7 @@ using namespace icinga;
 
 boost::signals2::signal<void (const DbQuery&)> DbObject::OnQuery;
 
-INITIALIZE_ONCE(DbObject, &DbObject::StaticInitialize);
+INITIALIZE_ONCE(&DbObject::StaticInitialize);
 
 DbObject::DbObject(const shared_ptr<DbType>& type, const String& name1, const String& name2)
 	: m_Name1(name1), m_Name2(name2), m_Type(type), m_LastConfigUpdate(0), m_LastStatusUpdate(0)
diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp
index 6c9862d..24611b8 100644
--- a/lib/db_ido/servicedbobject.cpp
+++ b/lib/db_ido/servicedbobject.cpp
@@ -38,7 +38,7 @@ using namespace icinga;
 
 REGISTER_DBTYPE(Service, "service", DbObjectTypeService, "service_object_id", ServiceDbObject);
 
-INITIALIZE_ONCE(ServiceDbObject, &ServiceDbObject::StaticInitialize);
+INITIALIZE_ONCE(&ServiceDbObject::StaticInitialize);
 
 void ServiceDbObject::StaticInitialize(void)
 {
diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp
index c0502a2..abbd9da 100644
--- a/lib/icinga/icingaapplication.cpp
+++ b/lib/icinga/icingaapplication.cpp
@@ -33,7 +33,7 @@ using namespace icinga;
 static Timer::Ptr l_RetentionTimer;
 
 REGISTER_TYPE(IcingaApplication);
-INITIALIZE_ONCE(IcingaApplication, &IcingaApplication::StaticInitialize);
+INITIALIZE_ONCE(&IcingaApplication::StaticInitialize);
 
 void IcingaApplication::StaticInitialize(void)
 {





More information about the icinga-checkins mailing list