RTC Toolkit
2.0.0
|
Abstract interface providing basic read and write facilities to a repository. More...
#include <repositoryIf.hpp>
Classes | |
class | ReadRequest |
A request object to pass information about datapoints that should be read from the repository. More... | |
class | Response |
An object used to wait for a request to complete. More... | |
class | WriteRequest |
A request object to pass information about datapoints that should be written to the repository. More... | |
Public Types | |
using | PathList = std::vector< DataPointPath > |
Public Member Functions | |
virtual | ~RepositoryIf () |
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... | |
virtual void | DeleteDataPoint (const DataPointPath &path)=0 |
Deletes a datapoint. More... | |
virtual const std::type_info & | GetDataPointType (const DataPointPath &path) const =0 |
Fetches the type of the datapoint. More... | |
virtual size_t | GetDataPointSize (const DataPointPath &path) const =0 |
Fetches the size of the datapoint's data. More... | |
virtual bool | DataPointExists (const DataPointPath &path) const =0 |
Checks for the existence of a datapoint in the repository. More... | |
virtual std::pair< PathList, PathList > | GetChildren (const DataPointPath &path) const =0 |
Queries the datapoints and child paths for a given path. 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) |
virtual Response | SendReadRequest (const ReadRequest &request) const =0 |
Sends a request to read data from the repository. More... | |
virtual Response | SendWriteRequest (const WriteRequest &request)=0 |
Sends a request to write data to the repository. More... | |
template<> | |
void | CreateDataPoint (const DataPointPath &path, const char *default_value) |
template<> | |
void | SetDataPoint (const DataPointPath &path, const char *value) |
Abstract interface providing basic read and write facilities to a repository.
using rtctk::componentFramework::RepositoryIf::PathList = std::vector<DataPointPath> |
|
virtual |
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. |
[in] | path | The datapoint path that should be created. |
void rtctk::componentFramework::RepositoryIf::CreateDataPoint | ( | const DataPointPath & | path, |
const char * | default_value | ||
) |
|
pure 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:
Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
void rtctk::componentFramework::RepositoryIf::CreateDataPoint | ( | const DataPointPath & | path, |
const T | default_value | ||
) |
Creates a new datapoint in the repository and sets a default value.
The type of the datapoint is derived from the template argument type.
T | The type of the datapoint to create. |
[in] | path | The datapoint path that should be created. |
[in] | default_value | The default value that should be set for the new datapoint. |
|
pure virtual |
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.Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
|
pure virtual |
Deletes a datapoint.
[in] | path | The path of the datapoint to delete in the repository. |
Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
|
pure virtual |
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.Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
T rtctk::componentFramework::RepositoryIf::GetDataPoint | ( | const DataPointPath & | path | ) | const |
Fetches a datapoint from the repository.
The datapoint is read from the repository and returned. If an error occurs then a rtctk::componentFramework::RtctkException
is thrown.
[in] | path | The path of the datapoint that should be fetched from the repository. |
|
pure virtual |
Fetches the size of the datapoint's data.
This method will return one of the following values depending on the category of the datapoint's type:
1
for scalars such as RtcBool
, RtcInt32
, RtcInt64
, RtcFloat
, and RtcDouble
. Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
|
pure virtual |
Fetches the type of the datapoint.
This will return the type used when the datapoint was created with the CreateDataPoint method.
type_info
object corresponding to the type of the datapoint.Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
void rtctk::componentFramework::RepositoryIf::ReadDataPoint | ( | const DataPointPath & | path, |
T & | buffer | ||
) | const |
Reads a datapoint from the repository.
Fetches the data for a datapoint from the repository and updates a local buffer in-place. If an error occurs then a rtctk::componentFramework::RtctkException
is thrown.
[in] | path | The path of the datapoint that should be fetched from the repository. |
[in] | buffer | A reference to the local buffer that should be filled with the received data. |
|
pure virtual |
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. |
Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
|
pure virtual |
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. |
Implemented in rtctk::componentFramework::PersistentRepoAdapter, rtctk::componentFramework::OldbAdapter, and rtctk::componentFramework::FileRepository.
void rtctk::componentFramework::RepositoryIf::SetDataPoint | ( | const DataPointPath & | path, |
const char * | value | ||
) |
void rtctk::componentFramework::RepositoryIf::SetDataPoint | ( | const DataPointPath & | path, |
const T | value | ||
) |
Sets a datapoint in the repository.
A new value for the datapoint is sent to the repository and updated. If an error occurs then a rtctk::componentFramework::RtctkException
is thrown.
[in] | path | The path of the datapoint that should be updated in the repository. |
[in] | value | The new data for the datapoint. |
void rtctk::componentFramework::RepositoryIf::WriteDataPoint | ( | const DataPointPath & | path, |
const char * | buffer | ||
) |
void rtctk::componentFramework::RepositoryIf::WriteDataPoint | ( | const DataPointPath & | path, |
const T & | buffer | ||
) |
Writes a datapoint to the repository.
Data is read from the buffer reference provided and sent to the repository to update the datapoint. If an error occurs then a rtctk::componentFramework::RtctkException
is thrown.
This method is preferred over SetDataPoint for large vectors and matrices, since passing a reference to the buffer is more efficient.
[in] | path | The path of the datapoint that should be updated in the repository. |
[in] | buffer | A reference to the new data for the datapoint. |