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

Base interface for all Runtime Configuration Repository adapters. More...

#include <rtctk/componentFramework/runtimeRepoIf.hpp>

Inheritance diagram for rtctk::componentFramework::RuntimeRepoIf:
rtctk::componentFramework::RepositorySubscriberIf rtctk::componentFramework::RepositoryIf rtctk::componentFramework::RuntimeRepoAdapter rtctk::componentFramework::RuntimeRepoAdapterLegacy rtctk::componentFramework::test::FakeRuntimeRepoIf rtctk::componentFramework::test::MockRuntimeRepoIf

Public Types

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.
 

Public Member Functions

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 Member Functions

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.
 

Additional Inherited Members

- 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
 
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.
 

Detailed Description

Base interface for all Runtime Configuration Repository adapters.

Member Typedef Documentation

◆ AdapterIdType

The type used to distinguish between different adapters implementing RuntimeRepoIf.

This is used to specialise the FactoryRegistry to make it suitable for adapter factories discriminated using a URI to select different backend implementations of the repository service.

Constructor & Destructor Documentation

◆ ~RuntimeRepoIf()

virtual rtctk::componentFramework::RuntimeRepoIf::~RuntimeRepoIf ( )
virtualdefault

Member Function Documentation

◆ CreateAdapter()

std::unique_ptr< RuntimeRepoIf > rtctk::componentFramework::RuntimeRepoIf::CreateAdapter ( const elt::mal::Uri & uri)
static

Factory method used to create the appropriate Runtime Configuration Repository adapter depending on the URI scheme.

The URI schemes supported by the factory method include the following:

  • rtr - Will create an instance of RuntimeRepoAdapter, to be used in operations.
  • cii.oldb - Will create an instance of RuntimeRepoAdapterLegacy, which is backed by the OLDB.
  • fake - Will create an instance of FakeRuntimeRepoAdapter, a simple repository suitable for testing. Need to link against the testSupport libraries for this to be available.
Parameters
[in]uriThe URI of the repository that needs to be accessed.
Returns
A unique pointer to the newly created adapter object. The caller must clean the object up once it is no longer needed.
Exceptions
UnsupportedUriExceptionIf the URI is not supported.
AdapterCreationExceptionIf the factory failed to create a new instance. This will contain nested exceptions caught from the adapter class constructor.
Thread Safety
thread-safe
Exception Safety
basic

◆ CreateDataPoint() [1/6]

template<typename T >
void rtctk::componentFramework::RepositoryIf::CreateDataPoint ( const DataPointPath & path)

Creates a new datapoint in the repository.

The type of the datapoint is derived from the template argument type.

Template Parameters
TThe type of the datapoint to create. See RepositoryIf::CreateDataPoint for a list of supported types.
Parameters
[in]pathThe datapoint path that should be created.
Thread Safety
thread-safe
Exception Safety
basic

◆ CreateDataPoint() [2/6]

void rtctk::componentFramework::RepositoryIf::CreateDataPoint ( const DataPointPath & path,
const char * initial_value )

◆ CreateDataPoint() [3/6]

void rtctk::componentFramework::RepositoryIf::CreateDataPoint ( const DataPointPath & path,
const std::type_info & type )
virtual

Creates a new datapoint in the repository with a specified type.

Parameters
[in]pathThe datapoint path that should be created.
[in]typeA type identifier object returned by typeid indicating the type of the new datapoint. Supported values are indicated below.

The following are the supported values for the type argument:

  • typeid(bool)
  • typeid(int32_t)
  • typeid(int64_t)
  • typeid(float)
  • typeid(double)
  • typeid(std::string)
  • typeid(std::vector<bool>)
  • typeid(std::vector<int32_t>)
  • typeid(std::vector<int64_t>)
  • typeid(std::vector<float>)
  • typeid(std::vector<double>)
  • typeid(std::vector<std::string>)
  • typeid(MatrixBuffer<bool>)
  • typeid(MatrixBuffer<int32_t>)
  • typeid(MatrixBuffer<int64_t>)
  • typeid(MatrixBuffer<float>)
  • typeid(MatrixBuffer<double>)
  • typeid(MatrixBuffer<std::string>)
Thread Safety
thread-safe
Exception Safety
basic
Deprecated
Use version that takes a default value instead.

Reimplemented from rtctk::componentFramework::RepositoryIf.

◆ CreateDataPoint() [4/6]

void rtctk::componentFramework::RuntimeRepoIf::CreateDataPoint ( const DataPointPath & path,
const std::type_info & type,
const std::string & server_alias )
virtual

Creates a new datapoint in the repository with a specified type on a particular external Redis server.

This version of the CreateDataPoint method ignores the default server alias setting and allows to explicitly give a server alias as an argument.

Parameters
[in]pathThe datapoint path that should be created.
[in]typeA type identifier object returned by typeid indicating the type of the new datapoint. See RepositoryIf::CreateDataPoint for a list of supported types.
[in]server_aliasThe symbolic name of the external Redis server, as configured in CII OLDB, on which the datapoint is created.
Thread Safety
thread-safe
Exception Safety
basic
Deprecated
The server alias is no longer applicable.

Reimplemented in rtctk::componentFramework::RuntimeRepoAdapterLegacy, rtctk::componentFramework::test::MockRuntimeRepoIf, and rtctk::componentFramework::RuntimeRepoAdapterLegacy.

◆ CreateDataPoint() [5/6]

template<typename T >
void rtctk::componentFramework::RepositoryIf::CreateDataPoint ( const DataPointPath & path,
const T & initial_value )

Creates a new datapoint in the repository with an initial value.

The type of the datapoint is derived from the template argument type.

Template Parameters
TThe type of the datapoint to create. See RepositoryIf::CreateDataPoint for a list of supported types.
Parameters
[in]pathThe datapoint path that should be created.
[in]initial_valueThe initial value that should be set for the new datapoint.
Thread Safety
thread-safe
Exception Safety
basic

◆ CreateDataPoint() [6/6]

template<typename T >
void rtctk::componentFramework::RuntimeRepoIf::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.

This version of the CreateDataPoint method ignores the default server alias setting and allows to explicitly give a server alias as an argument.

Template Parameters
TThe type of the datapoint to create. See RepositoryIf::CreateDataPoint for a list of supported types.
Parameters
[in]pathThe datapoint path that should be created.
[in]default_valueThe initial value to set the new datapoint to.
[in]server_aliasThe symbolic name of the external Redis server, as configured in CII OLDB, on which the datapoint is created.
Thread Safety
thread-safe
Exception Safety
basic
Deprecated
The server alias is no longer applicable.

◆ GetDefaultServerAlias()

std::string rtctk::componentFramework::RuntimeRepoIf::GetDefaultServerAlias ( ) const

Get the current default server alias setting.

Returns
std::string The current server alias used by CreateDataPoint.
Thread Safety
thread-safe
Exception Safety
strong
Deprecated
The server alias is no longer applicable.

◆ GetServerAlias()

std::string rtctk::componentFramework::RuntimeRepoIf::GetServerAlias ( const DataPointPath & path) const
virtual

Fetches the server alias for a specific datapoint.

Parameters
[in]pathThe datapoint path to query.
Returns
The server alias of the datapoint as a string.
Thread Safety
thread-safe
Exception Safety
strong
Deprecated
The server alias is no longer applicable.

Reimplemented in rtctk::componentFramework::RuntimeRepoAdapterLegacy.

◆ SetDefaultServerAlias()

void rtctk::componentFramework::RuntimeRepoIf::SetDefaultServerAlias ( const std::string & server_alias)

Set the current default server alias setting.

This sets the server alias string to use whenever the CreateDataPoint methods that do not explicitly take the server alias as an argument are invoked. An empty string can be given to cause the CreateDataPoint method to create the datapoints in the default OLDB location instead of an external Redis server.

Parameters
[in]server_aliasThe new server alias to be used by CreateDataPoint.
Thread Safety
thread-safe
Exception Safety
strong
Deprecated
The server alias is no longer applicable.

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