13#ifndef RTCTK_COMPONENTFRAMEWORK_REPOSITORYSUBSCRIBERIF_HPP
14#define RTCTK_COMPONENTFRAMEWORK_REPOSITORYSUBSCRIBERIF_HPP
64 const std::type_info& type,
68 , m_value_requested(value_requested)
71 , m_removed_callback(removed_callback)
72 , m_newvalue_callback(newvalue_callback) {
77 const std::type_info& type,
80 :
Parameters(path, true, buffer, type, removed_callback, newvalue_callback) {
87 return m_value_requested;
92 inline const std::type_info&
GetType()
const {
96 return m_removed_callback;
99 return m_newvalue_callback;
107 bool m_value_requested;
113 const std::type_info* m_type;
120 template <
typename F>
123 template <
typename T,
typename F>
126 template <
typename F>
129 inline const std::vector<Parameters>&
GetParams()
const {
134 std::vector<Parameters> m_params;
162 const bool unsubscribe_removed,
163 const bool unsubscribe_newvalue)
165 , m_unsubscribe_removed(unsubscribe_removed)
166 , m_unsubscribe_newvalue(unsubscribe_newvalue) {
173 return m_unsubscribe_removed;
176 return m_unsubscribe_newvalue;
184 bool m_unsubscribe_removed;
187 bool m_unsubscribe_newvalue;
218 inline const std::vector<Parameters>&
GetParams()
const {
223 std::vector<Parameters> m_params;
308 template <
typename T>
311 template <
typename T,
typename F>
335 template <
typename F>
338 if constexpr (std::is_convertible_v<F, NotifyHandler>) {
342 static_assert(std::is_convertible_v<F, NotifyHandler>,
"Feature not supported");
368 std::any m_extra_objects;
395 std::is_convertible_v<F, std::function<void(
const DataPointPath&)>>,
396 "The handler callback must have a signature compatible with void(const DataPointPath&).");
397 m_params.push_back(
Parameters(path,
nullptr,
typeid(
void), handler,
nullptr));
428template <
typename T,
typename F>
432 static_assert(std::is_convertible_v<F, ValueHandler<T>>,
433 "The handler callback must have a signature compatible with void(const"
434 " DataPointPath&, T&).");
437 auto callback = [handler, &buffer](
const DataPointPath& path) ->
void {
438 handler(path, buffer);
440 m_params.push_back(
Parameters(path,
true, &buffer,
typeid(buffer),
nullptr, callback));
465 static_assert(std::is_convertible_v<F, NotifyHandler>,
466 "The handler callback must have a signature compatible with void(const"
467 " DataPointPath&).");
470 auto callback = [handler](
const DataPointPath& path) ->
void { handler(path); };
471 m_params.push_back(
Parameters(path,
false,
nullptr,
typeid(
void),
nullptr, callback));
497template <
typename T,
typename F>
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:197
void Wait()
Waits for the request that was sent to the repository to complete.
Definition: repositoryIf.cpp:32
A structure to hold the arguments passed to the Add method.
Definition: repositorySubscriberIf.hpp:43
const std::type_info & GetType() const
Definition: repositorySubscriberIf.hpp:92
void * GetBuffer() const
Definition: repositorySubscriberIf.hpp:89
const CallbackType & GetRemovedCallback() const
Definition: repositorySubscriberIf.hpp:95
const DataPointPath & GetPath() const
Definition: repositorySubscriberIf.hpp:83
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:61
Parameters(const DataPointPath &path, void *buffer, const std::type_info &type, const CallbackType &removed_callback, const CallbackType &newvalue_callback)
Definition: repositorySubscriberIf.hpp:75
std::function< void(const DataPointPath &)> CallbackType
callback type that is used internally
Definition: repositorySubscriberIf.hpp:46
const bool GetValueRequested() const
Definition: repositorySubscriberIf.hpp:86
const CallbackType & GetNewValueCallback() const
Definition: repositorySubscriberIf.hpp:98
A request object to pass information about datapoints to subscribe to.
Definition: repositorySubscriberIf.hpp:37
const std::vector< Parameters > & GetParams() const
Definition: repositorySubscriberIf.hpp:129
void AddNewValueHandler(const DataPointPath &path, T &buffer, F handler)
Adds a request to subscribe to new data values for a particular datapoint.
Definition: repositorySubscriberIf.hpp:429
void AddRemovedHandler(const DataPointPath &path, F handler)
Adds a request to subscribe to removal notifications for a particular datapoint.
Definition: repositorySubscriberIf.hpp:392
void AddValueChangedHandler(const DataPointPath &path, F handler)
Adds a request to subscribe to value change notifications for a particular datapoint.
Definition: repositorySubscriberIf.hpp:463
A structure to hold the arguments passed with one of the Add methods.
Definition: repositorySubscriberIf.hpp:149
const DataPointPath & GetPath() const
Definition: repositorySubscriberIf.hpp:169
bool GetUnsubscribeRemoved() const
Definition: repositorySubscriberIf.hpp:172
bool GetUnsubscribeNewValue() const
Definition: repositorySubscriberIf.hpp:175
Parameters(const DataPointPath &path, const bool unsubscribe_removed, const bool unsubscribe_newvalue)
Allows to explicitly construct a complete parameters structure.
Definition: repositorySubscriberIf.hpp:161
A request object to pass information about datapoints to unsubscribe from.
Definition: repositorySubscriberIf.hpp:143
void AddRemovedHandler(const DataPointPath &path)
Adds a request to unsubscribe from removal notifications.
Definition: repositorySubscriberIf.cpp:20
void AddNewValueHandler(const DataPointPath &path)
Adds a request to unsubscribe from new value notifications for a datapoint.
Definition: repositorySubscriberIf.cpp:24
const std::vector< Parameters > & GetParams() const
Definition: repositorySubscriberIf.hpp:218
Abstract interface providing subscription facilities for a repository.
Definition: repositorySubscriberIf.hpp:29
virtual RepositoryIf::Response SendUnsubscribeRequest(const UnsubscribeRequest &request) const =0
This is called to asynchronously send a request to unsubscribe from various notifications.
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:336
friend class PyRepositorySubscriberIf
Definition: repositorySubscriberIf.hpp:367
virtual RepositoryIf::Response SendSubscribeRequest(const SubscribeRequest &request) const =0
This is called to asynchronously send a subscription request for datapoints.
std::function< void(DataPointPath const &path)> NotifyHandler
Signature of notification callbacks.
Definition: repositorySubscriberIf.hpp:305
virtual ~RepositorySubscriberIf()
Definition: repositorySubscriberIf.cpp:17
void Subscribe(const DataPointPath &path, T &buffer, F handler) const
A convenience template function that will register a callback to receive new datapoint values in a sy...
Definition: repositorySubscriberIf.hpp:498
void Unsubscribe(const DataPointPath &path) const
A simple convenience function that will deregister all callbacks for receiving new datapoint values.
Definition: repositorySubscriberIf.cpp:28
std::function< void(DataPointPath const &path, T &value)> ValueHandler
Signature of value callbacks.
Definition: repositorySubscriberIf.hpp:309
Definition: commandReplier.cpp:22
Header file for RepositoryIf and related base classes.