13#ifndef RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
14#define RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
20#include <ciiOldbSubscription.hpp>
21#include <ciiOldbTypedDataBase.hpp>
71 const std::shared_ptr<elt::oldb::CiiOldb>& oldb);
211 void SetTypeInfoMap(
const std::map<std::string, const std::type_info&>& map);
248 template <
typename R,
typename F>
249 Response ProcessRequest(
const R& request, F selector)
const;
257 template <
typename T>
266 template <
typename T>
267 void WriteData(
const DataPointPath& path,
const T& buffer)
const;
274 template <
typename T>
275 void RegisterSubscription(
const SubscribeRequest::Parameters& params)
const;
278 struct IoFunctionMapEntry {
280 using WriteFunction =
282 using RegisterFunction =
283 std::function<void(
const OldbAdapter*,
const SubscribeRequest::Parameters&)>;
285 ReadFunction m_read_function;
286 WriteFunction m_write_function;
287 RegisterFunction m_register_function;
291 using IoFunctionMap = std::map<std::type_index, IoFunctionMapEntry>;
298 template <
typename T>
299 static auto MakeMapEntry();
302 struct SubscriptionEntry {
303 std::shared_ptr<elt::oldb::CiiOldbTypedDataBase> m_datapoint;
304 std::shared_ptr<elt::oldb::CiiOldbDpSubscriptionBase> m_subscription;
313 std::function<bool(
const SubscriptionEntry&,
const UnsubscribeRequest::Parameters&)>
314 m_unregister_callback;
317 using SubsciptionMap = std::list<SubscriptionEntry>;
329 template <
typename T,
typename U,
typename V>
330 void CastAndRegisterSubscription(
331 const SubscribeRequest::Parameters& params,
332 const std::shared_ptr<elt::oldb::CiiOldbTypedDataBase>& datapoint,
333 std::function<
void(T*,
const std::shared_ptr<elt::oldb::CiiOldbDpValue<U>>&)>
334 write_function)
const;
337 mutable std::shared_ptr<elt::oldb::CiiOldb> m_client;
343 const elt::mal::Uri m_baseuri;
346 mutable std::list<SubscriptionEntry> m_subscriptions;
349 mutable std::mutex m_mutex;
352 const std::map<std::type_index, std::string>* m_metadata_instance_map =
nullptr;
355 static const std::map<std::type_index, std::string> S_METADATA_INSTANCE_MAP;
358 const std::map<std::string, const std::type_info&>* m_type_info_map =
nullptr;
361 static const std::map<std::string, const std::type_info&> S_TYPE_INFO_MAP;
364 static const IoFunctionMap S_IO_FUNCTIONS;
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
Provides access to the OLDB to read and write datapoints.
Definition: oldbAdapter.hpp:38
Response SendReadRequest(const ReadRequest &request) const override
Sends a request to read data from the repository.
Definition: oldbAdapter.cpp:560
std::size_t GetDataPointSize(const DataPointPath &path) const override
Returns the size of a datapoint in the OLDB.
Definition: oldbAdapter.cpp:457
OldbAdapter(const OldbAdapter &)=delete
This class cannot be copy constructed.
void SetTypeInfoMap(const std::map< std::string, const std::type_info & > &map)
Sets the OLDB metadata instance name to type_info map.
Definition: oldbAdapter.cpp:1278
static void InitMetadata()
Initialises the type metadata in the CII configuration service for the OLDB.
Definition: oldbAdapter.cpp:778
OldbAdapter & operator=(const OldbAdapter &)=delete
This class cannot be copy assigned.
std::pair< PathList, PathList > GetChildren(const DataPointPath &path) const override
Queries the datapoints and child paths for a given path.
Definition: oldbAdapter.cpp:540
static const std::string SUPPORTED_URI_SCHEME
Definition: oldbAdapter.hpp:40
OldbAdapter()=delete
Do not allow construction with no arguments.
virtual ~OldbAdapter()
Destroys the adapter for the OLDB service releasing allocated resources.
Definition: oldbAdapter.cpp:348
Response SendSubscribeRequest(const SubscribeRequest &request) const override
This is called to asynchronously send a subscription request for datapoints.
Definition: oldbAdapter.cpp:723
const std::type_info & GetDataPointType(const DataPointPath &path) const override
Retrieves the corresponding C++ type for the datapoint from the OLDB.
Definition: oldbAdapter.cpp:373
void CreateDataPoint(const DataPointPath &path, const std::type_info &type) override
Creates a new datapoint in the OLDB.
Definition: oldbAdapter.cpp:351
elt::oldb::CiiOldbDpCreateContext GetDataPointCreateContext() const
Get the datapoint creation context used by the underlying OLDB client object.
Definition: oldbAdapter.cpp:1282
OldbAdapter & operator=(OldbAdapter &&)=default
Objects of this class can be moved with the move assignment operator.
void DeleteDataPoint(const DataPointPath &path) override
Deletes a datapoint in the OLDB.
Definition: oldbAdapter.cpp:368
Response SendUnsubscribeRequest(const UnsubscribeRequest &request) const override
This is called to asynchronously send a request to unsubscribe from various notifications.
Definition: oldbAdapter.cpp:749
void SetDataPointCreateContext(elt::oldb::CiiOldbDpCreateContext &context)
Sets a new datapoint creation context on the underlying OLDB client object.
Definition: oldbAdapter.cpp:1286
bool DataPointExists(const DataPointPath &path) const override
Checks for the existence of a datapoint in the repository.
Definition: oldbAdapter.cpp:535
void SetMetadataInstanceMap(const std::map< std::type_index, std::string > &map)
Sets the type_index to OLDB metadata instance name map.
Definition: oldbAdapter.cpp:1235
elt::mal::Uri GetBaseUri() const
Get the base URI used when creating this adapter object.
Definition: oldbAdapter.hpp:85
OldbAdapter(OldbAdapter &&)=default
Objects of this class can be moved.
Response SendWriteRequest(const WriteRequest &request) override
Sends a request to write data to the repository.
Definition: oldbAdapter.cpp:564
Base interface for all OLDB adapters.
Definition: oldbIf.hpp:26
A request object to pass information about datapoints that should be read from the repository.
Definition: repositoryIf.hpp:49
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:197
A request object to pass information about datapoints that should be written to the repository.
Definition: repositoryIf.hpp:122
virtual void CreateDataPoint(const DataPointPath &path, const std::type_info &type)=0
Creates a new datapoint in the repository with a specified type.
Definition: commandReplier.cpp:22
Header file for OldbIf, which defines the API for OldbAdapters.