|
@@ -25,15 +25,15 @@ namespace Plugin {
|
|
|
25
25
|
|
|
26
26
|
namespace {
|
|
27
27
|
|
|
28
|
-
static Metadata<InProcessConfigPreconditions>metadata(
|
|
28
|
+
static Metadata<InProcessConfigPreconditions> metadata(
|
|
29
29
|
// Version
|
|
30
30
|
1, 0, 0,
|
|
31
31
|
// Preconditions
|
|
32
|
-
{
|
|
32
|
+
{},
|
|
33
33
|
// Terminations
|
|
34
|
-
{
|
|
34
|
+
{},
|
|
35
35
|
// Controls
|
|
36
|
-
{
|
|
36
|
+
{}
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -56,10 +56,33 @@ namespace Plugin {
|
|
|
56
56
|
return (string());
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
Core::hresult InProcessConfigPreconditions::Register(
|
|
59
|
+
Core::hresult InProcessConfigPreconditions::Register(Exchange::IDictionary::INotification* notification) {
|
|
60
|
+
ASSERT(notification != nullptr);
|
|
61
|
+
|
|
62
|
+
_adminLock.Lock();
|
|
63
|
+
auto item = std::find(_dictionaryNotification.begin(), _dictionaryNotification.end(), notification);
|
|
64
|
+
ASSERT(item == _dictionaryNotification.end());
|
|
65
|
+
|
|
66
|
+
if (item == _dictionaryNotification.end()) {
|
|
67
|
+
notification->AddRef();
|
|
68
|
+
_dictionaryNotification.push_back(notification);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_adminLock.Unlock();
|
|
60
72
|
return Core::ERROR_NONE;
|
|
61
73
|
}
|
|
62
|
-
Core::hresult InProcessConfigPreconditions::Unregister(const
|
|
74
|
+
Core::hresult InProcessConfigPreconditions::Unregister(const Exchange::IDictionary::INotification* notification) {
|
|
75
|
+
ASSERT(notification != nullptr);
|
|
76
|
+
|
|
77
|
+
_adminLock.Lock();
|
|
78
|
+
auto item = std::find(_dictionaryNotification.begin(), _dictionaryNotification.end(), notification);
|
|
79
|
+
ASSERT(item != _dictionaryNotification.end());
|
|
80
|
+
|
|
81
|
+
if (item != _dictionaryNotification.end()) {
|
|
82
|
+
_dictionaryNotification.erase(item);
|
|
83
|
+
notification->Release();
|
|
84
|
+
}
|
|
85
|
+
_adminLock.Unlock();
|
|
63
86
|
return Core::ERROR_NONE;
|
|
64
87
|
}
|
|
65
88
|
Core::hresult InProcessConfigPreconditions::Get(const string& /* path */, const string& /* key */, string& /* value */ /* @out */) const {
|
|
@@ -71,5 +94,13 @@ namespace Plugin {
|
|
|
71
94
|
Core::hresult InProcessConfigPreconditions::PathEntries(const string& /* path */, IDictionary::IPathIterator*& /* entries */ /* @out */) const {
|
|
72
95
|
return Core::ERROR_NONE;
|
|
73
96
|
}
|
|
97
|
+
|
|
98
|
+
void InProcessConfigPreconditions::NotifyModified(const string& path /* @index */, const string& key, const string& value) const {
|
|
99
|
+
_adminLock.Lock();
|
|
100
|
+
for (auto* notification : _dictionaryNotification) {
|
|
101
|
+
notification->Modified(path, key, value);
|
|
102
|
+
}
|
|
103
|
+
_adminLock.Unlock();
|
|
104
|
+
}
|
|
74
105
|
} // Plugin
|
|
75
106
|
} // Thunder
|
|
@@ -42,6 +42,7 @@ namespace Plugin {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
~InProcessConfigPreconditions() override = default;
|
|
45
|
+
private:
|
|
45
46
|
class Config : public Core::JSON::Container {
|
|
46
47
|
public:
|
|
47
48
|
Config(const Config&) = delete;
|
|
@@ -86,6 +87,8 @@ namespace Plugin {
|
|
|
86
87
|
private:
|
|
87
88
|
using DictionaryNotificationContainer = std::vector<Exchange::IDictionary::INotification*>;
|
|
88
89
|
|
|
90
|
+
void NotifyModified(const string& /* path */ /* @index */, const string& /* key */, const string& /* value */) const;
|
|
91
|
+
|
|
89
92
|
mutable Core::CriticalSection _adminLock;
|
|
90
93
|
DictionaryNotificationContainer _dictionaryNotification;
|
|
91
94
|
};
|