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);
178 void SetTypeInfoMap(
const std::map<std::string, const std::type_info&>& map);
196 template <
typename F>
205 template <
typename T>
214 template <
typename T>
215 void WriteData(
const DataPointPath& path,
const T& buffer)
const;
222 template <
typename T>
223 void RegisterSubscription(
const SubscribeRequest::Parameters& params)
const;
226 struct IoFunctionMapEntry {
228 using WriteFunction =
230 using RegisterFunction =
231 std::function<void(
const OldbAdapter*,
const SubscribeRequest::Parameters&)>;
233 ReadFunction m_read_function;
234 WriteFunction m_write_function;
235 RegisterFunction m_register_function;
239 using IoFunctionMap = std::map<std::type_index, IoFunctionMapEntry>;
246 template <
typename T>
247 static auto MakeMapEntry();
250 struct SubscriptionEntry {
251 std::shared_ptr<elt::oldb::CiiOldbTypedDataBase> m_datapoint;
252 std::shared_ptr<elt::oldb::CiiOldbDpSubscriptionBase> m_subscription;
261 std::function<bool(
const SubscriptionEntry&,
const UnsubscribeRequest::Parameters&)>
262 m_unregister_callback;
265 using SubsciptionMap = std::list<SubscriptionEntry>;
277 template <
typename T,
typename U,
typename V>
278 void CastAndRegisterSubscription(
279 const SubscribeRequest::Parameters& params,
280 const std::shared_ptr<elt::oldb::CiiOldbTypedDataBase>& datapoint,
281 std::function<
void(T*,
const std::shared_ptr<elt::oldb::CiiOldbDpValue<U>>&)>
282 write_function)
const;
285 mutable std::shared_ptr<elt::oldb::CiiOldb> m_client;
291 const elt::mal::Uri m_baseuri;
294 mutable std::list<SubscriptionEntry> m_subscriptions;
297 mutable std::mutex m_mutex;
300 const std::map<std::type_index, std::string>* m_metadata_instance_map =
nullptr;
303 static const std::map<std::type_index, std::string> S_METADATA_INSTANCE_MAP;
306 const std::map<std::string, const std::type_info&>* m_type_info_map =
nullptr;
309 static const std::map<std::string, const std::type_info&> S_TYPE_INFO_MAP;
312 static const IoFunctionMap S_IO_FUNCTIONS;
317 #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:1034
void DeleteDataPoint(const DataPointPath &path) override
Deletes a datapoint in the OLDB.
Definition: oldbAdapter.cpp:318
OldbAdapter & operator=(const OldbAdapter &)=delete
This class cannot be copy assigned.
Response SendReadRequest(const Request &request) const override
Sends a request to read data from the repository.
Definition: oldbAdapter.cpp:514
A request object to pass information about datapoints that should be read (written) from (to) the rep...
Definition: repositoryIf.hpp:45
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:991
bool DataPointExists(const DataPointPath &path) const override
Checks for the existence of a datapoint in the repository.
Definition: oldbAdapter.cpp:485
Response SendUnsubscribeRequest(const UnsubscribeRequest &request) const override
This is called to asynchronously send a request to unsubscribe from various notifications.
Definition: oldbAdapter.cpp:695
Definition: commandReplier.cpp:20
A request object to pass information about datapoints to subscribe to.
Definition: repositorySubscriberIf.hpp:31
std::size_t GetDataPointSize(const DataPointPath &path) const override
Returns the size of a datapoint in the OLDB.
Definition: oldbAdapter.cpp:407
OldbAdapter(const OldbAdapter &)=delete
This class cannot be copy constructed.
std::pair< StringList, StringList > GetChildren(const DataPointPath &path) const override
Queries the datapoints and child paths for a given path.
Definition: oldbAdapter.cpp:495
Response SendWriteRequest(const Request &request) override
Sends a request to write data to the repository.
Definition: oldbAdapter.cpp:518
A request object to pass information about datapoints to unsubscribe from.
Definition: repositorySubscriberIf.hpp:95
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 wraper for DataPoint paths which ensures that they only contain valid character...
Definition: dataPointPath.hpp:34
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:106
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:676
virtual ~OldbAdapter()
Destroys the adapter for the OLDB service releasing allocated resources.
Definition: oldbAdapter.cpp:298
const std::type_info & GetDataPointType(const DataPointPath &path) const override
Retrieves the corresponding C++ type for the datapoint from the OLDB.
Definition: oldbAdapter.cpp:323
Header file for OldbIf, which defines the API for OldbAdapters.