Fix INITIALIZE_ONCE().

This commit is contained in:
Gunnar Beutner 2013-08-01 11:14:33 +02:00
parent b9e988f309
commit 7a87fc0d5e
5 changed files with 8 additions and 7 deletions

View File

@ -34,8 +34,8 @@ inline bool InitializeOnceHelper(InitializeFunc func)
return true;
}
#define INITIALIZE_ONCE(func) \
static bool l_InitializeOnce ## __LINE__(InitializeOnceHelper(func));
#define INITIALIZE_ONCE(name, func) \
bool l_InitializeOnce ## name(InitializeOnceHelper(func));
}

View File

@ -29,7 +29,7 @@ using namespace icinga;
Timer::Ptr DbConnection::m_ProgramStatusTimer;
INITIALIZE_ONCE(&DbConnection::StaticInitialize);
INITIALIZE_ONCE(DbConnection, &DbConnection::StaticInitialize);
DbConnection::DbConnection(const Dictionary::Ptr& serializedUpdate)
: DynamicObject(serializedUpdate)

View File

@ -40,6 +40,8 @@ public:
DbConnection(const Dictionary::Ptr& serializedUpdate);
static void StaticInitialize(void);
void SetReference(const DbObject::Ptr& dbobj, const DbReference& dbref);
DbReference GetReference(const DbObject::Ptr& dbobj) const;
@ -60,7 +62,6 @@ private:
std::map<DbObject::Ptr, DbReference> m_References;
static Timer::Ptr m_ProgramStatusTimer;
static void StaticInitialize(void);
static void ProgramStatusHandler(void);
friend class DbType;

View File

@ -34,7 +34,7 @@ boost::signals2::signal<void (const DbObject::Ptr&)> DbObject::OnRegistered;
boost::signals2::signal<void (const DbObject::Ptr&)> DbObject::OnUnregistered;
boost::signals2::signal<void (const DbQuery&)> DbObject::OnQuery;
INITIALIZE_ONCE(&DbObject::StaticInitialize);
INITIALIZE_ONCE(DbObject, &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)

View File

@ -46,6 +46,8 @@ class DbObject : public Object
public:
DECLARE_PTR_TYPEDEFS(DbObject);
static void StaticInitialize(void);
void SetObject(const DynamicObject::Ptr& object);
DynamicObject::Ptr GetObject(void) const;
@ -87,8 +89,6 @@ private:
friend boost::shared_ptr<DbObject> boost::make_shared<>(const icinga::String&, const icinga::String&);
static void StaticInitialize(void);
static void ObjectRegisteredHandler(const DynamicObject::Ptr& object);
static void ObjectUnregisteredHandler(const DynamicObject::Ptr& object);
static void AttributesChangedHandler(const DynamicObject::Ptr& object, const std::set<String, string_iless>& attributes);