Abstract interface providing basic read and write facilities to a repository.
More...
#include <repositoryIf.hpp>
|
| class | Request |
| | A request object to pass information about datapoints that should be read (written) from (to) the repository. More...
|
| |
| class | Response |
| | An object used to wait for a request to complete. More...
|
| |
Abstract interface providing basic read and write facilities to a repository.
◆ StringList
◆ ~RepositoryIf()
| rtctk::componentFramework::RepositoryIf::~RepositoryIf |
( |
| ) |
|
|
virtual |
◆ CreateDataPoint()
| virtual void rtctk::componentFramework::RepositoryIf::CreateDataPoint |
( |
const DataPointPath & |
path, |
|
|
const std::string & |
type |
|
) |
| |
|
pure virtual |
Creates a new datapoint in the repository with a specified type.
- Parameters
-
| [in] | path | The datapoint path that should be created. |
| [in] | type | A string indicating the type of the new datapoint. Valid values are indicated below. |
The following are the supported values for the type string:
-
RtcBool
-
RtcInt32
-
RtcInt64
-
RtcFloat
-
RtcDouble
-
RtcString
-
RtcVectorBool
-
RtcVectorInt32
-
RtcVectorInt64
-
RtcVectorFloat
-
RtcVectorDouble
-
RtcVectorString
-
RtcMatrixBool
-
RtcMatrixInt32
-
RtcMatrixInt64
-
RtcMatrixFloat
-
RtcMatrixDouble
-
RtcMatrixString
Implemented in rtctk::componentFramework::FileRepository, MockRuntimeRepo, MockOldb, MockRuntimeRepo, and MockOldb.
◆ CreateDataPointV2() [1/3]
template<typename T >
| void rtctk::componentFramework::RepositoryIf::CreateDataPointV2 |
( |
const DataPointPath & |
path | ) |
|
Creates a new datapoint in the repository.
The type of the datapoint is derived from the template argument type.
- Parameters
-
| [in] | path | The datapoint path that should be created. |
◆ CreateDataPointV2() [2/3]
template<>
| void rtctk::componentFramework::RepositoryIf::CreateDataPointV2 |
( |
const DataPointPath & |
path, |
|
|
const char * |
default_value |
|
) |
| |
◆ CreateDataPointV2() [3/3]
template<typename T >
| void rtctk::componentFramework::RepositoryIf::CreateDataPointV2 |
( |
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.
- Parameters
-
| [in] | path | The datapoint path that should be created. |
| [in] | default_value | The default value that should be set for the new datapoint. |
◆ DataPointExists()
| virtual bool rtctk::componentFramework::RepositoryIf::DataPointExists |
( |
const DataPointPath & |
path | ) |
const |
|
pure virtual |
◆ DeleteDataPoint()
| virtual void rtctk::componentFramework::RepositoryIf::DeleteDataPoint |
( |
const DataPointPath & |
path | ) |
|
|
pure virtual |
◆ GetChildren()
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 std::runtime_error is thrown.
- Parameters
-
| [in] | path | The path in which to search for datapoints and child paths. |
- Returns
- A
std::pair or 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.
Implemented in rtctk::componentFramework::FileRepository, MockRuntimeRepo, MockOldb, MockRuntimeRepo, and MockOldb.
◆ GetDataPoint()
template<typename T >
| 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 std::runtime_error is thrown.
- Note
- This method blocks while waiting for the read request from the repository to complete.
- Parameters
-
| [in] | path | The path of the datapoint that should be fetched from the repository. |
- Returns
- The datapoint's value.
◆ GetDataPointSize()
| virtual size_t rtctk::componentFramework::RepositoryIf::GetDataPointSize |
( |
const DataPointPath & |
path | ) |
const |
|
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:
- Scalars
- Will always return
1 for scalars such as RtcBool, RtcInt32, RtcInt64, RtcFloat, and RtcDouble.
- Strings
- Will return the length of the string, i.e. the number of characters in the string.
- Vectors
- Will return the number of elements in the vector.
- Matrices
- Will return the total number of elements in the matrix, i.e. the number of rows times the number of columns.
- Returns
- The number of elements in the datapoint's data.
Implemented in rtctk::componentFramework::FileRepository, MockRuntimeRepo, MockOldb, MockRuntimeRepo, and MockOldb.
◆ GetDataPointType()
| virtual std::string rtctk::componentFramework::RepositoryIf::GetDataPointType |
( |
const DataPointPath & |
path | ) |
const |
|
pure virtual |
Fetches the type of the datapoint.
This will return the type used when the datapoint was created with the CreateDataPoint method. If the CreateDataPointV2 method was used instead then this returns the type string that was inferred by that method.
- Returns
- The type of the datapoint as a string, i.e. the type as is encoded in the underlying YAML file.
Implemented in rtctk::componentFramework::FileRepository, MockRuntimeRepo, MockOldb, MockRuntimeRepo, and MockOldb.
◆ ReadDataPoint()
template<typename T >
| 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 std::runtime_error is thrown.
- Note
- This method blocks while waiting for the data to be received from the repository.
- Parameters
-
| [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. |
◆ SendReadRequest()
| virtual Response rtctk::componentFramework::RepositoryIf::SendReadRequest |
( |
const Request & |
request | ) |
const |
|
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.
- Note
- The buffers for the datapoints added to
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 std::runtime_error is thrown.
- Note
- This method is not transactional or fully atomic. If an error occurs while reading the datapoints, some or all of the datapoint buffers registered with the read request may be left unmodified. It is however guaranteed that any particular datapoint buffer is either updated completely or not modified at all.
- Parameters
-
| [in] | request | The request object that contains all the datapoints to read. |
- Returns
- A response object that must be used to synchronise with the completion of the read request.
Implemented in rtctk::componentFramework::FileRepository, MockRuntimeRepo, MockOldb, MockRuntimeRepo, and MockOldb.
◆ SendWriteRequest()
| virtual Response rtctk::componentFramework::RepositoryIf::SendWriteRequest |
( |
const Request & |
request | ) |
|
|
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.
- Note
- The buffers for the datapoints added to
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 std::runtime_error is thrown.
- Note
- This method is not transactional or fully atomic. If an error occurs while writing the datapoints, only some of the datapoints registered with the write request may be actually updated in the repository. It is however guaranteed that any particular datapoint is either updated completely in the repository or not at all.
- Parameters
-
| [in] | request | The request object that contains all the datapoints to write. |
- Returns
- A response object that must be used to synchronise with the completion of the write request.
Implemented in rtctk::componentFramework::FileRepository, MockRuntimeRepo, MockOldb, MockRuntimeRepo, and MockOldb.
◆ SetDataPoint() [1/2]
template<>
| void rtctk::componentFramework::RepositoryIf::SetDataPoint |
( |
const DataPointPath & |
path, |
|
|
const char * |
value |
|
) |
| |
◆ SetDataPoint() [2/2]
template<typename T >
| 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 std::runtime_error is thrown.
- Note
- This method blocks while waiting for the data to be sent to the repository.
- Parameters
-
| [in] | path | The path of the datapoint that should be updated in the repository. |
| [in] | value | The new data for the datapoint. |
◆ WriteDataPoint() [1/2]
| void rtctk::componentFramework::RepositoryIf::WriteDataPoint |
( |
const DataPointPath & |
path, |
|
|
const char * |
buffer |
|
) |
| |
◆ WriteDataPoint() [2/2]
template<typename T >
| 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 std::runtime_error is thrown.
This method is preferred over SetDataPoint for large vectors and matrices, since passing a reference to the buffer is more efficient.
- Note
- This method blocks while waiting for the data to be sent to the repository.
- Parameters
-
| [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. |
The documentation for this class was generated from the following files: