|
RTC Toolkit 5.1.0
|
Provides access to the OLDB to read and write datapoints. More...
#include <rtctk/componentFramework/oldbAdapterLegacy.hpp>
Public Member Functions | |
| OldbAdapterLegacy ()=delete | |
| Do not allow construction with no arguments. | |
| OldbAdapterLegacy (const OldbAdapterLegacy &)=delete | |
| This class cannot be copy constructed. | |
| OldbAdapterLegacy & | operator= (const OldbAdapterLegacy &)=delete |
| This class cannot be copy assigned. | |
| OldbAdapterLegacy (OldbAdapterLegacy &&)=default | |
| Objects of this class can be moved. | |
| OldbAdapterLegacy & | operator= (OldbAdapterLegacy &&)=default |
| Objects of this class can be moved with the move assignment operator. | |
| OldbAdapterLegacy (const elt::mal::Uri &baseuri) | |
| Constructs an adapter for the OLDB service with the default OLDB API interface. | |
| OldbAdapterLegacy (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. | |
| virtual | ~OldbAdapterLegacy () |
| Destroys the adapter for the OLDB service releasing allocated resources. | |
| elt::mal::Uri | GetBaseUri () const |
| Get the base URI used when creating this adapter object. | |
| void | CreateDataPoint (const DataPointPath &path, const std::type_info &type) override |
| Creates a new datapoint in the OLDB. | |
| Response | SendReadRequest (const ReadRequest &request) const override |
| Sends a request to read data from the repository. | |
| Response | SendWriteRequest (const WriteRequest &request) override |
| Sends a request to write data to the repository. | |
| Response | SendSubscribeRequest (const SubscribeRequest &request) const override |
| This is called to asynchronously send a subscription request for datapoints. | |
| Response | SendUnsubscribeRequest (const UnsubscribeRequest &request) const override |
| This is called to asynchronously send a request to unsubscribe from various notifications. | |
| template<typename T , typename U > | |
| 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 |
| template<typename T > | |
| Lut::TableEntries | BindTypeHandlers () |
| template<typename T > | |
| void | CreateDataPoint (const DataPointPath &path) |
| Creates a new datapoint in the repository. | |
| template<typename T > | |
| void | CreateDataPoint (const DataPointPath &path, const T &initial_value) |
| Creates a new datapoint in the repository with an initial value. | |
| void | CreateDataPoint (const DataPointPath &path, const char *initial_value) |
| virtual void | CreateDataPoint (const DataPointPath &path, const std::type_info &type) |
| Creates a new datapoint in the repository with a specified type. | |
Public Member Functions inherited from rtctk::componentFramework::OldbIf | |
| virtual | ~OldbIf ()=default |
Public Member Functions inherited from rtctk::componentFramework::RepositorySubscriberIf | |
| RepositorySubscriberIf ()=default | |
| virtual | ~RepositorySubscriberIf ()=default |
| template<typename T = void, typename F , std::enable_if_t< std::is_convertible_v< F, NotifyCallbackType > or(not std::is_same_v< T, void > and std::is_convertible_v< F, ValueCallbackType< std::conditional_t< std::is_same_v< T, void >, std::byte, T > > >), bool > = true> | |
| Subscription | Subscribe (const DataPointPath &path, const F &cb_value, const ErrorCallbackType &cb_error) const |
| Subscribes to datapoint values change events by registering callbacks. | |
| Subscription | Subscribe (const CallbackType &cb_created, const CallbackType &cb_deleted, const ErrorCallbackType &cb_error) const |
| Subscribes to datapoint creation and deletion events by registering callbacks. | |
| template<typename T , typename F , std::enable_if_t< not std::is_convertible_v< T, RepositorySubscriberIf::NotifyCallbackType >, bool > = true> | |
| 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. | |
| template<typename F > | |
| void | Subscribe (const DataPointPath &path, F handler) const |
| A convenience template function that will register a callback to receive datapoint value change notifications in a synchronous manner. | |
| void | Unsubscribe (const DataPointPath &path) const |
| A simple convenience function that will deregister all callbacks for receiving new datapoint values. | |
Public Member Functions inherited from rtctk::componentFramework::RepositoryIf | |
| RepositoryIf ()=default | |
| virtual | ~RepositoryIf ()=default |
| BatchResponse | SendRequest (const BatchRequest &request) |
| BatchResponse | SendRequest (const BatchRequest &request) const |
| template<typename T > | |
| void | CreateDataPoint (const DataPointPath &path) |
| Creates a new datapoint in the repository. | |
| template<typename T > | |
| void | CreateDataPoint (const DataPointPath &path, const T &initial_value) |
| Creates a new datapoint in the repository with an initial value. | |
| void | CreateDataPoint (const DataPointPath &path, const char *initial_value) |
| void | DeleteDataPoint (const DataPointPath &path, bool recurse=false) |
| Deletes a datapoint. | |
| const std::type_info & | GetDataPointType (const DataPointPath &path) const |
| Fetches the type of the datapoint. | |
| size_t | GetDataPointSize (const DataPointPath &path) const |
| Fetches the size of the datapoint's data. | |
| RtcVectorUInt64 | GetDataPointShape (const DataPointPath &path) const |
| Fetches the shape of the datapoint's data. | |
| bool | DataPointExists (const DataPointPath &path) const |
| Checks for the existence of a datapoint in the repository. | |
| std::pair< PathList, PathList > | GetChildren (const DataPointPath &path, bool recurse=false) const |
| Queries the child datapoints and paths for a given parent path. | |
| template<typename T > | |
| T | GetDataPoint (const DataPointPath &path) const |
| Fetches a datapoint from the repository. | |
| template<typename T > | |
| void | SetDataPoint (const DataPointPath &path, const T &value) |
| Sets a datapoint in the repository. | |
| void | SetDataPoint (const DataPointPath &path, const char *value) |
| template<typename T > | |
| void | ReadDataPoint (const DataPointPath &path, T &buffer) const |
| Reads a datapoint from the repository. | |
| template<typename T > | |
| void | WriteDataPoint (const DataPointPath &path, const T &buffer) |
| Writes a datapoint to the repository. | |
| void | WriteDataPoint (const DataPointPath &path, const char *buffer) |
| template<typename... T> | |
| void | WriteDataPoints (const T &... args) |
| template<typename... T> | |
| void | ReadDataPoints (T &... args) const |
Static Public Member Functions | |
| static void | InitMetadata () |
| Initialises the type metadata in the CII configuration service for the OLDB. | |
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. | |
Static Public Member Functions inherited from rtctk::componentFramework::RepositoryIf | |
| static const std::type_info & | StringToType (const std::string &arg) |
| Converts an RTC type string to a type_info. | |
| static std::string | TypeToString (const std::type_info &arg) |
| Converts a type_info to an RTC type string. | |
Static Public Attributes | |
| static const std::string | SUPPORTED_URI_SCHEME = "cii.oldb.legacy" |
Protected Member Functions | |
| void | DeleteDataPointLegacy (const DataPointPath &path) override |
| Deletes a datapoint in the OLDB. | |
| const std::type_info & | GetDataPointTypeLegacy (const DataPointPath &path) const override |
| Retrieves the corresponding C++ type for the datapoint from the OLDB. | |
| std::size_t | GetDataPointSizeLegacy (const DataPointPath &path) const override |
| Returns the size of a datapoint in the OLDB. | |
| bool | DataPointExistsLegacy (const DataPointPath &path) const override |
| Checks for the existence of a datapoint in the repository. | |
| std::pair< PathList, PathList > | GetChildrenLegacy (const DataPointPath &path) const override |
| Queries the datapoints and child paths for a given path. | |
| void | SetMetadataInstanceMap (const std::map< std::type_index, std::string > &map) |
| Sets the type_index to OLDB metadata instance name map. | |
| void | SetTypeInfoMap (const std::map< std::string, const std::type_info & > &map) |
| Sets the OLDB metadata instance name to type_info map. | |
| elt::oldb::CiiOldbDpCreateContext | GetDataPointCreateContext () const |
| Get the datapoint creation context used by the underlying OLDB client object. | |
| void | SetDataPointCreateContext (elt::oldb::CiiOldbDpCreateContext &context) |
| Sets a new datapoint creation context on the underlying OLDB client object. | |
Additional Inherited Members | |
Public Types inherited from rtctk::componentFramework::OldbIf | |
| using | AdapterIdType = elt::mal::Uri |
| The type used to distinguish between different adapters implementing OldbIf. | |
Public Types inherited from rtctk::componentFramework::RepositorySubscriberIf | |
| template<typename T > | |
| using | ValueCallbackType = std::function<void(const DataPointPath&, T&, const MetaData&)> |
| using | NotifyCallbackType = std::function<void(const DataPointPath&, const MetaData&)> |
| using | ErrorCallbackType = std::function<void(std::exception_ptr)> |
| using | SubscriptionId = size_t |
Public Types inherited from rtctk::componentFramework::RepositoryIf | |
| using | PathList = std::vector<DataPointPath> |
| using | Clock = taiclock::TaiClock |
| using | Timestamp = Clock::time_point |
| using | CallbackType = std::function<void(const DataPointPath&)> |
| Signature of the callback functions that can be registered with the repository requests. | |
Protected Types inherited from rtctk::componentFramework::RepositoryIf | |
| using | RequestList = std::vector<std::any> |
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.
| Lut::TableEntries rtctk::componentFramework::OldbAdapterLegacy::BindTypeHandlers | ( | ) |
| void rtctk::componentFramework::OldbAdapterLegacy::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 | ( | const DataPointPath & | path | ) |
Creates a new datapoint in the repository.
The type of the datapoint is derived from the template argument type.
| T | The type of the datapoint to create. See RepositoryIf::CreateDataPoint for a list of supported types. |
| [in] | path | The datapoint path that should be created. |
| void rtctk::componentFramework::RepositoryIf::CreateDataPoint | ( | const DataPointPath & | path, |
| const char * | initial_value ) |
|
virtual |
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:
Reimplemented from rtctk::componentFramework::RepositoryIf.
Reimplemented in rtctk::componentFramework::RuntimeRepoAdapterLegacy.
|
overridevirtual |
Creates a new datapoint in the OLDB.
| [in] | path | The path of the new datapoint. |
| [in] | type | The data type of the datapoint. See RepositoryIf::CreateDataPoint for a list of supported types. |
| 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. |
Reimplemented from rtctk::componentFramework::RepositoryIf.
Reimplemented in rtctk::componentFramework::RuntimeRepoAdapterLegacy.
| void rtctk::componentFramework::RepositoryIf::CreateDataPoint | ( | const DataPointPath & | path, |
| const T & | initial_value ) |
Creates a new datapoint in the repository with an initial value.
The type of the datapoint is derived from the template argument type.
| T | The type of the datapoint to create. See RepositoryIf::CreateDataPoint for a list of supported types. |
| [in] | path | The datapoint path that should be created. |
| [in] | initial_value | The initial value that should be set for the new datapoint. |
|
overrideprotectedvirtual |
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.Reimplemented from rtctk::componentFramework::RepositoryIf.
|
overrideprotectedvirtual |
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. |
Reimplemented from rtctk::componentFramework::RepositoryIf.
|
inline |
Get the base URI used when creating this adapter object.
|
overrideprotectedvirtual |
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 path lists, i.e. std::vector<DataPointPath>, 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.Reimplemented from rtctk::componentFramework::RepositoryIf.
|
protected |
Get the datapoint creation context used by the underlying OLDB client object.
|
overrideprotectedvirtual |
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. |
Reimplemented from rtctk::componentFramework::RepositoryIf.
|
overrideprotectedvirtual |
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. |
Reimplemented from rtctk::componentFramework::RepositoryIf.
|
static |
Initialises the type metadata in the CII configuration service for the OLDB.
Default metadata related to standard data types needs to be initialised in the CII configuration service before the OldbAdapterLegacy can be used properly. This function will create the needed metadata if it is missing. If the metadata for the types already exists then this function will reset the values.
| InitialisationException | For any error that occurs in the CII system. |
|
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. |
Reimplemented from 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. |
Reimplemented from 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. |
Reimplemented from 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. |
Reimplemented from rtctk::componentFramework::RepositoryIf.
|
protected |
Sets a new datapoint creation context on the underlying OLDB client object.
| [in] | context | The new context to set. |
|
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 OldbAdapterLegacy 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 OldbAdapterLegacy instances. |
|
inlinestatic |