mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-20 04:04:32 +02:00
Namespace: place ObjectLock in all methods
(cherry picked from commit 5afda779435c848cf5a8411f713adc9891aa5092)
This commit is contained in:
parent
c6f84e24da
commit
ae3590023b
@ -37,6 +37,8 @@ Namespace::Namespace(NamespaceBehavior *behavior)
|
|||||||
|
|
||||||
Value Namespace::Get(const String& field) const
|
Value Namespace::Get(const String& field) const
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
Value value;
|
Value value;
|
||||||
if (!GetOwnField(field, &value))
|
if (!GetOwnField(field, &value))
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Namespace does not contain field '" + field + "'"));
|
BOOST_THROW_EXCEPTION(ScriptError("Namespace does not contain field '" + field + "'"));
|
||||||
@ -45,6 +47,8 @@ Value Namespace::Get(const String& field) const
|
|||||||
|
|
||||||
bool Namespace::Get(const String& field, Value *value) const
|
bool Namespace::Get(const String& field, Value *value) const
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
auto nsVal = GetAttribute(field);
|
auto nsVal = GetAttribute(field);
|
||||||
|
|
||||||
if (!nsVal)
|
if (!nsVal)
|
||||||
@ -56,16 +60,22 @@ bool Namespace::Get(const String& field, Value *value) const
|
|||||||
|
|
||||||
void Namespace::Set(const String& field, const Value& value, bool overrideFrozen)
|
void Namespace::Set(const String& field, const Value& value, bool overrideFrozen)
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
return SetFieldByName(field, value, overrideFrozen, DebugInfo());
|
return SetFieldByName(field, value, overrideFrozen, DebugInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Namespace::Contains(const String& field) const
|
bool Namespace::Contains(const String& field) const
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
return HasOwnField(field);
|
return HasOwnField(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Namespace::Remove(const String& field, bool overrideFrozen)
|
void Namespace::Remove(const String& field, bool overrideFrozen)
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
m_Behavior->Remove(this, field, overrideFrozen);
|
m_Behavior->Remove(this, field, overrideFrozen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +113,8 @@ void Namespace::SetAttribute(const String& key, const std::shared_ptr<NamespaceV
|
|||||||
|
|
||||||
Value Namespace::GetFieldByName(const String& field, bool, const DebugInfo& debugInfo) const
|
Value Namespace::GetFieldByName(const String& field, bool, const DebugInfo& debugInfo) const
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
auto nsVal = GetAttribute(field);
|
auto nsVal = GetAttribute(field);
|
||||||
|
|
||||||
if (nsVal)
|
if (nsVal)
|
||||||
@ -113,6 +125,8 @@ Value Namespace::GetFieldByName(const String& field, bool, const DebugInfo& debu
|
|||||||
|
|
||||||
void Namespace::SetFieldByName(const String& field, const Value& value, bool overrideFrozen, const DebugInfo& debugInfo)
|
void Namespace::SetFieldByName(const String& field, const Value& value, bool overrideFrozen, const DebugInfo& debugInfo)
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
auto nsVal = GetAttribute(field);
|
auto nsVal = GetAttribute(field);
|
||||||
|
|
||||||
if (!nsVal)
|
if (!nsVal)
|
||||||
@ -123,11 +137,15 @@ void Namespace::SetFieldByName(const String& field, const Value& value, bool ove
|
|||||||
|
|
||||||
bool Namespace::HasOwnField(const String& field) const
|
bool Namespace::HasOwnField(const String& field) const
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
return GetAttribute(field) != nullptr;
|
return GetAttribute(field) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Namespace::GetOwnField(const String& field, Value *result) const
|
bool Namespace::GetOwnField(const String& field, Value *result) const
|
||||||
{
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
|
||||||
auto nsVal = GetAttribute(field);
|
auto nsVal = GetAttribute(field);
|
||||||
|
|
||||||
if (!nsVal)
|
if (!nsVal)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user