13#ifndef RTCTK_COMPONENTFRAMEWORK_OLDBADAPTERLEGACY_HPP
14#define RTCTK_COMPONENTFRAMEWORK_OLDBADAPTERLEGACY_HPP
20#include <ciiOldbSubscription.hpp>
21#include <ciiOldbTypedDataBase.hpp>
72 const std::shared_ptr<elt::oldb::CiiOldb>&
oldb);
252 template <
typename R,
typename F>
261 template <
typename T>
270 template <
typename T>
278 template <
typename T>
279 void RegisterSubscription(
const SubscribeRequest::Parameters&
params)
const;
282 struct IoFunctionMapEntry {
285 using WriteFunction =
287 using RegisterFunction =
290 ReadFunction m_read_function;
291 WriteFunction m_write_function;
292 RegisterFunction m_register_function;
296 using IoFunctionMap = std::map<std::type_index, IoFunctionMapEntry>;
303 template <
typename T>
304 static auto MakeMapEntry();
307 struct SubscriptionEntry {
308 std::shared_ptr<elt::oldb::CiiOldbTypedDataBase> m_datapoint;
309 std::shared_ptr<elt::oldb::CiiOldbDpSubscriptionBase> m_subscription;
318 std::function<
bool(
const SubscriptionEntry&,
const UnsubscribeRequest::Parameters&)>
319 m_unregister_callback;
322 using SubsciptionMap = std::list<SubscriptionEntry>;
333 template <
typename T,
typename U>
334 void CastAndRegisterSubscription(
335 const SubscribeRequest::Parameters&
params,
336 const std::shared_ptr<elt::oldb::CiiOldbTypedDataBase>&
datapoint,
337 std::function<
void(T*,
const std::shared_ptr<elt::oldb::CiiOldbDpValue<U>>&)>
341 mutable std::shared_ptr<elt::oldb::CiiOldb> m_client;
347 const elt::mal::Uri m_baseuri;
350 mutable std::list<SubscriptionEntry> m_subscriptions;
353 mutable std::mutex m_mutex;
356 const std::map<std::type_index, std::string>* m_metadata_instance_map =
nullptr;
359 static const std::map<std::type_index, std::string> S_METADATA_INSTANCE_MAP;
362 const std::map<std::string, const std::type_info&>* m_type_info_map =
nullptr;
365 static const std::map<std::string, const std::type_info&> S_TYPE_INFO_MAP;
368 static const IoFunctionMap S_IO_FUNCTIONS;
372 template <
typename T>
373 void CreateImpl(detail::CreateRequest<T>& req);
375 template <
typename T>
376 void ReadImpl(detail::ReadRequest<T>& req);
378 template <
typename T>
379 void WriteImpl(detail::WriteRequest<T>& req);
381 template <
typename T>
382 void PartialReadImpl(detail::PartialReadRequest<T>& req);
384 template <
typename T>
385 void PartialWriteImpl(detail::PartialWriteRequest<T>& req);
387 void ReadMetaDataImpl(detail::ReadMetaDataRequest& req);
388 void WriteMetaDataImpl(detail::WriteMetaDataRequest& req);
389 void DeleteImpl(detail::DeleteRequest& req);
390 void ExistsImpl(detail::ExistsRequest& req);
391 void GetChildrenImpl(detail::GetChildrenRequest& req);
392 void CreateLinkImpl(detail::CreateSymlinkRequest& req);
393 void UpdateLinkImpl(detail::UpdateSymlinkRequest& req);
394 void SubscribeImpl(detail::ValueSubscribeRequest& req);
395 void CreateDeleteSubscribeImpl(detail::CreateDeleteSubscribeRequest& req);
396 void UnsubscribeImpl(detail::UnsubscribeRequest& req);
400 template <
typename T>
401 static RequestDispatcher<OldbAdapterLegacy>::TableEntries BindTypeHandlers();
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:74
Provides access to the OLDB to read and write datapoints.
Definition oldbAdapterLegacy.hpp:39
void SetDataPointCreateContext(elt::oldb::CiiOldbDpCreateContext &context)
Sets a new datapoint creation context on the underlying OLDB client object.
Definition oldbAdapterLegacy.cpp:1225
OldbAdapterLegacy & operator=(const OldbAdapterLegacy &)=delete
This class cannot be copy assigned.
Response SendReadRequest(const ReadRequest &request) const override
Sends a request to read data from the repository.
Definition oldbAdapterLegacy.cpp:636
elt::mal::Uri GetBaseUri() const
Get the base URI used when creating this adapter object.
Definition oldbAdapterLegacy.hpp:86
const std::type_info & GetDataPointTypeLegacy(const DataPointPath &path) const override
Retrieves the corresponding C++ type for the datapoint from the OLDB.
Definition oldbAdapterLegacy.cpp:367
elt::oldb::CiiOldbDpCreateContext GetDataPointCreateContext() const
Get the datapoint creation context used by the underlying OLDB client object.
Definition oldbAdapterLegacy.cpp:1221
OldbAdapterLegacy(const OldbAdapterLegacy &)=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 oldbAdapterLegacy.cpp:1217
bool DataPointExistsLegacy(const DataPointPath &path) const override
Checks for the existence of a datapoint in the repository.
Definition oldbAdapterLegacy.cpp:610
OldbAdapterLegacy(OldbAdapterLegacy &&)=default
Objects of this class can be moved.
std::pair< PathList, PathList > GetChildrenLegacy(const DataPointPath &path) const override
Queries the datapoints and child paths for a given path.
Definition oldbAdapterLegacy.cpp:616
void DeleteDataPointLegacy(const DataPointPath &path) override
Deletes a datapoint in the OLDB.
Definition oldbAdapterLegacy.cpp:362
virtual ~OldbAdapterLegacy()
Destroys the adapter for the OLDB service releasing allocated resources.
Definition oldbAdapterLegacy.cpp:337
static const std::string SUPPORTED_URI_SCHEME
Definition oldbAdapterLegacy.hpp:41
static void InitMetadata()
Initialises the type metadata in the CII configuration service for the OLDB.
Definition oldbAdapterLegacy.cpp:802
Response SendUnsubscribeRequest(const UnsubscribeRequest &request) const override
This is called to asynchronously send a request to unsubscribe from various notifications.
Definition oldbAdapterLegacy.cpp:773
void CreateDataPoint(const DataPointPath &path, const std::type_info &type) override
Creates a new datapoint in the OLDB.
Definition oldbAdapterLegacy.cpp:340
void SetMetadataInstanceMap(const std::map< std::type_index, std::string > &map)
Sets the type_index to OLDB metadata instance name map.
Definition oldbAdapterLegacy.cpp:1174
OldbAdapterLegacy & operator=(OldbAdapterLegacy &&)=default
Objects of this class can be moved with the move assignment operator.
OldbAdapterLegacy()=delete
Do not allow construction with no arguments.
std::size_t GetDataPointSizeLegacy(const DataPointPath &path) const override
Returns the size of a datapoint in the OLDB.
Definition oldbAdapterLegacy.cpp:492
Response SendWriteRequest(const WriteRequest &request) override
Sends a request to write data to the repository.
Definition oldbAdapterLegacy.cpp:640
Response SendSubscribeRequest(const SubscribeRequest &request) const override
This is called to asynchronously send a subscription request for datapoints.
Definition oldbAdapterLegacy.cpp:747
Base interface for all OLDB adapters.
Definition oldbIf.hpp:25
An object used to wait for a request to complete.
Definition repositoryIf.hpp:1354
void CreateDataPoint(const DataPointPath &path)
Creates a new datapoint in the repository.
Definition repositoryIf.ipp:1696
std::vector< std::any > RequestList
Definition repositoryIf.hpp:106
Definition commandReplier.cpp:22
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Header file for OldbIf, which defines the API for OldbAdapters.
Header file for the RequestDispatcher utility class.
Definition repositoryIf.ipp:63
Definition repositorySubscriberIf.ipp:41
Definition repositoryIf.ipp:77