RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
rtctk::componentFramework::RuntimeRepoAdapter Class Reference

Implementation of the Runtime Configuration Repository Adapter. More...

#include <rtctk/componentFramework/runtimeRepoAdapter.hpp>

Inheritance diagram for rtctk::componentFramework::RuntimeRepoAdapter:
rtctk::componentFramework::RuntimeRepoIf rtctk::componentFramework::RepositorySubscriberIf rtctk::componentFramework::RepositoryIf

Classes

struct  CreateDeleteSubscription
 
struct  ValueSubscription
 

Public Member Functions

 RuntimeRepoAdapter ()=delete
 Do not allow construction with no arguments.
 
 RuntimeRepoAdapter (const RuntimeRepoAdapter &)=delete
 This class cannot be copy constructed.
 
RuntimeRepoAdapteroperator= (const RuntimeRepoAdapter &)=delete
 This class cannot be copy assigned.
 
 RuntimeRepoAdapter (RuntimeRepoAdapter &&)=default
 Objects of this class can be moved.
 
RuntimeRepoAdapteroperator= (RuntimeRepoAdapter &&)=default
 Objects of this class can be moved with the move assignment operator.
 
 RuntimeRepoAdapter (const elt::mal::Uri &baseuri)
 Constructs an adapter for the Runtime Configuration Repository service.
 
virtual ~RuntimeRepoAdapter ()
 
- Public Member Functions inherited from rtctk::componentFramework::RuntimeRepoIf
virtual ~RuntimeRepoIf ()=default
 
std::string GetDefaultServerAlias () const
 Get the current default server alias setting.
 
void SetDefaultServerAlias (const std::string &server_alias)
 Set the current default server alias setting.
 
virtual void CreateDataPoint (const DataPointPath &path, const std::type_info &type, const std::string &server_alias)
 Creates a new datapoint in the repository with a specified type on a particular external Redis server.
 
template<typename T >
void CreateDataPoint (const DataPointPath &path, const T default_value, const std::string &server_alias)
 Creates a new datapoint in the repository with a default value on a particular external Redis server.
 
virtual std::string GetServerAlias (const DataPointPath &path) const
 Fetches the server alias for a specific datapoint.
 
template<typename T >
void CreateDataPoint (const DataPointPath &path)
 Creates a new 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)
 
virtual void CreateDataPoint (const DataPointPath &path, const std::type_info &type)
 Creates a new datapoint in the repository with a specified type.
 
- Public Member Functions inherited from rtctk::componentFramework::RepositorySubscriberIf
 RepositorySubscriberIf ()=default
 
virtual ~RepositorySubscriberIf ()=default
 
template<typename T = void, typename F , std::enable_if_t< std::is_convertible_v< F, NotifyCallbackType > or(not std::is_same_v< T, void > and std::is_convertible_v< F, ValueCallbackType< std::conditional_t< std::is_same_v< T, void >, std::byte, T > > >), bool > = true>
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.
 
virtual RepositoryIf::Response SendSubscribeRequest (const SubscribeRequest &request) const
 This is called to asynchronously send a subscription request for datapoints.
 
virtual RepositoryIf::Response SendUnsubscribeRequest (const UnsubscribeRequest &request) const
 This is called to asynchronously send a request to unsubscribe from various notifications.
 
template<typename T , typename F , std::enable_if_t< not std::is_convertible_v< T, RepositorySubscriberIf::NotifyCallbackType >, bool > = true>
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 synchronous manner.
 
template<typename F >
void Subscribe (const DataPointPath &path, F handler) const
 A convenience template function that will register a callback to receive datapoint value change notifications in a synchronous manner.
 
void Unsubscribe (const DataPointPath &path) const
 A simple convenience function that will deregister all callbacks for receiving new datapoint values.
 
- 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 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 >
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
 
virtual Response SendReadRequest (const ReadRequest &request) const
 Sends a request to read data from the repository.
 
virtual Response SendWriteRequest (const WriteRequest &request)
 Sends a request to write data to the repository.
 

Static Public Attributes

static const std::string SUPPORTED_URI_SCHEME = "rtr"
 

Protected Types

using DispatchFunction = std::function<void(RuntimeRepoAdapter*, std::any&, RtrClient&)>
 
using LookupTable = std::unordered_map<std::type_index, DispatchFunction>
 
using TableEntry = typename LookupTable::value_type
 
- Protected Types inherited from rtctk::componentFramework::RepositoryIf
using RequestList = std::vector<std::any>
 

Protected Member Functions

BatchResponse ProcessRequests (const RequestList &requests) override
 
template<typename T >
void CreateImpl (detail::CreateRequest< T > &, RtrClient &)
 
template<typename T >
void WriteImpl (detail::WriteRequest< T > &, RtrClient &)
 
template<typename T >
void ReadImpl (detail::ReadRequest< T > &, RtrClient &)
 
template<typename T >
void PartialWriteImpl (detail::PartialWriteRequest< T > &, RtrClient &)
 
template<typename T >
void PartialReadImpl (detail::PartialReadRequest< T > &, RtrClient &)
 
void WriteMetaDataImpl (detail::WriteMetaDataRequest &, RtrClient &)
 
void ReadMetaDataImpl (detail::ReadMetaDataRequest &, RtrClient &)
 
void DeleteImpl (detail::DeleteRequest &, RtrClient &)
 
void ExistsImpl (detail::ExistsRequest &, RtrClient &)
 
void GetChildrenImpl (detail::GetChildrenRequest &, RtrClient &)
 
void CreateLinkImpl (detail::CreateSymlinkRequest &, RtrClient &)
 
void UpdateLinkImpl (detail::UpdateSymlinkRequest &, RtrClient &)
 
void SubscribeImpl (detail::ValueSubscribeRequest &, RtrClient &)
 
void CreateDeleteSubscribeImpl (detail::CreateDeleteSubscribeRequest &, RtrClient &)
 
void UnsubscribeImpl (detail::UnsubscribeRequest &, RtrClient &)
 
virtual void InvokeRequestHandler (std::any &, RtrClient &)
 
void SubscriptionCallbackHandler (const JsonPayload &)
 
- Protected Member Functions inherited from rtctk::componentFramework::RepositoryIf
virtual void DeleteDataPointLegacy (const DataPointPath &path)
 Deletes a datapoint.
 
virtual const std::type_info & GetDataPointTypeLegacy (const DataPointPath &path) const
 Fetches the type of the datapoint.
 
virtual size_t GetDataPointSizeLegacy (const DataPointPath &path) const
 Fetches the size of the datapoint's data.
 
virtual bool DataPointExistsLegacy (const DataPointPath &path) const
 Checks for the existence of a datapoint in the repository.
 
virtual std::pair< PathList, PathListGetChildrenLegacy (const DataPointPath &path) const
 Queries the datapoints and child paths for a given path.
 

Static Protected Member Functions

template<typename T >
static TableEntry Bind (void(RuntimeRepoAdapter::*method)(T &, RtrClient &))
 

Protected Attributes

std::string m_ip
 
uint16_t m_port
 
std::string m_topic
 
std::mutex m_mutex
 Mutex for synchronising access to subscriptions.
 
std::list< ValueSubscriptionm_value_subscriptions
 
std::list< CreateDeleteSubscriptionm_create_delete_subscriptions
 
MalDdsEventService m_mal_event_service
 
EventServiceIfm_event_service
 
std::unique_ptr< EventSubscriberIfm_event_subscriber
 

Static Protected Attributes

static const LookupTable S_REQUEST_DISPATCHER_TABLE
 

Additional Inherited Members

- Public Types inherited from rtctk::componentFramework::RuntimeRepoIf
using AdapterIdType = elt::mal::Uri
 The type used to distinguish between different adapters implementing RuntimeRepoIf.
 
- Public Types inherited from rtctk::componentFramework::RepositorySubscriberIf
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.
 
- Static Public Member Functions inherited from rtctk::componentFramework::RuntimeRepoIf
static std::unique_ptr< RuntimeRepoIfCreateAdapter (const elt::mal::Uri &uri)
 Factory method used to create the appropriate Runtime Configuration Repository adapter depending on the URI scheme.
 
- Static Public Member Functions inherited from rtctk::componentFramework::RepositoryIf
static const std::type_info & StringToType (const std::string &arg)
 Converts an RTC type string to a type_info.
 
static std::string TypeToString (const std::type_info &arg)
 Converts a type_info to an RTC type string.
 

Detailed Description

Implementation of the Runtime Configuration Repository Adapter.

Member Typedef Documentation

◆ DispatchFunction

◆ LookupTable

using rtctk::componentFramework::RuntimeRepoAdapter::LookupTable = std::unordered_map<std::type_index, DispatchFunction>
protected

◆ TableEntry

Constructor & Destructor Documentation

◆ RuntimeRepoAdapter() [1/4]

rtctk::componentFramework::RuntimeRepoAdapter::RuntimeRepoAdapter ( )
delete

Do not allow construction with no arguments.

◆ RuntimeRepoAdapter() [2/4]

rtctk::componentFramework::RuntimeRepoAdapter::RuntimeRepoAdapter ( const RuntimeRepoAdapter & )
delete

This class cannot be copy constructed.

◆ RuntimeRepoAdapter() [3/4]

rtctk::componentFramework::RuntimeRepoAdapter::RuntimeRepoAdapter ( RuntimeRepoAdapter && )
default

Objects of this class can be moved.

◆ RuntimeRepoAdapter() [4/4]

rtctk::componentFramework::RuntimeRepoAdapter::RuntimeRepoAdapter ( const elt::mal::Uri & baseuri)
explicit

Constructs an adapter for the Runtime Configuration Repository service.

Parameters
[in]baseuriA URI with an RTR scheme, containing an IP, port and pub/sub topic name. E.g.: rtr://127.0.0.1:8000/rtr_topic

◆ ~RuntimeRepoAdapter()

rtctk::componentFramework::RuntimeRepoAdapter::~RuntimeRepoAdapter ( )
virtual

Member Function Documentation

◆ Bind()

template<typename T >
RuntimeRepoAdapter::TableEntry rtctk::componentFramework::RuntimeRepoAdapter::Bind ( void(RuntimeRepoAdapter::*)(T &, RtrClient &) method)
staticprotected

◆ CreateDeleteSubscribeImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::CreateDeleteSubscribeImpl ( detail::CreateDeleteSubscribeRequest & req,
RtrClient & client )
protected

◆ CreateImpl()

template<typename T >
void rtctk::componentFramework::RuntimeRepoAdapter::CreateImpl ( detail::CreateRequest< T > & req,
RtrClient & client )
protected

◆ CreateLinkImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::CreateLinkImpl ( detail::CreateSymlinkRequest & req,
RtrClient & client )
protected

◆ DeleteImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::DeleteImpl ( detail::DeleteRequest & req,
RtrClient & client )
protected

◆ ExistsImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::ExistsImpl ( detail::ExistsRequest & req,
RtrClient & client )
protected

◆ GetChildrenImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::GetChildrenImpl ( detail::GetChildrenRequest & req,
RtrClient & client )
protected

◆ InvokeRequestHandler()

void rtctk::componentFramework::RuntimeRepoAdapter::InvokeRequestHandler ( std::any & request,
RtrClient & client )
protectedvirtual

◆ operator=() [1/2]

RuntimeRepoAdapter & rtctk::componentFramework::RuntimeRepoAdapter::operator= ( const RuntimeRepoAdapter & )
delete

This class cannot be copy assigned.

◆ operator=() [2/2]

RuntimeRepoAdapter & rtctk::componentFramework::RuntimeRepoAdapter::operator= ( RuntimeRepoAdapter && )
default

Objects of this class can be moved with the move assignment operator.

◆ PartialReadImpl()

template<typename T >
void rtctk::componentFramework::RuntimeRepoAdapter::PartialReadImpl ( detail::PartialReadRequest< T > & req,
RtrClient & client )
protected

◆ PartialWriteImpl()

template<typename T >
void rtctk::componentFramework::RuntimeRepoAdapter::PartialWriteImpl ( detail::PartialWriteRequest< T > & req,
RtrClient & client )
protected

◆ ProcessRequests()

RepositoryIf::BatchResponse rtctk::componentFramework::RuntimeRepoAdapter::ProcessRequests ( const RequestList & requests)
overrideprotectedvirtual

◆ ReadImpl()

template<typename T >
void rtctk::componentFramework::RuntimeRepoAdapter::ReadImpl ( detail::ReadRequest< T > & req,
RtrClient & client )
protected

◆ ReadMetaDataImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::ReadMetaDataImpl ( detail::ReadMetaDataRequest & req,
RtrClient & client )
protected

◆ SubscribeImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::SubscribeImpl ( detail::ValueSubscribeRequest & req,
RtrClient & client )
protected

◆ SubscriptionCallbackHandler()

void rtctk::componentFramework::RuntimeRepoAdapter::SubscriptionCallbackHandler ( const JsonPayload & payload)
protected

◆ UnsubscribeImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::UnsubscribeImpl ( detail::UnsubscribeRequest & req,
RtrClient & client )
protected

◆ UpdateLinkImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::UpdateLinkImpl ( detail::UpdateSymlinkRequest & req,
RtrClient & client )
protected

◆ WriteImpl()

template<typename T >
void rtctk::componentFramework::RuntimeRepoAdapter::WriteImpl ( detail::WriteRequest< T > & req,
RtrClient & client )
protected

◆ WriteMetaDataImpl()

void rtctk::componentFramework::RuntimeRepoAdapter::WriteMetaDataImpl ( detail::WriteMetaDataRequest & req,
RtrClient & client )
protected

Member Data Documentation

◆ m_create_delete_subscriptions

std::list<CreateDeleteSubscription> rtctk::componentFramework::RuntimeRepoAdapter::m_create_delete_subscriptions
protected

◆ m_event_service

EventServiceIf& rtctk::componentFramework::RuntimeRepoAdapter::m_event_service
protected

◆ m_event_subscriber

std::unique_ptr<EventSubscriberIf> rtctk::componentFramework::RuntimeRepoAdapter::m_event_subscriber
protected

◆ m_ip

std::string rtctk::componentFramework::RuntimeRepoAdapter::m_ip
protected

◆ m_mal_event_service

MalDdsEventService rtctk::componentFramework::RuntimeRepoAdapter::m_mal_event_service
protected

◆ m_mutex

std::mutex rtctk::componentFramework::RuntimeRepoAdapter::m_mutex
mutableprotected

Mutex for synchronising access to subscriptions.

◆ m_port

uint16_t rtctk::componentFramework::RuntimeRepoAdapter::m_port
protected

◆ m_topic

std::string rtctk::componentFramework::RuntimeRepoAdapter::m_topic
protected

◆ m_value_subscriptions

std::list<ValueSubscription> rtctk::componentFramework::RuntimeRepoAdapter::m_value_subscriptions
protected

◆ S_REQUEST_DISPATCHER_TABLE

const RuntimeRepoAdapter::LookupTable rtctk::componentFramework::RuntimeRepoAdapter::S_REQUEST_DISPATCHER_TABLE
staticprotected

◆ SUPPORTED_URI_SCHEME

const std::string rtctk::componentFramework::RuntimeRepoAdapter::SUPPORTED_URI_SCHEME = "rtr"
inlinestatic

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