MCPcopy Create free account
hub / github.com/Icinga/icinga2 / RegisterObject

Method RegisterObject

lib/base/configtype.cpp:25–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void ConfigType::RegisterObject(const ConfigObject::Ptr& object)
26{
27 String name = object->GetName();
28
29 {
30 std::unique_lock<decltype(m_Mutex)> lock (m_Mutex);
31
32 auto it = m_ObjectMap.find(name);
33
34 if (it != m_ObjectMap.end()) {
35 if (it->second == object)
36 return;
37
38 auto *type = dynamic_cast<Type *>(this);
39
40 BOOST_THROW_EXCEPTION(ScriptError("An object with type '" + type->GetName() + "' and name '" + name + "' already exists (" +
41 Convert::ToString(it->second->GetDebugInfo()) + "), new declaration: " + Convert::ToString(object->GetDebugInfo()),
42 object->GetDebugInfo()));
43 }
44
45 m_ObjectMap[name] = object;
46 m_ObjectVector.push_back(object);
47 }
48}
49
50void ConfigType::UnregisterObject(const ConfigObject::Ptr& object)
51{

Callers 1

RegisterMethod · 0.80

Calls 6

ScriptErrorClass · 0.85
findMethod · 0.80
push_backMethod · 0.80
GetNameMethod · 0.45
endMethod · 0.45
GetDebugInfoMethod · 0.45

Tested by

no test coverage detected