15 #ifndef ACSDKCOMMUNICATIONINTERFACES_COMMUNICATIONPROPERTY_H_ 16 #define ACSDKCOMMUNICATIONINTERFACES_COMMUNICATIONPROPERTY_H_ 26 namespace acsdkCommunicationInterfaces {
42 std::unique_lock<std::mutex> lock(m_propertyMutex);
44 auto weakSubscriptionProxy = m_weakSubscriptionProxy;
45 auto propertyName = m_name;
48 m_staticExecutor.
execute([weakSubscriptionProxy, newValue, propertyName]() {
49 weakSubscriptionProxy->notifyObservers(
51 obs->onCommunicationPropertyChange(propertyName, newValue);
63 std::unique_lock<std::mutex> lock(m_propertyMutex);
74 static std::shared_ptr<CommunicationProperty<T>>
create(
const std::string& name, T initValue,
bool writeable) {
75 return std::shared_ptr<CommunicationProperty<T>>(
new CommunicationProperty(name, initValue, writeable));
92 m_weakSubscriptionProxy->addWeakPtrObserver(subscriber);
93 return !subscriber.expired();
101 m_weakSubscriptionProxy->removeWeakPtrObserver(subscriber);
108 bool notifyOnCommunicationPropertyChange(
const std::string& propertyName, T newValue) {
109 m_weakSubscriptionProxy->notifyObservers(
111 obs->onCommunicationPropertyChange(propertyName, newValue);
123 m_weakSubscriptionProxy{std::make_shared<notifier::Notifier<CommunicationPropertyChangeSubscriber<T>>>()},
126 m_writeable{writeable} {
131 const std::shared_ptr<notifier::Notifier<CommunicationPropertyChangeSubscriber<T>>> m_weakSubscriptionProxy;
140 const bool m_writeable;
143 std::mutex m_propertyMutex;
149 template <
typename T>
155 #endif // ACSDKCOMMUNICATIONINTERFACES_COMMUNICATIONPROPERTY_H_ bool execute(std::function< void()> &&function) noexcept
Schedules a function for execution.
void removeSubscriber(const std::shared_ptr< CommunicationPropertyChangeSubscriber< T >> &subscriber)
Definition: CommunicationProperty.h:100
::std::string string
Definition: gtest-port.h:1097
Single-thread executor implementation.
Definition: Executor.h:45
Definition: CommunicationPropertyChangeSubscriber.h:28
bool isWriteable()
Definition: CommunicationProperty.h:82
static std::shared_ptr< CommunicationProperty< T > > create(const std::string &name, T initValue, bool writeable)
Definition: CommunicationProperty.h:74
bool addSubscriber(const std::weak_ptr< CommunicationPropertyChangeSubscriber< T >> &subscriber)
Definition: CommunicationProperty.h:91
bool setValue(T newValue)
Definition: CommunicationProperty.h:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
T getValue()
Definition: CommunicationProperty.h:62
Definition: CommunicationProperty.h:34
const T & move(const T &t)
Definition: gtest-port.h:1317