RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
rtctk::componentFramework::OldbAdapter Class Reference

Implementation of the OLDB Adapter. More...

#include <rtctk/componentFramework/oldbAdapter.hpp>

Inheritance diagram for rtctk::componentFramework::OldbAdapter:
rtctk::componentFramework::OldbIf rtctk::componentFramework::RepositorySubscriberIf rtctk::componentFramework::RepositoryIf

Classes

struct  MethodsRecord
 Structure of method pointers to methods that implement certain OLDB operations for a specific datapoint type. More...
 
struct  SubscriptionEntry
 

Public Member Functions

 OldbAdapter ()=delete
 Do not allow construction with no arguments.
 
 OldbAdapter (const OldbAdapter &)=delete
 This class cannot be copy constructed.
 
OldbAdapteroperator= (const OldbAdapter &)=delete
 This class cannot be copy assigned.
 
 OldbAdapter (OldbAdapter &&)=delete
 Objects of this class can not be moved because we have a mutex.
 
OldbAdapteroperator= (OldbAdapter &&)=delete
 
 OldbAdapter (const elt::mal::Uri &baseuri)
 Constructs an adapter for the CII OLDB service with the default OLDB client instance.
 
 OldbAdapter (const elt::mal::Uri &baseuri, const std::shared_ptr< elt::oldb::CiiOldb > &oldb)
 Constructs an adapter for the OLDB service with a specific OLDB client instance.
 
 ~OldbAdapter () override=default
 Destroys the adapter for the OLDB service releasing allocated resources.
 
elt::mal::Uri GetUri () const override
 Get the URI used when creating this adapter object.
 
template<typename CiiType>
auto GetOldbTypedDataPoint (auto &request)
 
template<typename T>
Lut::TableEntries BindRequestHandlers ()
 
- Public Member Functions inherited from rtctk::componentFramework::OldbIf
 ~OldbIf () override=default
 
- Public Member Functions inherited from rtctk::componentFramework::RepositorySubscriberIf
 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
 

Static Public Attributes

static const std::string SUPPORTED_URI_SCHEME = "cii.oldb"
 

Protected Types

using CiiOldbTypedDataBase = elt::oldb::CiiOldbTypedDataBase
 
using CiiOldbDpSubscriptionBase = elt::oldb::CiiOldbDpSubscriptionBase
 
using MethodLookupTable = std::unordered_map<std::type_index, MethodsRecord>
 
using MethodLookupTableEntry = typename MethodLookupTable::value_type
 
- Protected Types inherited from rtctk::componentFramework::RepositoryIf
using RequestList = std::vector<std::any>
 

Protected Member Functions

RTCTK_LOCAL auto GetOldbBaseDataPoint (auto &request)
 
template<typename CiiType>
RTCTK_LOCAL auto GetOldbTypedDataPoint (auto &request)
 
template<typename DataPointType, typename T>
void CreateImpl (detail::CreateRequest< T > &)
 
template<typename T>
void DispatchCreateRequest (detail::CreateRequest< T > &)
 
template<typename DataPointType, typename T>
void ReadImpl (detail::ReadRequest< T > &)
 
template<typename T>
void DispatchReadRequest (detail::ReadRequest< T > &)
 
template<typename DataPointType, typename T>
void WriteImpl (detail::WriteRequest< T > &)
 
template<typename T>
void DispatchWriteRequest (detail::WriteRequest< T > &)
 
template<typename DataPointType, typename T>
void PartialReadImpl (detail::PartialReadRequest< T > &)
 
template<typename T>
void DispatchPartialReadRequest (detail::PartialReadRequest< T > &)
 
template<typename DataPointType, typename T>
void PartialWriteImpl (detail::PartialWriteRequest< T > &)
 
template<typename T>
void DispatchPartialWriteRequest (detail::PartialWriteRequest< T > &)
 
template<typename DataPointType>
void ReadMetaDataImpl (detail::ReadMetaDataRequest &)
 
void DispatchReadMetaDataRequest (detail::ReadMetaDataRequest &)
 
template<typename DataPointType>
void WriteMetaDataImpl (detail::WriteMetaDataRequest &)
 
void DispatchWriteMetaDataRequest (detail::WriteMetaDataRequest &)
 
template<typename DataPointType>
void DeleteWithMetadata (const elt::mal::Uri &)
 
void DeleteImpl (detail::DeleteRequest &)
 
void ExistsImpl (detail::ExistsRequest &)
 
void GetChildrenImpl (detail::GetChildrenRequest &)
 
void GetChildrenImplRecursive (const DataPointPath &, PathList &, PathList &, bool)
 
void CreateLinkImpl (detail::CreateSymlinkRequest &)
 
void UpdateLinkImpl (detail::UpdateSymlinkRequest &)
 
template<typename DataPointType>
void SubscribeImpl (detail::ValueSubscribeRequest &)
 
void DispatchSubscribeRequest (detail::ValueSubscribeRequest &)
 
void CreateDeleteSubscribeImpl (detail::CreateDeleteSubscribeRequest &)
 Operation not supported by this backend, invocation will result in exception.
 
void UnsubscribeImpl (detail::UnsubscribeRequest &)
 
BatchResponse ProcessRequests (const RequestList &requests) override
 

Static Protected Member Functions

template<typename T>
static MethodLookupTableEntry BindTypeHandlers ()
 Helper method to bind a set of handler methods for a particular datapoint type.
 
static const MethodsRecordFindTypeHandlers (const std::type_info &type)
 Find the handler methods to use for a given datapoint type.
 
template<typename T>
static RequestDispatcher< OldbAdapter >::TableEntries BindRequestHandlers ()
 Helper method to bind multiple handler methods for templated requests.
 

Protected Attributes

const elt::mal::Uri m_baseuri
 The prefix part for OLDB URIs.
 
std::shared_ptr< elt::oldb::CiiOldb > m_client
 Pointer to the CII OLDB API client object.
 
std::mutex m_mutex
 Mutex for synchronising access to subscriptions.
 
DynamicThreadPool m_thread_pool {"oldb_worker"}
 worker threadpool
 
std::map< SubscriptionId, SubscriptionEntrym_subscriptions
 

Static Protected Attributes

static const MethodLookupTable S_TYPE_DISPATCH_TABLE
 A lookup table of methods for handling different datapoint types.
 
static const RequestDispatcher< OldbAdapterS_REQUEST_DISPATCHER
 A lookup table of methods for handling different request types.
 

Additional Inherited Members

- Public Types inherited from rtctk::componentFramework::OldbIf
using AdapterIdType = elt::mal::Uri
 The type used to distinguish between different adapters implementing OldbIf.
 
- 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::OldbIf
static std::unique_ptr< OldbIfCreateAdapter (const elt::mal::Uri &uri)
 Factory method used to create the appropriate OLDB 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 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.
 

Detailed Description

Implementation of the OLDB Adapter.

Member Typedef Documentation

◆ CiiOldbDpSubscriptionBase

using rtctk::componentFramework::OldbAdapter::CiiOldbDpSubscriptionBase = elt::oldb::CiiOldbDpSubscriptionBase
protected

◆ CiiOldbTypedDataBase

using rtctk::componentFramework::OldbAdapter::CiiOldbTypedDataBase = elt::oldb::CiiOldbTypedDataBase
protected

◆ MethodLookupTable

using rtctk::componentFramework::OldbAdapter::MethodLookupTable = std::unordered_map<std::type_index, MethodsRecord>
protected

◆ MethodLookupTableEntry

using rtctk::componentFramework::OldbAdapter::MethodLookupTableEntry = typename MethodLookupTable::value_type
protected

Constructor & Destructor Documentation

◆ OldbAdapter() [1/5]

rtctk::componentFramework::OldbAdapter::OldbAdapter ( )
delete

Do not allow construction with no arguments.

◆ OldbAdapter() [2/5]

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

This class cannot be copy constructed.

◆ OldbAdapter() [3/5]

rtctk::componentFramework::OldbAdapter::OldbAdapter ( OldbAdapter && )
delete

Objects of this class can not be moved because we have a mutex.

◆ OldbAdapter() [4/5]

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

Constructs an adapter for the CII OLDB service with the default OLDB client instance.

Parameters
[in]baseuriA URI with a CII OLDB scheme, e.g.: cii.oldb:/basepath The URI must contain a base path where the datapoints are stored.

◆ OldbAdapter() [5/5]

rtctk::componentFramework::OldbAdapter::OldbAdapter ( const elt::mal::Uri & baseuri,
const std::shared_ptr< elt::oldb::CiiOldb > & oldb )
explicit

Constructs an adapter for the OLDB service with a specific OLDB client instance.

Parameters
[in]baseuriA URI with a CII OLDB scheme, e.g.: cii.oldb:/basepath The URI must contain a base path where the datapoints are stored.
[in]oldbThe OLDB client object to use for accessing the OLDB.

◆ ~OldbAdapter()

rtctk::componentFramework::OldbAdapter::~OldbAdapter ( )
overridedefault

Destroys the adapter for the OLDB service releasing allocated resources.

Member Function Documentation

◆ BindRequestHandlers() [1/2]

template<typename T>
static RequestDispatcher< OldbAdapter >::TableEntries rtctk::componentFramework::OldbAdapter::BindRequestHandlers ( )
staticprotected

Helper method to bind multiple handler methods for templated requests.

Template Parameters
TThe element type of the request class, e.g. CreateRequest<T>.
Returns
Table entries to add to S_REQUEST_DISPATCHER.

◆ BindRequestHandlers() [2/2]

template<typename T>
Lut::TableEntries rtctk::componentFramework::OldbAdapter::BindRequestHandlers ( )

◆ BindTypeHandlers()

template<typename T>
OldbAdapter::MethodLookupTableEntry rtctk::componentFramework::OldbAdapter::BindTypeHandlers ( )
staticprotected

Helper method to bind a set of handler methods for a particular datapoint type.

Template Parameters
TThe datapoint type, e.g. RtcInt64.
Returns
Table entry to add to S_TYPE_DISPATCH_TABLE.

◆ CreateDeleteSubscribeImpl()

void rtctk::componentFramework::OldbAdapter::CreateDeleteSubscribeImpl ( detail::CreateDeleteSubscribeRequest & request)
protected

Operation not supported by this backend, invocation will result in exception.

◆ CreateImpl()

template<typename DataPointType, typename T>
void rtctk::componentFramework::OldbAdapter::CreateImpl ( detail::CreateRequest< T > & request)
protected

◆ CreateLinkImpl()

void rtctk::componentFramework::OldbAdapter::CreateLinkImpl ( detail::CreateSymlinkRequest & request)
protected

◆ DeleteImpl()

void rtctk::componentFramework::OldbAdapter::DeleteImpl ( detail::DeleteRequest & request)
protected

◆ DeleteWithMetadata()

template<typename DataPointType>
void rtctk::componentFramework::OldbAdapter::DeleteWithMetadata ( const elt::mal::Uri & uri)
protected

◆ DispatchCreateRequest()

template<typename T>
void rtctk::componentFramework::OldbAdapter::DispatchCreateRequest ( detail::CreateRequest< T > & request)
protected

◆ DispatchPartialReadRequest()

template<typename T>
void rtctk::componentFramework::OldbAdapter::DispatchPartialReadRequest ( detail::PartialReadRequest< T > & request)
protected

◆ DispatchPartialWriteRequest()

template<typename T>
void rtctk::componentFramework::OldbAdapter::DispatchPartialWriteRequest ( detail::PartialWriteRequest< T > & request)
protected

◆ DispatchReadMetaDataRequest()

void rtctk::componentFramework::OldbAdapter::DispatchReadMetaDataRequest ( detail::ReadMetaDataRequest & request)
protected

◆ DispatchReadRequest()

template<typename T>
void rtctk::componentFramework::OldbAdapter::DispatchReadRequest ( detail::ReadRequest< T > & request)
protected

◆ DispatchSubscribeRequest()

void rtctk::componentFramework::OldbAdapter::DispatchSubscribeRequest ( detail::ValueSubscribeRequest & request)
protected

◆ DispatchWriteMetaDataRequest()

void rtctk::componentFramework::OldbAdapter::DispatchWriteMetaDataRequest ( detail::WriteMetaDataRequest & request)
protected

◆ DispatchWriteRequest()

template<typename T>
void rtctk::componentFramework::OldbAdapter::DispatchWriteRequest ( detail::WriteRequest< T > & request)
protected

◆ ExistsImpl()

void rtctk::componentFramework::OldbAdapter::ExistsImpl ( detail::ExistsRequest & request)
protected

◆ FindTypeHandlers()

const OldbAdapter::MethodsRecord & rtctk::componentFramework::OldbAdapter::FindTypeHandlers ( const std::type_info & type)
staticprotected

Find the handler methods to use for a given datapoint type.

Parameters
[in]typeThe datapoint type that needs to be handled.
Returns
The set of handler methods for a particular datapoint type.
Exceptions
UnsupportedTypeNo handler methods could be found for the given datapoint type.

◆ GetChildrenImpl()

void rtctk::componentFramework::OldbAdapter::GetChildrenImpl ( detail::GetChildrenRequest & request)
protected

◆ GetChildrenImplRecursive()

void rtctk::componentFramework::OldbAdapter::GetChildrenImplRecursive ( const DataPointPath & path,
PathList & child_paths,
PathList & datapoints,
bool recurse )
protected

◆ GetOldbBaseDataPoint()

auto rtctk::componentFramework::OldbAdapter::GetOldbBaseDataPoint ( auto & request)
protected

◆ GetOldbTypedDataPoint() [1/2]

template<typename CiiType>
RTCTK_LOCAL auto rtctk::componentFramework::OldbAdapter::GetOldbTypedDataPoint ( auto & request)
protected

◆ GetOldbTypedDataPoint() [2/2]

template<typename CiiType>
auto rtctk::componentFramework::OldbAdapter::GetOldbTypedDataPoint ( auto & request)

◆ GetUri()

elt::mal::Uri rtctk::componentFramework::OldbAdapter::GetUri ( ) const
inlineoverridevirtual

Get the URI used when creating this adapter object.

Returns
elt::mal::Uri object indicating the URI used with CreateAdapter.
Thread Safety
thread-safe
Exception Safety
strong

Implements rtctk::componentFramework::OldbIf.

◆ operator=() [1/2]

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

This class cannot be copy assigned.

◆ operator=() [2/2]

OldbAdapter & rtctk::componentFramework::OldbAdapter::operator= ( OldbAdapter && )
delete

◆ PartialReadImpl()

template<typename DataPointType, typename T>
void rtctk::componentFramework::OldbAdapter::PartialReadImpl ( detail::PartialReadRequest< T > & request)
protected

◆ PartialWriteImpl()

template<typename DataPointType, typename T>
void rtctk::componentFramework::OldbAdapter::PartialWriteImpl ( detail::PartialWriteRequest< T > & request)
protected

◆ ProcessRequests()

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

◆ ReadImpl()

template<typename DataPointType, typename T>
void rtctk::componentFramework::OldbAdapter::ReadImpl ( detail::ReadRequest< T > & request)
protected

◆ ReadMetaDataImpl()

template<typename DataPointType>
void rtctk::componentFramework::OldbAdapter::ReadMetaDataImpl ( detail::ReadMetaDataRequest & request)
protected

◆ SubscribeImpl()

template<typename DataPointType>
void rtctk::componentFramework::OldbAdapter::SubscribeImpl ( detail::ValueSubscribeRequest & request)
protected

◆ UnsubscribeImpl()

void rtctk::componentFramework::OldbAdapter::UnsubscribeImpl ( detail::UnsubscribeRequest & request)
protected

◆ UpdateLinkImpl()

void rtctk::componentFramework::OldbAdapter::UpdateLinkImpl ( detail::UpdateSymlinkRequest & request)
protected

◆ WriteImpl()

template<typename DataPointType, typename T>
void rtctk::componentFramework::OldbAdapter::WriteImpl ( detail::WriteRequest< T > & request)
protected

◆ WriteMetaDataImpl()

template<typename DataPointType>
void rtctk::componentFramework::OldbAdapter::WriteMetaDataImpl ( detail::WriteMetaDataRequest & request)
protected

Member Data Documentation

◆ m_baseuri

const elt::mal::Uri rtctk::componentFramework::OldbAdapter::m_baseuri
protected

The prefix part for OLDB URIs.

All datapoint paths given to the public OldbAdapter methods are relative to this prefix.

◆ m_client

std::shared_ptr<elt::oldb::CiiOldb> rtctk::componentFramework::OldbAdapter::m_client
mutableprotected

Pointer to the CII OLDB API client object.

◆ m_mutex

std::mutex rtctk::componentFramework::OldbAdapter::m_mutex
mutableprotected

Mutex for synchronising access to subscriptions.

◆ m_subscriptions

std::map<SubscriptionId, SubscriptionEntry> rtctk::componentFramework::OldbAdapter::m_subscriptions
protected

◆ m_thread_pool

DynamicThreadPool rtctk::componentFramework::OldbAdapter::m_thread_pool {"oldb_worker"}
protected

worker threadpool

◆ S_REQUEST_DISPATCHER

const Lut rtctk::componentFramework::OldbAdapter::S_REQUEST_DISPATCHER
staticprotected
Initial value:
= {
void ExistsImpl(detail::ExistsRequest &)
Definition oldbAdapter.cpp:1125
void GetChildrenImpl(detail::GetChildrenRequest &)
Definition oldbAdapter.cpp:1138
void UnsubscribeImpl(detail::UnsubscribeRequest &)
Definition oldbAdapter.cpp:1306
static RequestDispatcher< OldbAdapter >::TableEntries BindRequestHandlers()
Helper method to bind multiple handler methods for templated requests.
void CreateDeleteSubscribeImpl(detail::CreateDeleteSubscribeRequest &)
Operation not supported by this backend, invocation will result in exception.
Definition oldbAdapter.cpp:1302
void DeleteImpl(detail::DeleteRequest &)
Definition oldbAdapter.cpp:1078
void CreateLinkImpl(detail::CreateSymlinkRequest &)
Definition oldbAdapter.cpp:1173
void UpdateLinkImpl(detail::UpdateSymlinkRequest &)
Definition oldbAdapter.cpp:1193
void DispatchSubscribeRequest(detail::ValueSubscribeRequest &)
Definition oldbAdapter.cpp:1295
void DispatchWriteMetaDataRequest(detail::WriteMetaDataRequest &)
Definition oldbAdapter.cpp:1052
void DispatchReadMetaDataRequest(detail::ReadMetaDataRequest &)
Definition oldbAdapter.cpp:1013
static TableEntries Bind(void(OldbAdapter::*method)(T &, Args...))
Definition requestDispatcher.hpp:66

A lookup table of methods for handling different request types.

◆ S_TYPE_DISPATCH_TABLE

const OldbAdapter::MethodLookupTable rtctk::componentFramework::OldbAdapter::S_TYPE_DISPATCH_TABLE
staticprotected

A lookup table of methods for handling different datapoint types.

◆ SUPPORTED_URI_SCHEME

const std::string rtctk::componentFramework::OldbAdapter::SUPPORTED_URI_SCHEME = "cii.oldb"
inlinestatic

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