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

Method Set

lib/base/namespace.cpp:48–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void Namespace::Set(const String& field, const Value& value, bool isConst, const DebugInfo& debugInfo)
49{
50 ObjectLock olock(this);
51
52 if (m_Frozen) {
53 BOOST_THROW_EXCEPTION(ScriptError("Namespace is read-only and must not be modified.", debugInfo));
54 }
55
56 std::unique_lock<decltype(m_DataMutex)> dlock (m_DataMutex);
57
58 auto nsVal = m_Data.find(field);
59
60 if (nsVal == m_Data.end()) {
61 m_Data[field] = NamespaceValue{value, isConst || m_ConstValues};
62 } else {
63 if (nsVal->second.Const) {
64 BOOST_THROW_EXCEPTION(ScriptError("Constant must not be modified.", debugInfo));
65 }
66
67 nsVal->second.Val = value;
68 }
69}
70
71/**
72 * Returns the number of elements in the namespace.

Callers

nothing calls this directly

Calls 3

ScriptErrorClass · 0.85
findMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected