.
This commit is contained in:
@@ -324,7 +324,7 @@ public:
|
||||
* \param[in] e event.
|
||||
* \return notified observer count.
|
||||
*/
|
||||
size_t notifyObservers(const _Key& k, const _Event* e) noexcept override {
|
||||
virtual size_t notifyObservers(const _Key& k, const _Event* e) noexcept override {
|
||||
std::lock_guard<std::recursive_mutex> lock(_observersMutex);
|
||||
size_t retval = 0;
|
||||
// We work with a copy so that we can insert/remove observers within a callback.
|
||||
@@ -337,6 +337,27 @@ public:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify observers of a new event.
|
||||
*
|
||||
* \param[in] key observer filter key.
|
||||
* \param[in] substkey key that is send to the observers.
|
||||
* \param[in] e event.
|
||||
* \return notified observer count.
|
||||
*/
|
||||
virtual size_t notifyObservers(const _Key& key, const _Key& substkey, const _Event* e) noexcept override {
|
||||
std::lock_guard<std::recursive_mutex> lock(_observersMutex);
|
||||
size_t retval = 0;
|
||||
// We work with a copy so that we can insert/remove observers within a callback.
|
||||
observers_type tmp = _observers;
|
||||
auto ol = tmp.equal_range(key);
|
||||
for (auto i = ol.first; i != ol.second; i++) {
|
||||
i->second->notificationReceived(this, substkey, e);
|
||||
retval++;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -269,6 +269,18 @@ public:
|
||||
*/
|
||||
virtual size_t notifyObservers(const _Key& key, const _Event* e) noexcept = 0;
|
||||
|
||||
/**
|
||||
* Notify observers of a new event.
|
||||
*
|
||||
* The purpose of this function is to implement an all-events key.
|
||||
*
|
||||
* \param[in] key observer filter key.
|
||||
* \param[in] substkey key that is send to the observers.
|
||||
* \param[in] e event.
|
||||
* \return notified observer count.
|
||||
*/
|
||||
virtual size_t notifyObservers(const _Key& key, const _Key& substkey, const _Event* e) noexcept = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user