13#ifndef RTCTK_COMPONENTFRAMEWORK_REPOSITORYSUBSCRIBERIF_HPP
14#define RTCTK_COMPONENTFRAMEWORK_REPOSITORYSUBSCRIBERIF_HPP
37 using RtctkException::RtctkException;
121 std::is_convertible_v<F, NotifyCallbackType> or
122 (not std::is_same_v<T, void> and
123 std::is_convertible_v<
151#pragma GCC diagnostic push
152#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
191 bool value_requested,
193 const std::type_info& type,
197 , m_value_requested(value_requested)
200 , m_removed_callback(removed_callback)
201 , m_newvalue_callback(newvalue_callback) {
206 const std::type_info& type,
209 :
Parameters(path, true, buffer, type, removed_callback, newvalue_callback) {
216 return m_value_requested;
221 [[deprecated]]
inline const std::type_info&
GetType()
const {
225 return m_removed_callback;
228 return m_newvalue_callback;
236 bool m_value_requested;
242 const std::type_info* m_type;
249 template <
typename F>
250 [[deprecated(
"Use BatchRequest instead.")]]
void
253 template <
typename T,
typename F>
254 [[deprecated(
"Use BatchRequest instead.")]]
void
255 AddNewValueHandler(
const DataPointPath& path, T& buffer, F handler);
257 template <
typename F>
258 [[deprecated(
"Use BatchRequest instead.")]]
void
259 AddValueChangedHandler(
const DataPointPath& path, F handler);
261 [[deprecated(
"Use BatchRequest instead.")]]
inline const std::vector<Parameters>&
267 std::vector<Parameters> m_params;
297 const bool unsubscribe_removed,
298 const bool unsubscribe_newvalue)
300 , m_unsubscribe_removed(unsubscribe_removed)
301 , m_unsubscribe_newvalue(unsubscribe_newvalue) {
308 return m_unsubscribe_removed;
311 return m_unsubscribe_newvalue;
319 bool m_unsubscribe_removed;
322 bool m_unsubscribe_newvalue;
337 [[deprecated(
"Use BatchRequest instead.")]]
void
352 [[deprecated(
"Use BatchRequest instead.")]]
void
355 [[deprecated(
"Use BatchRequest instead.")]]
inline const std::vector<Parameters>&
361 std::vector<Parameters> m_params;
407 SendSubscribeRequest(
const SubscribeRequest& request)
const;
446 using NotifyHandler [[deprecated]] = std::function<void(
const DataPointPath& path)>;
449 template <
typename T>
450 using ValueHandler [[deprecated]] = std::function<void(
const DataPointPath& path, T& value)>;
455 std::enable_if_t<not std::is_convertible_v<T, RepositorySubscriberIf::NotifyCallbackType>,
457 [[deprecated]]
void Subscribe(
const DataPointPath& path, T& buffer, F handler)
const;
482 template <
typename F>
485 if constexpr (std::is_convertible_v<F, NotifyHandler>) {
489 static_assert(std::is_convertible_v<F, NotifyHandler>,
"Feature not supported");
491 SendSubscribeRequest(subscribe).Wait();
511 [[deprecated]]
void Unsubscribe(
const DataPointPath& path)
const;
516 friend class PyRepositorySubscriberIf;
517 std::any m_extra_objects;
520 mutable std::mutex m_subscriptions_mutex;
523 mutable std::map<DataPointPath, std::vector<SubscriptionId>> m_new_value_subscriptions;
524 mutable std::map<DataPointPath, std::vector<SubscriptionId>> m_removed_subscriptions;
526#pragma GCC diagnostic pop
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:74
An object used to wait for a request to complete.
Definition repositoryIf.hpp:1370
Abstract interface providing basic read and write facilities to a repository.
Definition repositoryIf.hpp:104
std::function< void(const DataPointPath &)> CallbackType
Signature of the callback functions that can be registered with the repository requests.
Definition repositoryIf.hpp:114
Definition repositorySubscriberIf.hpp:83
Definition repositorySubscriberIf.hpp:40
A structure to hold the arguments passed to the Add method.
Definition repositorySubscriberIf.hpp:172
const std::type_info & GetType() const
Definition repositorySubscriberIf.hpp:221
void * GetBuffer() const
Definition repositorySubscriberIf.hpp:218
const CallbackType & GetRemovedCallback() const
Definition repositorySubscriberIf.hpp:224
const DataPointPath & GetPath() const
Definition repositorySubscriberIf.hpp:212
Parameters(const DataPointPath &path, bool value_requested, void *buffer, const std::type_info &type, const CallbackType &removed_callback, const CallbackType &newvalue_callback)
Allows to explicitly construct a complete parameters structure.
Definition repositorySubscriberIf.hpp:190
Parameters(const DataPointPath &path, void *buffer, const std::type_info &type, const CallbackType &removed_callback, const CallbackType &newvalue_callback)
Definition repositorySubscriberIf.hpp:204
std::function< void(const DataPointPath &)> CallbackType
callback type that is used internally
Definition repositorySubscriberIf.hpp:175
const bool GetValueRequested() const
Definition repositorySubscriberIf.hpp:215
const CallbackType & GetNewValueCallback() const
Definition repositorySubscriberIf.hpp:227
A request object to pass information about datapoints to subscribe to.
Definition repositorySubscriberIf.hpp:166
const std::vector< Parameters > & GetParams() const
Definition repositorySubscriberIf.hpp:262
void AddValueChangedHandler(const DataPointPath &path, F handler)
Adds a request to subscribe to value change notifications for a particular datapoint.
Definition repositorySubscriberIf.ipp:202
Definition repositorySubscriberIf.hpp:35
RAII wrapper class used to manage the life-time of individual subscriptions.
Definition repositorySubscriberIf.hpp:64
std::function< void()> UnsubscribeMethod
Definition repositorySubscriberIf.hpp:66
Subscription(const Subscription &)=delete
Subscription & operator=(const Subscription &)=delete
A structure to hold the arguments passed with one of the Add methods.
Definition repositorySubscriberIf.hpp:284
const DataPointPath & GetPath() const
Definition repositorySubscriberIf.hpp:304
bool GetUnsubscribeRemoved() const
Definition repositorySubscriberIf.hpp:307
bool GetUnsubscribeNewValue() const
Definition repositorySubscriberIf.hpp:310
Parameters(const DataPointPath &path, const bool unsubscribe_removed, const bool unsubscribe_newvalue)
Allows to explicitly construct a complete parameters structure.
Definition repositorySubscriberIf.hpp:296
A request object to pass information about datapoints to unsubscribe from.
Definition repositorySubscriberIf.hpp:278
const std::vector< Parameters > & GetParams() const
Definition repositorySubscriberIf.hpp:356
Abstract interface providing I/O and additional subscription facilities for a repository.
Definition repositorySubscriberIf.hpp:27
std::function< void(std::exception_ptr)> ErrorCallbackType
Definition repositorySubscriberIf.hpp:49
void Subscribe(const DataPointPath &path, F handler) const
A convenience template function that will register a callback to receive datapoint value change notif...
Definition repositorySubscriberIf.hpp:483
virtual ~RepositorySubscriberIf()=default
std::function< void(const DataPointPath &, T &, const MetaData &)> ValueCallbackType
Definition repositorySubscriberIf.hpp:46
std::function< void(const DataPointPath &, const MetaData &)> NotifyCallbackType
Definition repositorySubscriberIf.hpp:48
size_t SubscriptionId
Definition repositorySubscriberIf.hpp:51
RepositorySubscriberIf()=default
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:211
#define RTCTK_API
Helper to indicate that a class or function must be exported in the public symbol table.
Definition config.hpp:33
Definition commandReplier.cpp:22
uint64_t RtcUInt64
Definition repositoryIf.hpp:61
DataPointPath m_path
Definition populateConfig.cpp:168
Header file for RepositoryIf and related base classes.
Implementation file for RepositorySubscriberIf template methods and related classes.
Definition repositorySubscriberIf.ipp:41