mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
In essence, namespace behaviors acted as hooks for update operations on namespaces. Two behaviors were implemented: - `NamespaceBehavior`: allows the update operation unless it acts on a value that itself was explicitly marked as constant. - `ConstNamespaceBehavior`: initially allows insert operations but marks the individual values as const. Additionally provides a `Freeze()` member function. After this was called, updates are rejected unless a special `overrideFrozen` flag is set explicitly. This marvel of object-oriented programming can be replaced with a simple bool. This commit basically replaces `Namespace::m_Behavior` with `Namespace::m_ConstValues` and inlines the behavior functions where they were called. While doing so, the code was slightly simplified by assuming that `m_ConstValues` is true if `m_Frozen` is true. This is similar to what the API allowed in the old code as you could only freeze a `ConstNamespaceBehavior`. However, this PR moves the `Freeze()` member function and the related `m_Freeze` member variable to the `Namespace` class. So now the API allows any namespace to be frozen. The new code also makes sense with the previously mentioned simplification: a `Namespace` with `m_ConstValues = false` can be modified without restrictions until `Freeze()` is called. When this is done, it becomes read-only. The changes outside of `namespace.*` just adapt the code to the slightly changed API.