RTC Toolkit 6.0.0-pre2
Loading...
Searching...
No Matches
rtctk::componentFramework::RepositorySubscriberIf Class Reference

Abstract interface providing I/O and additional subscription facilities for a repository. More...

#include <rtctk/componentFramework/repositorySubscriberIf.hpp>

Inheritance diagram for rtctk::componentFramework::RepositorySubscriberIf:
rtctk::componentFramework::RepositoryIf rtctk::componentFramework::OldbIf rtctk::componentFramework::RuntimeRepoIf rtctk::componentFramework::test::FakeRepositorySubscriber rtctk::componentFramework::OldbAdapter rtctk::componentFramework::test::FakeOldbIf rtctk::componentFramework::RuntimeRepoAdapter rtctk::componentFramework::test::FakeRuntimeRepoIf rtctk::componentFramework::test::MockRuntimeRepoIf rtctk::componentFramework::test::FakeOldbIf rtctk::componentFramework::test::FakeRuntimeRepoIf rtctk::componentFramework::test::MockRuntimeRepoIf

Classes

class  BatchRequest
 
class  SequenceIdMissmatch
 
class  Subscription
 RAII wrapper class used to manage the life-time of individual subscriptions. More...
 
class  SubscriptionError
 

Public Types

template<typename T>
using ValueCallbackType = std::function<void(const DataPointPath&, T&, const MetaData&)>
 
using NotifyCallbackType = std::function<void(const DataPointPath&, const MetaData&)>
 
using ErrorCallbackType = std::function<void(std::exception_ptr)>
 
using SubscriptionId = size_t
 
- Public Types inherited from rtctk::componentFramework::RepositoryIf
using PathList = std::vector<DataPointPath>
 
using Clock = taiclock::TaiClock
 
using Timestamp = Clock::time_point
 
using CallbackType = std::function<void(const DataPointPath&)>
 Signature of the callback functions that can be registered with the repository requests.
 

Public Member Functions

 RepositorySubscriberIf ()=default
 
template<typename T = void, typename F>
Subscription Subscribe (const DataPointPath &path, const F &cb_value, const ErrorCallbackType &cb_error) const
 Subscribes to datapoint values change events by registering callbacks.
 
Subscription Subscribe (const CallbackType &cb_created, const CallbackType &cb_deleted, const ErrorCallbackType &cb_error) const
 Subscribes to datapoint creation and deletion events by registering callbacks.
 
- Public Member Functions inherited from rtctk::componentFramework::RepositoryIf
 RepositoryIf ()=default
 
virtual ~RepositoryIf ()=default
 
BatchResponse SendRequest (const BatchRequest &request)
 
BatchResponse SendRequest (const BatchRequest &request) const
 
template<typename T>
void CreateDataPoint (const DataPointPath &path)
 Creates a new empty datapoint in the repository.
 
template<typename T>
void CreateDataPoint (const DataPointPath &path, const T &initial_value)
 Creates a new datapoint in the repository with an initial value.
 
void CreateDataPoint (const DataPointPath &path, const char *initial_value)
 
void DeleteDataPoint (const DataPointPath &path, bool recurse=false)
 Deletes a datapoint.
 
const std::type_info & GetDataPointType (const DataPointPath &path) const
 Fetches the type of the datapoint.
 
size_t GetDataPointSize (const DataPointPath &path) const
 Fetches the size of the datapoint's data.
 
RtcVectorUInt64 GetDataPointShape (const DataPointPath &path) const
 Fetches the shape of the datapoint's data.
 
bool DataPointExists (const DataPointPath &path) const
 Checks for the existence of a datapoint in the repository.
 
std::pair< PathList, PathListGetChildren (const DataPointPath &path, bool recurse=false) const
 Queries the child datapoints and paths for a given parent path.
 
template<typename T>
GetDataPoint (const DataPointPath &path) const
 Fetches a datapoint from the repository.
 
template<typename T>
std::optional< T > TryGetDataPoint (const DataPointPath &path) const
 Fetches a datapoint from the repository.
 
template<typename T>
void SetDataPoint (const DataPointPath &path, const T &value)
 Sets a datapoint in the repository.
 
void SetDataPoint (const DataPointPath &path, const char *value)
 
template<typename T>
void ReadDataPoint (const DataPointPath &path, T &buffer) const
 Reads a datapoint from the repository.
 
template<typename T>
void WriteDataPoint (const DataPointPath &path, const T &buffer)
 Writes a datapoint to the repository.
 
void WriteDataPoint (const DataPointPath &path, const char *buffer)
 
template<typename... T>
void WriteDataPoints (const T &... args)
 
template<typename... T>
void ReadDataPoints (T &... args) const
 

Additional Inherited Members

- Static Public Member Functions inherited from rtctk::componentFramework::RepositoryIf
static const std::type_info & StringToType (const std::string &arg)
 Converts an RTC datapoint type string to a type_info.
 
static std::string TypeToString (const std::type_info &arg)
 Converts a type_info to an RTC datapoint type string.
 
static std::any MakeAnyBuffer (const MetaData &metadata)
 Helper method to create an std::any buffer compatible with a specific datapoint.
 
- Protected Types inherited from rtctk::componentFramework::RepositoryIf
using RequestList = std::vector<std::any>
 
- Protected Member Functions inherited from rtctk::componentFramework::RepositoryIf
virtual BatchResponse ProcessRequests (const RequestList &requests)=0
 

Detailed Description

Abstract interface providing I/O and additional subscription facilities for a repository.

Thread Safety
thread-safe

Member Typedef Documentation

◆ ErrorCallbackType

using rtctk::componentFramework::RepositorySubscriberIf::ErrorCallbackType = std::function<void(std::exception_ptr)>

◆ NotifyCallbackType

◆ SubscriptionId

◆ ValueCallbackType

template<typename T>
using rtctk::componentFramework::RepositorySubscriberIf::ValueCallbackType = std::function<void(const DataPointPath&, T&, const MetaData&)>

Constructor & Destructor Documentation

◆ RepositorySubscriberIf()

rtctk::componentFramework::RepositorySubscriberIf::RepositorySubscriberIf ( )
default

Member Function Documentation

◆ Subscribe() [1/2]

RepositorySubscriberIf::Subscription rtctk::componentFramework::RepositorySubscriberIf::Subscribe ( const CallbackType & cb_created,
const CallbackType & cb_deleted,
const ErrorCallbackType & cb_error ) const

Subscribes to datapoint creation and deletion events by registering callbacks.

This function can be used to register callback functions that will be called whenever a datapoint created or datapoint deleted notification is received.

Note
This is a synchronous method that blocks until the registration has been completed for the datapoint.
Parameters
[in]cb_createdA handler functional to invoke after a datapoint was created.
[in]cb_deletedA handler functional to invoke after a datapoint was deleted.
[in]cb_errorA handler functional to invoke after a subscription error was detected.
Returns
A moveable subscription object that controls the life-time of the subscription.
Thread Safety
thread-safe
Exception Safety
basic

◆ Subscribe() [2/2]

template<typename T, typename F>
RepositorySubscriberIf::Subscription rtctk::componentFramework::RepositorySubscriberIf::Subscribe ( const DataPointPath & path,
const F & cb_value,
const ErrorCallbackType & cb_error ) const

Subscribes to datapoint values change events by registering callbacks.

This is a convenience function that can be used to register a callback function that will be called whenever a datapoint value change notification is received and a new value is available. Either a notification only callback, or a callback that also receives the value can be registered. In the second case, a new buffer object will be allocated by the API and filled with the new value for every new value notification. This buffer is then passed onto the registered callback by reference, since the ownership of the memory for the buffer remains with the API.

Note
This is a synchronous method that blocks until the registration has been completed for the datapoint.
Template Parameters
TThe datapoint type.
FThe type of the cb_value callback function. It can be any callable that has a function signature compatible with:
void(const DataPointPath& path, const MetaData& metadata)
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:77
Class for passing/receiving metadata to/from the repository.
Definition repositoryIf.hpp:146
or
void(const DataPointPath& path, T& buffer, const MetaData& metadata)
Parameters
[in]pathThe path of the datapoint to subscribe to.
[in]cb_valueA handler function, lambda or functional to invoke after a new datapoint value is received.
[in]cb_errorA functional to invoke after a subscription error was detected.
Returns
A moveable subscription object that controls the life-time of the subscription.
Thread Safety
thread-safe
Exception Safety
basic

The documentation for this class was generated from the following files: