16 #ifndef ACSDK_NOTIFIER_NOTIFIER_H_ 17 #define ACSDK_NOTIFIER_NOTIFIER_H_ 37 template <
typename ObserverType>
44 void addObserver(
const std::shared_ptr<ObserverType>& observer)
override;
45 void removeObserver(
const std::shared_ptr<ObserverType>& observer)
override;
48 void notifyObservers(std::function<
void(
const std::shared_ptr<ObserverType>&)> notify)
override;
50 void setAddObserverFunction(std::function<
void(
const std::shared_ptr<ObserverType>&)> addObserverFunc)
override;
54 using Traits = NotifierTraits<ObserverType>;
57 std::unique_ptr<DataInterface> m_data;
60 template <
typename ObserverType>
64 template <
typename ObserverType>
66 m_data->doAddStrongRefObserver(Traits::toVoidPtr(observer));
69 template <
typename ObserverType>
71 m_data->doRemoveObserver(Traits::toVoidPtr(observer));
74 template <
typename ObserverType>
76 m_data->doAddWeakRefObserver(Traits::toVoidPtr(observer.lock()));
79 template <
typename ObserverType>
81 m_data->doRemoveObserver(Traits::toVoidPtr(observer.lock()));
84 template <
typename ObserverType>
86 m_data->doNotifyObservers(Traits::adaptFunction(
std::move(notify)));
89 template <
typename ObserverType>
91 std::function<
void(
const std::shared_ptr<ObserverType>&)> notify) {
92 return m_data->doNotifyObserversInReverse(Traits::adaptFunction(
std::move(notify)));
95 template <
typename ObserverType>
97 std::function<
void(
const std::shared_ptr<ObserverType>&)> addObserverFunc) {
98 m_data->doSetAddObserverFunction(Traits::adaptFunction(
std::move(addObserverFunc)));
104 #endif // ACSDK_NOTIFIER_NOTIFIER_H_ void addObserver(const std::shared_ptr< ObserverType > &observer) override
Add an observer.
Definition: Notifier.h:65
void removeWeakPtrObserver(const std::weak_ptr< ObserverType > &observer) override
Remove an observer.
Definition: Notifier.h:80
Generic implementation of NotifierInterface.
Definition: Notifier.h:38
void notifyObservers(std::function< void(const std::shared_ptr< ObserverType > &)> notify) override
Notify the observers in the order that they were added.
Definition: Notifier.h:85
void setAddObserverFunction(std::function< void(const std::shared_ptr< ObserverType > &)> addObserverFunc) override
Set a function for notifications on an observer additions.
Definition: Notifier.h:96
void removeObserver(const std::shared_ptr< ObserverType > &observer) override
Remove an observer.
Definition: Notifier.h:70
void addWeakPtrObserver(const std::weak_ptr< ObserverType > &observer) override
Add a weak reference to an observer.
Definition: Notifier.h:75
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool notifyObserversInReverse(std::function< void(const std::shared_ptr< ObserverType > &)> notify) override
Notify the observers in the reverse order that they were added.
Definition: Notifier.h:90
Notifier()
Definition: Notifier.h:61
std::unique_ptr< DataInterface > createDataInterface()
Constructs a new instance of DataInterface.
const T & move(const T &t)
Definition: gtest-port.h:1317
Generic observer operations interface.
Definition: NotifierInterface.h:33