RTC Toolkit
1.0.0
|
Provides access to the OLDB to read and write datapoints. More...
#include <oldbAdapter.hpp>
Public Member Functions | |
OldbAdapter ()=delete | |
Do not allow construction with no arguments. More... | |
OldbAdapter (const OldbAdapter &)=delete | |
This class cannot be copy constructed. More... | |
OldbAdapter & | operator= (const OldbAdapter &)=delete |
This class cannot be copy assigned. More... | |
OldbAdapter (OldbAdapter &&)=default | |
Objects of this class can be moved. More... | |
OldbAdapter & | operator= (OldbAdapter &&)=default |
Objects of this class can be moved with the move assignment operator. More... | |
OldbAdapter (const elt::mal::Uri &baseuri) | |
Constructs an adapter for the OLDB service with the default OLDB API interface. More... | |
OldbAdapter (const elt::mal::Uri &baseuri, const std::shared_ptr< elt::oldb::CiiOldb > &oldb) | |
Constructs an adapter for the OLDB service with a specific OLDB API interface. More... | |
virtual | ~OldbAdapter () |
Destroys the adapter for the OLDB service releasing allocated resources. More... | |
void | CreateDataPoint (const DataPointPath &path, const std::type_info &type) override |
Creates a new datapoint in the OLDB. More... | |
void | DeleteDataPoint (const DataPointPath &path) override |
Deletes a datapoint in the OLDB. More... | |
const std::type_info & | GetDataPointType (const DataPointPath &path) const override |
Retrieves the corresponding C++ type for the datapoint from the OLDB. More... | |
std::size_t | GetDataPointSize (const DataPointPath &path) const override |
Returns the size of a datapoint in the OLDB. More... | |
bool | DataPointExists (const DataPointPath &path) const override |
Checks for the existence of a datapoint in the repository. More... | |
std::pair< StringList, StringList > | GetChildren (const DataPointPath &path) const override |
Queries the datapoints and child paths for a given path. More... | |
Response | SendReadRequest (const Request &request) const override |
Sends a request to read data from the repository. More... | |
Response | SendWriteRequest (const Request &request) override |
Sends a request to write data to the repository. More... | |
Response | SendSubscribeRequest (const SubscribeRequest &request) const override |
This is called to asynchronously send a subscription request for datapoints. More... | |
Response | SendUnsubscribeRequest (const UnsubscribeRequest &request) const override |
This is called to asynchronously send a request to unsubscribe from various notifications. More... | |
template<typename T , typename U , typename V > | |
void | CastAndRegisterSubscription (const SubscribeRequest::Parameters ¶ms, const std::shared_ptr< CiiOldbTypedDataBase > &datapoint, std::function< void(T *, const std::shared_ptr< CiiOldbDpValue< U >> &)> write_function) const |
virtual void | CreateDataPoint (const DataPointPath &path, const std::type_info &type)=0 |
Creates a new datapoint in the repository with a specified type. More... | |
template<typename T > | |
void | CreateDataPoint (const DataPointPath &path) |
Creates a new datapoint in the repository. More... | |
template<typename T > | |
void | CreateDataPoint (const DataPointPath &path, const T default_value) |
Creates a new datapoint in the repository and sets a default value. More... | |
template<> | |
void | CreateDataPoint (const DataPointPath &path, const char *default_value) |
Public Member Functions inherited from rtctk::componentFramework::OldbIf | |
virtual | ~OldbIf ()=default |
Public Member Functions inherited from rtctk::componentFramework::RepositoryIf | |
virtual | ~RepositoryIf () |
template<typename T > | |
void | CreateDataPoint (const DataPointPath &path) |
Creates a new datapoint in the repository. More... | |
template<typename T > | |
void | CreateDataPoint (const DataPointPath &path, const T default_value) |
Creates a new datapoint in the repository and sets a default value. More... | |
template<typename T > | |
T | GetDataPoint (const DataPointPath &path) const |
Fetches a datapoint from the repository. More... | |
template<typename T > | |
void | SetDataPoint (const DataPointPath &path, const T value) |
Sets a datapoint in the repository. More... | |
template<typename T > | |
void | ReadDataPoint (const DataPointPath &path, T &buffer) const |
Reads a datapoint from the repository. More... | |
template<typename T > | |
void | WriteDataPoint (const DataPointPath &path, const T &buffer) |
Writes a datapoint to the repository. More... | |
void | WriteDataPoint (const DataPointPath &path, const char *buffer) |
template<> | |
void | CreateDataPoint (const DataPointPath &path, const char *default_value) |
template<> | |
void | SetDataPoint (const DataPointPath &path, const char *value) |
Public Member Functions inherited from rtctk::componentFramework::RepositorySubscriberIf | |
virtual | ~RepositorySubscriberIf () |
template<typename T , typename F > | |
void | Subscribe (const DataPointPath &path, T &buffer, F handler) const |
A convenience template function that will register a callback to receive new datapoint values in a synchronous manner. More... | |
void | Unsubscribe (const DataPointPath &path) const |
A simple convenience function that will deregister all callbacks for receiving new datapoint values. More... | |
Protected Member Functions | |
void | SetMetadataInstanceMap (const std::map< std::type_index, std::string > &map) |
Sets the type_index to OLDB metadata instance name map. More... | |
void | SetTypeInfoMap (const std::map< std::string, const std::type_info & > &map) |
Sets the OLDB metadata instance name to type_info map. More... | |
Additional Inherited Members | |
Public Types inherited from rtctk::componentFramework::RepositoryIf | |
using | StringList = std::vector< std::string > |
Static Public Member Functions inherited from rtctk::componentFramework::OldbIf | |
static std::unique_ptr< OldbIf > | CreateAdapter (const elt::mal::Uri &uri) |
Factory method used to create the appropriate OLDB adapter depending on the URI scheme. More... | |
Provides access to the OLDB to read and write datapoints.
Uses the OLDB API under the hood, but standardises the interface to be compatible with other repositories in the RTC Toolkit.
|
delete |
Do not allow construction with no arguments.
|
delete |
This class cannot be copy constructed.
|
default |
Objects of this class can be moved.
|
explicit |
Constructs an adapter for the OLDB service with the default OLDB API interface.
[in] | baseuri | The OLDB URI containing a base path where the datapoints are stored. The URI must use the cii.oldb scheme. |
|
explicit |
Constructs an adapter for the OLDB service with a specific OLDB API interface.
[in] | baseuri | The OLDB URI containing a base path where the datapoints are stored. The URI must use the cii.oldb scheme. |
[in] | oldb | The OLDB API client object to use under the hood. |
|
virtual |
Destroys the adapter for the OLDB service releasing allocated resources.
void rtctk::componentFramework::OldbAdapter::CastAndRegisterSubscription | ( | const SubscribeRequest::Parameters & | params, |
const std::shared_ptr< CiiOldbTypedDataBase > & | datapoint, | ||
std::function< void(T *, const std::shared_ptr< CiiOldbDpValue< U >> &)> | write_function | ||
) | const |
void rtctk::componentFramework::RepositoryIf::CreateDataPoint | ( | typename T | ) |
Creates a new datapoint in the repository.
The type of the datapoint is derived from the template argument type.
[in] | path | The datapoint path that should be created. |
void rtctk::componentFramework::RepositoryIf::CreateDataPoint | ( | ) |
|
overridevirtual |
Creates a new datapoint in the OLDB.
[in] | path | The path of the new datapoint. |
[in] | type | The data type of the datapoint. More specifically this corresponds to the metadata instance name as configured in the CII configuration service that is supported by OLDB. |
CiiOldbDpExistsException | If there is already a datapoint with the given path. |
CiiOldbInvalidUriException | If the path is in violation of OLDB URI rules. |
CiiOldbUndefinedMetadataException | If datapoint info does not exist. |
CiiOldbStorageError | If the data provider has problems with reading/storing datapoints. |
CiiOldbException | If an unknown OLDB error occurs. |
Implements rtctk::componentFramework::RepositoryIf.
virtual void rtctk::componentFramework::RepositoryIf::CreateDataPoint |
Creates a new datapoint in the repository with a specified type.
[in] | path | The datapoint path that should be created. |
[in] | type | A type identifier object returned by typeid indicating the type of the new datapoint. Supported values are indicated below. |
The following are the supported values for the type
argument:
void rtctk::componentFramework::RepositoryIf::CreateDataPoint | ( | typename T | ) |
Creates a new datapoint in the repository and sets a default value.
The type of the datapoint is derived from the template argument type.
[in] | path | The datapoint path that should be created. |
[in] | default_value | The default value that should be set for the new datapoint. |
|
overridevirtual |
Checks for the existence of a datapoint in the repository.
[in] | path | The datapoint path to check. |
true
if the datapoint path exists in the repository and false
otherwise.Implements rtctk::componentFramework::RepositoryIf.
|
overridevirtual |
Deletes a datapoint in the OLDB.
[in] | path | The path of an existing datapoint to delete. |
CiiOldbDpUndefinedException | If there is no datapoint with the specified path. Either such URL does not exist, or the URL is not a datapoint but a hierarchy element (folder). |
CiiOldbStorageError | If the data provider has problems with reading/writing datapoints. |
CiiOldbException | If an unknown OLDB error occurs. |
Implements rtctk::componentFramework::RepositoryIf.
|
overridevirtual |
Queries the datapoints and child paths for a given path.
This method will query all the available datapoints that are leaf nodes immediately below the given path
and also the child paths, i.e. sub-folders when interpreting the repository as a hierarchical folder like structure. The set of immediate datapoint and child paths is returned as two separate lists.
If an error occurs when querying the the repository a rtctk::componentFramework::RtctkException
is thrown.
[in] | path | The path in which to search for datapoints and child paths. |
std::pair
of string lists, i.e. std::vector<std::string>
, with the first list in the pair containing the datapoints found and the second list containing the child paths found. If no datapoints are found then the list for datapoints is empty. Similarly if not child paths are found then the child path list is empty.Implements rtctk::componentFramework::RepositoryIf.
|
overridevirtual |
Returns the size of a datapoint in the OLDB.
This method will return the size in bytes for all scalar types. For strings it returns the number of characters in the string. For vectors and matrices it returns the total number of elements. For binary blobs it returns the total number of bytes.
[in] | path | The path of the datapoint. |
CiiOldbInvalidUriException | If the path is in violation of OLDB URI rules. |
CiiOldbDpUndefinedException | If there is no datapoint with the specified path. Either such URL does not exist, or the URL is not a datapoint but a hierarchy element (folder). |
CiiOldbStorageError | If the data provider has problems with reading/storing datapoints. |
CiiOldbException | If an unknown OLDB error occurs. |
Implements rtctk::componentFramework::RepositoryIf.
|
overridevirtual |
Retrieves the corresponding C++ type for the datapoint from the OLDB.
[in] | path | The path of the datapoint. |
type_info
corresponding to the type that was used during datapoint creation.CiiOldbInvalidUriException | If the path is in violation of OLDB URI rules. |
CiiOldbDpUndefinedException | If there is no datapoint with the specified path. Either such URL does not exist, or the URL is not a datapoint but a hierarchy element (folder). |
CiiOldbStorageError | If the data provider has problems with reading/storing datapoints. |
CiiOldbException | If an unknown OLDB error occurs. |
Implements rtctk::componentFramework::RepositoryIf.
|
delete |
This class cannot be copy assigned.
|
default |
Objects of this class can be moved with the move assignment operator.
|
overridevirtual |
Sends a request to read data from the repository.
This method allows non-blocking and asynchronous reading of datapoints form the repository. The method returns immediately, allowing other work to be done in the calling thread while the read request is completed in the background. If any callback handlers were registered in request
, they will be called as soon as the data is available for the respective datapoint.
request
must not be accessed until the Wait
method of the response object returns successfully, i.e. without a timeout.If an error occurs then a rtctk::componentFramework::RtctkException
is thrown.
[in] | request | The request object that contains all the datapoints to read. |
Implements rtctk::componentFramework::RepositoryIf.
|
overridevirtual |
This is called to asynchronously send a subscription request for datapoints.
One or more datapoints can be subscribed to by constructing a SubscribeRequest object and sending it to the repository service with this method. A typical usage is indicated in the following code sample:
[in] | request | The subscription request to send to the repository. |
Implements rtctk::componentFramework::RepositorySubscriberIf.
|
overridevirtual |
This is called to asynchronously send a request to unsubscribe from various notifications.
One can stop receiving notifications for one or more datapoints by constructing a UnsubscribeRequest object and sending it to the repository service with this method. A typical usage is indicated in the following code sample:
[in] | request | The request to send to the repository. |
Implements rtctk::componentFramework::RepositorySubscriberIf.
|
overridevirtual |
Sends a request to write data to the repository.
This method allows non-blocking writing of datapoints to the repository. The method returns immediately, allowing other work to be done in the calling thread while the write request is completed in the background. If any callback handlers were registered in request
, they will be called as soon as the respective datapoint's data has been sent and the buffer will no longer be accessed by the API, i.e. the caller can modify or release the buffer from that point on.
request
must not be modified or released until the Wait
method of the response object returns successfully, i.e. without a timeout.If an error occurs then a rtctk::componentFramework::RtctkException
is thrown.
[in] | request | The request object that contains all the datapoints to write. |
Implements rtctk::componentFramework::RepositoryIf.
|
protected |
Sets the type_index to OLDB metadata instance name map.
[in] | map | The new map to use. This object must be kept alive and unmodified for the lifetime of all OldbAdapter instances. |
|
protected |
Sets the OLDB metadata instance name to type_info map.
[in] | map | The new map to use. This object must be kept alive and unmodified for the lifetime of all OldbAdapter instances. |