#include using namespace icinga; bool propgetter(string prop, const Object::Ptr& object, string *key) { DynamicObject::Ptr dobj = dynamic_pointer_cast(object); return dobj->GetConfig()->GetProperty(prop, key); } int main(int argc, char **argv) { for (int i = 0; i < 10000; i++) { stringstream sname; sname << "foo" << i; DynamicObject::Ptr dobj = make_shared(); dobj->GetConfig()->SetProperty("type", "process"); dobj->GetConfig()->SetProperty("name", sname.str()); dobj->Commit(); } ObjectMap::Ptr byType = make_shared(ObjectSet::GetAllObjects(), bind(&propgetter, "type", _1, _2)); byType->Start(); ObjectMap::Ptr byName = make_shared(ObjectSet::GetAllObjects(), bind(&propgetter, "name", _1, _2)); byName->Start(); ObjectMap::Range processes = byType->GetRange("process"); cout << distance(processes.first, processes.second) << " processes" << endl; ObjectMap::Range foo55 = byName->GetRange("foo55"); cout << distance(foo55.first, foo55.second) << " foo55s" << endl; return 0; }