RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
oldbAdapter.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
13#define RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
14
15#include <ciiOldb.hpp>
16#include <ciiOldbSubscription.hpp>
17#include <ciiOldbTypedDataBase.hpp>
18
22
23#include <map>
24#include <unordered_map>
25
27
33class OldbAdapter : public OldbIf {
34public:
35 inline static const std::string SUPPORTED_URI_SCHEME = "cii.oldb";
36
38 OldbAdapter() = delete;
39
41 OldbAdapter(const OldbAdapter&) = delete;
42
45
49
56 explicit OldbAdapter(const elt::mal::Uri& baseuri);
57
64 explicit OldbAdapter(const elt::mal::Uri& baseuri,
65 const std::shared_ptr<elt::oldb::CiiOldb>& oldb);
66
70 ~OldbAdapter() override = default;
71
72 elt::mal::Uri GetUri() const override {
73 return m_baseuri;
74 }
75
76protected:
77 using CiiOldbTypedDataBase = elt::oldb::CiiOldbTypedDataBase;
78 using CiiOldbDpSubscriptionBase = elt::oldb::CiiOldbDpSubscriptionBase;
79
80 RTCTK_LOCAL auto GetOldbBaseDataPoint(auto& request);
81
82 template <typename CiiType>
84
85 template <typename DataPointType, typename T>
87
88 template <typename T>
90
91 template <typename DataPointType, typename T>
93
94 template <typename T>
96
97 template <typename DataPointType, typename T>
99
100 template <typename T>
102
103 template <typename DataPointType, typename T>
105
106 template <typename T>
108
109 template <typename DataPointType, typename T>
111
112 template <typename T>
114
115 template <typename DataPointType>
117
119
120 template <typename DataPointType>
122
124
125 template <typename DataPointType>
126 void DeleteWithMetadata(const elt::mal::Uri&);
127
134
135 template <typename DataPointType>
137
139
142
144
145 BatchResponse ProcessRequests(const RequestList& requests) override;
146
151 const elt::mal::Uri m_baseuri;
152
154 mutable std::shared_ptr<elt::oldb::CiiOldb> m_client;
155
157 mutable std::mutex m_mutex;
158
161
162 // data structures to hold active subscriptions
164 std::shared_ptr<CiiOldbTypedDataBase> dp;
165 std::shared_ptr<CiiOldbDpSubscriptionBase> sub;
166 std::function<void(SubscriptionEntry&)> unreg_cb;
167 };
168
169 std::map<SubscriptionId, SubscriptionEntry> m_subscriptions;
170
183
184 using MethodLookupTable = std::unordered_map<std::type_index, MethodsRecord>;
185 using MethodLookupTableEntry = typename MethodLookupTable::value_type;
186
192 template <typename T>
194
201 static const MethodsRecord& FindTypeHandlers(const std::type_info& type);
202
205
211 template <typename T>
213
216};
217
218} // namespace rtctk::componentFramework
219
220#endif // RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:76
The DynamicThreadPool allows creating multiple threads which are garbage collected.
Definition dynamicThreadPool.hpp:36
std::unordered_map< std::type_index, MethodsRecord > MethodLookupTable
Definition oldbAdapter.hpp:184
void ExistsImpl(detail::ExistsRequest &)
Definition oldbAdapter.cpp:1125
void DispatchReadRequest(detail::ReadRequest< T > &)
Definition oldbAdapter.cpp:800
void GetChildrenImpl(detail::GetChildrenRequest &)
Definition oldbAdapter.cpp:1138
void DeleteWithMetadata(const elt::mal::Uri &)
Definition oldbAdapter.cpp:1059
void WriteImpl(detail::WriteRequest< T > &)
Definition oldbAdapter.cpp:825
void WriteMetaDataImpl(detail::WriteMetaDataRequest &)
Definition oldbAdapter.cpp:1020
void DispatchCreateRequest(detail::CreateRequest< T > &)
Definition oldbAdapter.cpp:750
void UnsubscribeImpl(detail::UnsubscribeRequest &)
Definition oldbAdapter.cpp:1306
static const MethodsRecord & FindTypeHandlers(const std::type_info &type)
Find the handler methods to use for a given datapoint type.
Definition oldbAdapter.cpp:1362
void DispatchPartialReadRequest(detail::PartialReadRequest< T > &)
Definition oldbAdapter.cpp:908
OldbAdapter(const OldbAdapter &)=delete
This class cannot be copy constructed.
void CreateImpl(detail::CreateRequest< T > &)
Definition oldbAdapter.cpp:716
const elt::mal::Uri m_baseuri
The prefix part for OLDB URIs.
Definition oldbAdapter.hpp:151
void DispatchWriteRequest(detail::WriteRequest< T > &)
Definition oldbAdapter.cpp:847
OldbAdapter & operator=(const OldbAdapter &)=delete
This class cannot be copy assigned.
static RequestDispatcher< OldbAdapter >::TableEntries BindRequestHandlers()
Helper method to bind multiple handler methods for templated requests.
void DispatchPartialWriteRequest(detail::PartialWriteRequest< T > &)
Definition oldbAdapter.cpp:969
elt::oldb::CiiOldbTypedDataBase CiiOldbTypedDataBase
Definition oldbAdapter.hpp:77
OldbAdapter & operator=(OldbAdapter &&)=delete
OldbAdapter(OldbAdapter &&)=delete
Objects of this class can not be moved because we have a mutex.
static const std::string SUPPORTED_URI_SCHEME
Definition oldbAdapter.hpp:35
void CreateDeleteSubscribeImpl(detail::CreateDeleteSubscribeRequest &)
Operation not supported by this backend, invocation will result in exception.
Definition oldbAdapter.cpp:1302
OldbAdapter()=delete
Do not allow construction with no arguments.
RTCTK_LOCAL auto GetOldbTypedDataPoint(auto &request)
std::map< SubscriptionId, SubscriptionEntry > m_subscriptions
Definition oldbAdapter.hpp:169
void ReadMetaDataImpl(detail::ReadMetaDataRequest &)
Definition oldbAdapter.cpp:995
void DeleteImpl(detail::DeleteRequest &)
Definition oldbAdapter.cpp:1078
static MethodLookupTableEntry BindTypeHandlers()
Helper method to bind a set of handler methods for a particular datapoint type.
Definition oldbAdapter.cpp:1354
elt::oldb::CiiOldbDpSubscriptionBase CiiOldbDpSubscriptionBase
Definition oldbAdapter.hpp:78
elt::mal::Uri GetUri() const override
Get the URI used when creating this adapter object.
Definition oldbAdapter.hpp:72
void PartialReadImpl(detail::PartialReadRequest< T > &)
Definition oldbAdapter.cpp:873
void PartialWriteImpl(detail::PartialWriteRequest< T > &)
Definition oldbAdapter.cpp:934
void CreateLinkImpl(detail::CreateSymlinkRequest &)
Definition oldbAdapter.cpp:1173
void UpdateLinkImpl(detail::UpdateSymlinkRequest &)
Definition oldbAdapter.cpp:1193
BatchResponse ProcessRequests(const RequestList &requests) override
Definition oldbAdapter.cpp:1315
static const MethodLookupTable S_TYPE_DISPATCH_TABLE
A lookup table of methods for handling different datapoint types.
Definition oldbAdapter.hpp:204
void DispatchSubscribeRequest(detail::ValueSubscribeRequest &)
Definition oldbAdapter.cpp:1295
~OldbAdapter() override=default
Destroys the adapter for the OLDB service releasing allocated resources.
void DispatchWriteMetaDataRequest(detail::WriteMetaDataRequest &)
Definition oldbAdapter.cpp:1052
typename MethodLookupTable::value_type MethodLookupTableEntry
Definition oldbAdapter.hpp:185
void SubscribeImpl(detail::ValueSubscribeRequest &)
Definition oldbAdapter.cpp:1271
void ReadImpl(detail::ReadRequest< T > &)
Definition oldbAdapter.cpp:776
std::mutex m_mutex
Mutex for synchronising access to subscriptions.
Definition oldbAdapter.hpp:157
std::shared_ptr< elt::oldb::CiiOldb > m_client
Pointer to the CII OLDB API client object.
Definition oldbAdapter.hpp:154
void DispatchReadMetaDataRequest(detail::ReadMetaDataRequest &)
Definition oldbAdapter.cpp:1013
RTCTK_LOCAL auto GetOldbBaseDataPoint(auto &request)
Definition oldbAdapter.cpp:694
static const RequestDispatcher< OldbAdapter > S_REQUEST_DISPATCHER
A lookup table of methods for handling different request types.
Definition oldbAdapter.hpp:215
void GetChildrenImplRecursive(const DataPointPath &, PathList &, PathList &, bool)
Definition oldbAdapter.cpp:1146
DynamicThreadPool m_thread_pool
worker threadpool
Definition oldbAdapter.hpp:160
Base interface for all OLDB adapters.
Definition oldbIf.hpp:24
std::vector< std::any > RequestList
Definition repositoryIf.hpp:52
Definition requestDispatcher.hpp:30
#define RTCTK_LOCAL
Helper to hide a class or function from the public symbol table.
Definition config.hpp:59
Header file for a dynamic resizing thread pool.
Definition commandReplier.cpp:21
RepositoryIf::PathList PathList
Definition persistentRepoAdapter.cpp:95
Header file for OldbIf, which defines the API for OldbAdapters.
Header file for the RequestDispatcher utility class.
Structure of method pointers to methods that implement certain OLDB operations for a specific datapoi...
Definition oldbAdapter.hpp:177
void(OldbAdapter::* subscribe_method)(detail::ValueSubscribeRequest &)
Definition oldbAdapter.hpp:181
void(OldbAdapter::* delete_method)(const elt::mal::Uri &)
Definition oldbAdapter.hpp:180
void(OldbAdapter::* write_metadata_method)(detail::WriteMetaDataRequest &)
Definition oldbAdapter.hpp:179
void(OldbAdapter::* read_metadata_method)(detail::ReadMetaDataRequest &)
Definition oldbAdapter.hpp:178
std::shared_ptr< CiiOldbDpSubscriptionBase > sub
Definition oldbAdapter.hpp:165
std::shared_ptr< CiiOldbTypedDataBase > dp
Definition oldbAdapter.hpp:164
std::function< void(SubscriptionEntry &)> unreg_cb
Definition oldbAdapter.hpp:166
Definition repositorySubscriberIf.ipp:40
Definition repositorySubscriberIf.ipp:26