Go to the documentation of this file.
12 #ifndef RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
18 #include <ciiOldb.hpp>
19 #include <ciiOldbSubscription.hpp>
20 #include <ciiOldbTypedDataBase.hpp>
65 const std::shared_ptr<elt::oldb::CiiOldb>& oldb);
195 void SetTypeInfoMap(
const std::map<std::string, const std::type_info&>& map);
214 template <
typename R,
typename F>
215 Response ProcessRequest(
const R& request, F selector)
const;
223 template <
typename T>
232 template <
typename T>
233 void WriteData(
const DataPointPath& path,
const T& buffer)
const;
240 template <
typename T>
241 void RegisterSubscription(
const SubscribeRequest::Parameters& params)
const;
244 struct IoFunctionMapEntry {
246 using WriteFunction =
248 using RegisterFunction =
249 std::function<void(
const OldbAdapter*,
const SubscribeRequest::Parameters&)>;
251 ReadFunction m_read_function;
252 WriteFunction m_write_function;
253 RegisterFunction m_register_function;
257 using IoFunctionMap = std::map<std::type_index, IoFunctionMapEntry>;
264 template <
typename T>
265 static auto MakeMapEntry();
268 struct SubscriptionEntry {
269 std::shared_ptr<elt::oldb::CiiOldbTypedDataBase> m_datapoint;
270 std::shared_ptr<elt::oldb::CiiOldbDpSubscriptionBase> m_subscription;
279 std::function<bool(
const SubscriptionEntry&,
const UnsubscribeRequest::Parameters&)>
280 m_unregister_callback;
283 using SubsciptionMap = std::list<SubscriptionEntry>;
295 template <
typename T,
typename U,
typename V>
296 void CastAndRegisterSubscription(
297 const SubscribeRequest::Parameters& params,
298 const std::shared_ptr<elt::oldb::CiiOldbTypedDataBase>& datapoint,
299 std::function<
void(T*,
const std::shared_ptr<elt::oldb::CiiOldbDpValue<U>>&)>
300 write_function)
const;
303 mutable std::shared_ptr<elt::oldb::CiiOldb> m_client;
309 const elt::mal::Uri m_baseuri;
312 mutable std::list<SubscriptionEntry> m_subscriptions;
315 mutable std::mutex m_mutex;
318 const std::map<std::type_index, std::string>* m_metadata_instance_map =
nullptr;
321 static const std::map<std::type_index, std::string> S_METADATA_INSTANCE_MAP;
324 const std::map<std::string, const std::type_info&>* m_type_info_map =
nullptr;
327 static const std::map<std::string, const std::type_info&> S_TYPE_INFO_MAP;
330 static const IoFunctionMap S_IO_FUNCTIONS;
335 #endif // RTCTK_COMPONENTFRAMEWORK_OLDBADAPTER_HPP
OldbAdapter & operator=(OldbAdapter &&)=default
Objects of this class can be moved with the move assignment operator.
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:1216
void DeleteDataPoint(const DataPointPath &path) override
Deletes a datapoint in the OLDB.
Definition: oldbAdapter.cpp:309
Response SendWriteRequest(const WriteRequest &request) override
Sends a request to write data to the repository.
Definition: oldbAdapter.cpp:509
OldbAdapter & operator=(const OldbAdapter &)=delete
This class cannot be copy assigned.
A request object to pass information about datapoints that should be read from the repository.
Definition: repositoryIf.hpp:44
Provides access to the OLDB to read and write datapoints.
Definition: oldbAdapter.hpp:34
void SetMetadataInstanceMap(const std::map< std::type_index, std::string > &map)
Sets the type_index to OLDB metadata instance name map.
Definition: oldbAdapter.cpp:1173
bool DataPointExists(const DataPointPath &path) const override
Checks for the existence of a datapoint in the repository.
Definition: oldbAdapter.cpp:476
Response SendUnsubscribeRequest(const UnsubscribeRequest &request) const override
This is called to asynchronously send a request to unsubscribe from various notifications.
Definition: oldbAdapter.cpp:693
Definition: commandReplier.cpp:20
A request object to pass information about datapoints to subscribe to.
Definition: repositorySubscriberIf.hpp:33
std::size_t GetDataPointSize(const DataPointPath &path) const override
Returns the size of a datapoint in the OLDB.
Definition: oldbAdapter.cpp:398
Response SendReadRequest(const ReadRequest &request) const override
Sends a request to read data from the repository.
Definition: oldbAdapter.cpp:505
OldbAdapter(const OldbAdapter &)=delete
This class cannot be copy constructed.
std::pair< PathList, PathList > GetChildren(const DataPointPath &path) const override
Queries the datapoints and child paths for a given path.
Definition: oldbAdapter.cpp:486
A request object to pass information about datapoints that should be written to the repository.
Definition: repositoryIf.hpp:115
A request object to pass information about datapoints to unsubscribe from.
Definition: repositorySubscriberIf.hpp:115
static void InitMetadata()
Initialises the type metadata in the CII configuration service for the OLDB.
Definition: oldbAdapter.cpp:721
Definition: oldbIf.hpp:20
OldbAdapter()=delete
Do not allow construction with no arguments.
OldbAdapter(OldbAdapter &&)=default
Objects of this class can be moved.
virtual void CreateDataPoint(const DataPointPath &path, const std::type_info &type)=0
Creates a new datapoint in the repository with a specified type.
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:65
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:188
virtual void CreateDataPoint(const DataPointPath &path, const std::type_info &type)=0
Creates a new datapoint in the repository with a specified type.
Response SendSubscribeRequest(const SubscribeRequest &request) const override
This is called to asynchronously send a subscription request for datapoints.
Definition: oldbAdapter.cpp:667
virtual ~OldbAdapter()
Destroys the adapter for the OLDB service releasing allocated resources.
Definition: oldbAdapter.cpp:289
const std::type_info & GetDataPointType(const DataPointPath &path) const override
Retrieves the corresponding C++ type for the datapoint from the OLDB.
Definition: oldbAdapter.cpp:314
Header file for OldbIf, which defines the API for OldbAdapters.