using namespace icinga;
-map<pair<String, String>, Dictionary::Ptr> DynamicObject::m_PersistentUpdates;
double DynamicObject::m_CurrentTx = 0;
set<DynamicObject::Ptr> DynamicObject::m_ModifiedObjects;
} else {
/* keep non-replicated objects until another config object with
* the same name is created (which is when we restore its tags) */
- m_PersistentUpdates[make_pair(type, name)] = update;
+ GetPersistentObjects()[make_pair(type, name)] = update;
}
}
}
return classes;
}
+DynamicObject::PersistentUpdateMap& DynamicObject::GetPersistentObjects(void)
+{
+ static DynamicObject::PersistentUpdateMap persistentObjects;
+ return persistentObjects;
+}
+
+
void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory factory)
{
if (GetObjects(type).first != GetObjects(type).second)
/* restore persistent objects that match the newly-registered class */
map<pair<String, String>, Dictionary::Ptr>::iterator prev, st;
- for (st = m_PersistentUpdates.begin(); st != m_PersistentUpdates.end(); st++)
+ for (st = GetPersistentObjects().begin(); st != GetPersistentObjects().end(); )
{
/* check type of the update */
if (st->first.first != type) {
prev = st;
st++;
- m_PersistentUpdates.erase(prev);
+ GetPersistentObjects().erase(prev);
}
}
/* restore the object's persistent non-config attributes */
map<pair<String, String>, Dictionary::Ptr>::iterator st;
- st = m_PersistentUpdates.find(make_pair(obj->GetType(), obj->GetName()));
- if (st != m_PersistentUpdates.end()) {
+ st = GetPersistentObjects().find(make_pair(obj->GetType(), obj->GetName()));
+ if (st != GetPersistentObjects().end()) {
Logger::Write(LogDebug, "base", "Restoring persistent state "
"for object " + obj->GetType() + ":" + obj->GetName());
obj->ApplyUpdate(st->second, Attribute_All & ~Attribute_Config);
/* we're done with this update, remove it */
- m_PersistentUpdates.erase(st);
+ GetPersistentObjects().erase(st);
}
/* apply the object's non-config attributes */
AttributeMap m_Attributes;
double m_ConfigTx;
- static map<pair<String, String>, Dictionary::Ptr> m_PersistentUpdates;
static double m_CurrentTx;
+ typedef map<pair<String, String>, Dictionary::Ptr> PersistentUpdateMap;
+ static PersistentUpdateMap& GetPersistentObjects(void);
+
static set<DynamicObject::Ptr> m_ModifiedObjects;
void InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, int allowedTypes, bool suppressEvents);