Go to the documentation of this file.
9 #ifndef RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
10 #define RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
62 inline const std::vector<Parameters>&
GetParams()
const {
return m_params; };
65 std::vector<Parameters> m_params;
76 Response(std::future<void>&& future) noexcept;
80 bool Wait(
const std::chrono::seconds timeout);
86 std::future<void> m_future;
256 template <
typename T>
258 m_params.push_back({
path, &buffer, std::type_index(
typeid(buffer))});
267 template <
typename T>
269 m_params.push_back({
path,
const_cast<T*
>(&buffer), std::type_index(
typeid(buffer))});
294 template <
typename T,
typename F>
299 auto callback = [handler, &buffer] () ->
void { handler(buffer); };
300 m_params.push_back({
path, &buffer, std::type_index(
typeid(buffer)), callback});
323 template <
typename T,
typename F>
325 auto callback = [handler, &buffer] () ->
void { handler(buffer); };
326 m_params.push_back({
path,
const_cast<T*
>(&buffer), std::type_index(
typeid(buffer)),
337 template <
typename T>
339 static const std::map<std::type_index, std::string> type_map = {
340 {std::type_index(
typeid(
bool)),
"RtcBool"},
341 {std::type_index(
typeid(
int32_t)),
"RtcInt32"},
342 {std::type_index(
typeid(int64_t)),
"RtcInt64"},
343 {std::type_index(
typeid(
float)),
"RtcFloat"},
344 {std::type_index(
typeid(
double)),
"RtcDouble"},
345 {std::type_index(
typeid(std::string)),
"RtcString"},
346 {std::type_index(
typeid(std::vector<bool>)),
"RtcVectorBool"},
347 {std::type_index(
typeid(std::vector<int32_t>)),
"RtcVectorInt32"},
348 {std::type_index(
typeid(std::vector<int64_t>)),
"RtcVectorInt64"},
349 {std::type_index(
typeid(std::vector<float>)),
"RtcVectorFloat"},
350 {std::type_index(
typeid(std::vector<double>)),
"RtcVectorDouble"},
351 {std::type_index(
typeid(std::vector<std::string>)),
"RtcVectorString"},
359 std::string type = type_map.at(std::type_index(
typeid(T)));
371 template <
typename T>
373 CreateDataPointV2<T>(
path);
388 template <
typename T>
406 template <
typename T>
422 template <
typename T>
444 template <
typename T>
461 #endif // RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
void SetDataPoint(const DataPointPath &path, const T value)
Sets a datapoint in the repository.
Definition: repositoryIf.hpp:407
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition: repositoryIf.hpp:389
virtual Response SendWriteRequest(const Request &request)=0
Sends a request to write data to the repository.
A request object to pass information about datapoints that should be read (written) from (to) the rep...
Definition: repositoryIf.hpp:37
std::function< void()> m_callback
The callback function to invoke when a datapoint is received.
Definition: repositoryIf.hpp:54
Definition: rtcComponent.hpp:17
std::type_index m_type
This stores the type information for the buffer.
Definition: repositoryIf.hpp:51
virtual bool DataPointExists(const DataPointPath &path) const =0
Checks for the existence of a datapoint in the repository.
Declaration of the MatrixBuffer template class used in APIs.
string path
Definition: rtctkExampleDataTaskRobotTest.py:228
virtual size_t GetDataPointSize(const DataPointPath &path) const =0
Fetches the size of the datapoint's data.
const std::vector< Parameters > & GetParams() const
Definition: repositoryIf.hpp:62
virtual void CreateDataPoint(const DataPointPath &path, const std::string &type)=0
Creates a new datapoint in the repository with a specified type.
void * m_buffer
The buffer of data to read (write) for a write (read) request.
Definition: repositoryIf.hpp:48
virtual void DeleteDataPoint(const DataPointPath &path)=0
Deletes a datapoint.
DataPointPath m_path
The datapoint path to read or write.
Definition: repositoryIf.hpp:45
std::vector< std::string > StringList
Definition: repositoryIf.hpp:30
void Add(const DataPointPath &path, T &buffer)
Definition: repositoryIf.hpp:257
void Wait()
Waits for the request sent to the repository to complete.
Definition: repositoryIf.cpp:33
Abstract interface providing basic read and write facilities to a repository.
Definition: repositoryIf.hpp:28
virtual std::pair< StringList, StringList > GetChildren(const DataPointPath &path) const =0
Queries the datapoints and child paths for a given path.
Response & operator=(Response &&other) noexcept
Definition: repositoryIf.cpp:22
Response(std::future< void > &&future) noexcept
Definition: repositoryIf.cpp:14
virtual std::string GetDataPointType(const DataPointPath &path) const =0
Fetches the type of the datapoint.
void ReadDataPoint(const DataPointPath &path, T &buffer) const
Reads a datapoint from the repository.
Definition: repositoryIf.hpp:423
void WriteDataPoint(const DataPointPath &path, const T &buffer)
Writes a datapoint to the repository.
Definition: repositoryIf.hpp:445
A structure to hold the arguments passed with one of the Add methods.
Definition: repositoryIf.hpp:43
int int32_t
Definition: mudpi.h:17
Header file for RepositoryIf and related base classes.
virtual Response SendReadRequest(const Request &request) const =0
Sends a request to read data from the repository.
Definition: dataPointPath.hpp:30
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:74
void CreateDataPointV2(const DataPointPath &path)
Creates a new datapoint in the repository.
Definition: repositoryIf.hpp:338
Definition: matrixBuffer.hpp:19
virtual ~RepositoryIf()
Definition: repositoryIf.cpp:58