Skip to content

Commit 4bebfb1

Browse files
authored
Merge branch 'master' into development/adding-more-to-actions
2 parents f5c0477 + 623e372 commit 4bebfb1

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Dictionary/Dictionary.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,39 @@ namespace Plugin {
288288
return (result);
289289
}
290290

291+
bool Dictionary::IsUnderRegisteredNamespace(const string& registeredPath, const string& changedPath) const
292+
{
293+
const string& delimiter = Delimiter();
294+
295+
bool result = false;
296+
297+
if (registeredPath == delimiter) {
298+
result = true;
299+
} else if (changedPath.compare(0, registeredPath.size(), registeredPath) == 0) {
300+
if (changedPath.size() == registeredPath.size()) {
301+
result = true;
302+
} else if (changedPath.at(registeredPath.size()) == delimiter[0]) {
303+
result = true;
304+
}
305+
}
306+
307+
return result;
308+
}
291309

292310
void Dictionary::NotifyForUpdate(const string& path, const string& key, const string& value) const
293311
{
294312
ObserverMap::const_iterator index(_observers.cbegin());
295313

296314
while (index != _observers.cend()) {
297-
if (index->first == path) {
315+
if (IsUnderRegisteredNamespace(index->first, path)) {
298316
index->second->Modified(path, key, value);
299317
}
300318
index++;
301319
}
302320

303-
Exchange::JDictionary::Event::Modified(*this, path, key, value);
321+
Exchange::JDictionary::Event::Modified(*this, path, key, value, [&path, this](const string&, const string& index_) -> bool {
322+
return (this->IsUnderRegisteredNamespace(index_, path));
323+
});
304324
}
305325

306326
// Direct method to Set a value for a key in a certain namespace from the dictionary.

Dictionary/Dictionary.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ namespace Plugin {
321321
bool CreateInternalDictionary(const string& currentSpace, const NameSpace& data);
322322
void CreateExternalDictionary(const string& currentSpace, NameSpace& data) const;
323323
inline void NotifyForUpdate(const string& path, const string& key, const string& value) const;
324+
bool IsUnderRegisteredNamespace(const string& registeredPath, const string& changedPath) const;
324325

325326
const string& Delimiter() const {
326327
static string delimiter{ Exchange::IDictionary::namespaceDelimiter };

0 commit comments

Comments
 (0)