13#ifndef RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
14#define RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
68 const std::type_info& type,
69 const std::function<
void()>& callback)
70 : m_path(path), m_buffer(buffer), m_type(&type), m_callback(callback) {
79 inline const std::type_info&
GetType()
const {
94 const std::type_info* m_type;
97 std::function<void()> m_callback;
100 template <
typename T>
102 template <
typename T,
typename F>
104 inline const std::vector<Parameters>&
GetParams()
const {
112 std::vector<Parameters> m_params;
141 const std::type_info& type,
142 const std::function<
void()>& callback)
143 : m_path(path), m_buffer(buffer), m_type(&type), m_callback(callback) {
152 inline const std::type_info&
GetType()
const {
164 const void* m_buffer;
167 const std::type_info* m_type;
170 std::function<void()> m_callback;
173 template <
typename T>
175 template <
typename T,
typename F>
177 inline const std::vector<Parameters>&
GetParams()
const {
185 std::vector<Parameters> m_params;
199 explicit Response(std::future<void>&& future)
noexcept;
228 bool Wait(
const std::chrono::microseconds& timeout);
234 std::future<void> m_future;
272 template <
typename T>
274 template <
typename T>
355 template <
typename T>
357 template <
typename T>
359 template <
typename T>
361 template <
typename T>
432 m_params.push_back(
Parameters(path, &buffer,
typeid(buffer),
nullptr));
463template <
typename T,
typename F>
465 static_assert(std::is_convertible_v<F, std::function<void(T&)>>,
466 "The handler callback must have a signature compatible with void(T&).");
470 auto callback = [handler, &buffer]() ->
void { handler(buffer); };
471 m_params.push_back(
Parameters(path, &buffer,
typeid(buffer), callback));
486 m_params.push_back(
Parameters(path, &buffer,
typeid(buffer),
nullptr));
515template <
typename T,
typename F>
517 static_assert(std::is_convertible_v<F, std::function<void(
const T&)>>,
518 "The handler callback must have a signature compatible with void(const T&).");
519 auto callback = [handler, &buffer]() ->
void { handler(buffer); };
520 m_params.push_back(
Parameters(path, &buffer,
typeid(buffer), callback));
555 CreateDataPoint<T>(path);
616 request.
Add(path, buffer);
641 request.
Add(path, buffer);
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
A structure to hold the arguments passed with one of the Add methods.
Definition: repositoryIf.hpp:55
const DataPointPath & GetPath() const
Definition: repositoryIf.hpp:73
const std::function< void()> & GetCallback() const
Definition: repositoryIf.hpp:82
Parameters(const DataPointPath &path, void *buffer, const std::type_info &type, const std::function< void()> &callback)
Allows to explicitly construct a complete parameters structure.
Definition: repositoryIf.hpp:66
const std::type_info & GetType() const
Definition: repositoryIf.hpp:79
void * GetBuffer() const
Definition: repositoryIf.hpp:76
A request object to pass information about datapoints that should be read from the repository.
Definition: repositoryIf.hpp:49
void Add(const DataPointPath &path, T &buffer)
Adds a datapoint to the request for reading.
Definition: repositoryIf.hpp:431
std::vector< Parameters > & GetParams()
Definition: repositoryIf.hpp:107
const std::vector< Parameters > & GetParams() const
Definition: repositoryIf.hpp:104
An object used to wait for a request to complete.
Definition: repositoryIf.hpp:197
Response & operator=(Response &&other) noexcept
Definition: repositoryIf.cpp:26
void Wait()
Waits for the request that was sent to the repository to complete.
Definition: repositoryIf.cpp:32
A structure to hold the arguments passed with one of the Add methods.
Definition: repositoryIf.hpp:128
const void * GetBuffer() const
Definition: repositoryIf.hpp:149
const std::type_info & GetType() const
Definition: repositoryIf.hpp:152
const DataPointPath & GetPath() const
Definition: repositoryIf.hpp:146
const std::function< void()> & GetCallback() const
Definition: repositoryIf.hpp:155
Parameters(const DataPointPath &path, const void *buffer, const std::type_info &type, const std::function< void()> &callback)
Allows to explicitly construct a complete parameters structure.
Definition: repositoryIf.hpp:139
A request object to pass information about datapoints that should be written to the repository.
Definition: repositoryIf.hpp:122
void Add(const DataPointPath &path, const T &buffer)
Adds a datapoint to the request for writing.
Definition: repositoryIf.hpp:485
std::vector< Parameters > & GetParams()
Definition: repositoryIf.hpp:180
const std::vector< Parameters > & GetParams() const
Definition: repositoryIf.hpp:177
Abstract interface providing basic read and write facilities to a repository.
Definition: repositoryIf.hpp:38
virtual const std::type_info & GetDataPointType(const DataPointPath &path) const =0
Fetches the type of the datapoint.
virtual size_t GetDataPointSize(const DataPointPath &path) const =0
Fetches the size of the datapoint's data.
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition: repositoryIf.hpp:574
virtual std::pair< PathList, PathList > GetChildren(const DataPointPath &path) const =0
Queries the datapoints and child paths for a given path.
virtual void CreateDataPoint(const DataPointPath &path, const std::type_info &type)=0
Creates a new datapoint in the repository with a specified type.
void SetDataPoint(const DataPointPath &path, const T value)
Sets a datapoint in the repository.
Definition: repositoryIf.hpp:595
virtual void DeleteDataPoint(const DataPointPath &path)=0
Deletes a datapoint.
void WriteDataPoint(const DataPointPath &path, const T &buffer)
Writes a datapoint to the repository.
Definition: repositoryIf.hpp:639
virtual ~RepositoryIf()
Definition: repositoryIf.cpp:45
virtual bool DataPointExists(const DataPointPath &path) const =0
Checks for the existence of a datapoint in the repository.
std::vector< DataPointPath > PathList
Definition: repositoryIf.hpp:40
void ReadDataPoint(const DataPointPath &path, T &buffer) const
Reads a datapoint from the repository.
Definition: repositoryIf.hpp:614
virtual Response SendWriteRequest(const WriteRequest &request)=0
Sends a request to write data to the repository.
virtual Response SendReadRequest(const ReadRequest &request) const =0
Sends a request to read data from the repository.
Header file for DataPointPath.
Declaration of the MatrixBuffer template class used in APIs.
Declaration of the MatrixSpan template class used in APIs.
Definition: commandReplier.cpp:22