13#ifndef RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
14#define RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
21#include <initializer_list>
30#include <taiclock/taiClock.hpp>
57 using Clock = taiclock::TaiClock;
113 const std::vector<Info>&
GetInfo()
const;
116 static RTCTK_LOCAL std::string InfoToString(
const std::vector<Info>& info);
118 std::shared_ptr<std::vector<Info>> m_info;
166 inline bool HasValue() const noexcept;
178 inline operator const
std::any&() const;
187 template <typename T>
188 const T&
Cast() const;
196 const
std::
string& m_key;
199 const
std::any& m_value;
220 inline bool HasValue() const noexcept;
232 inline operator const
std::any&() const;
241 template <typename T>
251 template <typename T>
252 const T&
Cast() const;
273 template <typename T>
281 inline
void Reset() noexcept;
289 const
std::
string& m_key;
296 using MapType =
std::map<
std::
string,
std::any>;
305 template <typename MapIterType, typename ProxyType>
308 using iterator_concept = std::bidirectional_iterator_tag;
309 using iterator_category = std::bidirectional_iterator_tag;
310 using value_type = std::pair<const MapType::key_type&, ProxyType>;
311 using difference_type = MapType::difference_type;
312 using pointer = void;
313 using reference = std::conditional_t<std::is_same_v<ProxyType, ConstValueProxy>,
317 IteratorImpl() =
default;
318 IteratorImpl(
const IteratorImpl& rhs) =
default;
319 IteratorImpl(IteratorImpl&& rhs)
noexcept =
default;
320 ~IteratorImpl() =
default;
321 IteratorImpl&
operator=(
const IteratorImpl& rhs) =
default;
322 IteratorImpl&
operator=(IteratorImpl&& rhs)
noexcept =
default;
323 value_type& operator*();
324 value_type operator*()
const;
325 value_type* operator->();
326 const value_type* operator->()
const;
327 IteratorImpl& operator++();
328 IteratorImpl operator++(
int);
329 IteratorImpl& operator--();
330 IteratorImpl operator--(
int);
331 bool operator==(
const IteratorImpl& rhs)
const;
332 bool operator!=(
const IteratorImpl& rhs)
const;
337 MapIterType m_iterator;
343 std::optional<value_type> m_pair;
350 class RTCTK_API Iterator final :
public IteratorImpl<MapType::iterator, ValueProxy> {
353 RTCTK_LOCAL inline Iterator(MapType::iterator&& iter);
361 :
public IteratorImpl<MapType::const_iterator, ConstValueProxy> {
364 RTCTK_LOCAL inline ConstIterator(MapType::const_iterator&& iter);
371 :
public IteratorImpl<MapType::reverse_iterator, ValueProxy> {
374 RTCTK_LOCAL inline ReverseIterator(MapType::reverse_iterator&& iter);
382 :
public IteratorImpl<MapType::const_reverse_iterator, ConstValueProxy> {
385 RTCTK_LOCAL inline ConstReverseIterator(MapType::const_reverse_iterator&& iter);
394 const std::string&
GetKey()
const;
397 std::shared_ptr<std::string> m_key;
406 const std::string&
GetKey()
const;
409 std::shared_ptr<std::string> m_key;
419 const std::type_info& type_used,
420 const std::type_info& type_expected);
421 const std::string&
GetKey()
const;
427 inline Attributes(
const std::string& key,
428 const std::type_info& type_used,
429 const std::type_info& type_expected);
431 std::reference_wrapper<const std::type_info> m_type_used;
432 std::reference_wrapper<const std::type_info> m_type_expected;
435 std::shared_ptr<Attributes> m_attribs;
449 MetaData(std::initializer_list<std::pair<std::string, std::any>> init_list);
458 inline bool Empty()
const;
464 inline size_t GetSize() const noexcept;
471 inline
bool Contains(const
std::
string& key) const;
497 template <typename T>
498 auto&
Insert(const
std::
string& key, T&& value);
508 template <typename T>
509 auto&
Insert(
std::
string&& key, T&& value);
662 template <
typename T>
665 const T& initial_value,
666 std::optional<std::reference_wrapper<const MetaData>> metadata = std::nullopt,
672 template <
typename T>
675 const T&& initial_value,
676 std::optional<std::reference_wrapper<const MetaData>> metadata = std::nullopt,
717 std::pair<PathList, PathList>& result,
718 bool recurse =
false,
725 std::pair<PathList, PathList>&& result,
726 bool recurse =
false,
729 template <
typename T>
732 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
738 template <
typename T>
741 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
767 template <
typename T>
770 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
776 template <
typename T>
779 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
818 template <
typename T>
825 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
831 template <
typename T>
838 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
874 template <
typename T>
881 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
887 template <
typename T>
894 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
925 template <
typename T>
928 std::optional<std::reference_wrapper<MetaData>> metadata,
931 template <
typename T>
937 std::optional<std::reference_wrapper<MetaData>> metadata,
950 template <
typename Rep,
typename Period>
951 bool WaitFor(
const std::chrono::duration<Rep, Period>& timeout);
953 template <
typename Clk,
typename Duration>
954 bool WaitUntil(
const std::chrono::time_point<Clk, Duration>& timeout);
977 template <
typename T>
993 template <
typename T>
1112 std::pair<PathList, PathList>
1129 template <
typename T>
1146 template <
typename T>
1163 template <
typename T>
1183 template <
typename T>
1204 template <
typename T>
1209 template <
typename... T>
1212 template <
typename... T>
1222 static const std::type_info&
StringToType(
const std::string& arg);
1231 static std::string
TypeToString(
const std::type_info& arg);
Header file for basic type aliases.
The BufferTooSmall is thrown when an API call fails because the provided buffer is not big enough to ...
Definition exceptions.hpp:266
BufferTooSmall(const std::size_t actual, const std::size_t expected)
Construct exception object.
Definition exceptions.cpp:159
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:77
Definition repositoryIf.hpp:95
An object representing one or more asynchronous I/O requests to a repository.
Definition repositoryIf.hpp:634
void DataPointExists(const DataPointPath &path, bool &result, const CallbackType &callback=nullptr) const
Definition repositoryIf.cpp:349
void PartialReadDataPoint(const DataPointPath &path, T &&buffer, size_t first, size_t last, size_t d_first, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr) const =delete
Reading from a datapoint into an rvalue reference is not allowed.
RequestList m_requests
Definition repositoryIf.hpp:922
void WriteDataPoint(const DataPointPath &path, const T &buffer, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Definition repositoryIf.ipp:1538
void GetChildren(const DataPointPath &path, std::pair< PathList, PathList > &&result, bool recurse=false, const CallbackType &callback=nullptr) const =delete
Querying children with an rvalue reference for the result is not allowed.
void PartialWriteDataPoint(const DataPointPath &path, const T &&buffer, size_t first, size_t last, size_t d_first, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)=delete
Writing to a datapoint from an rvalue reference is not allowed.
void DeleteDataPoint(const DataPointPath &path, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:343
virtual ~BatchRequest()=default
void WriteDataPoint(const DataPointPath &path, const T &&buffer, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)=delete
Writing to a datapoint from an rvalue reference is not allowed.
void ReadDataPoint(const DataPointPath &path, T &buffer, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr) const
Definition repositoryIf.ipp:1444
void GetChildren(const DataPointPath &path, std::pair< PathList, PathList > &result, bool recurse=false, const CallbackType &callback=nullptr) const
void PartialReadDataPoint(const DataPointPath &path, T &buffer, size_t first, size_t last, size_t d_first, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr) const
Definition repositoryIf.ipp:1595
void CreateDataPoint(const DataPointPath &path, const T &&initial_value, std::optional< std::reference_wrapper< const MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)=delete
Creation of datapoints from an rvalue reference is not allowed.
void ReadDataPoint(const DataPointPath &path, T &&buffer, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr) const =delete
Reading from a datapoint into an rvalue reference is not allowed.
void ReadMetaData(const DataPointPath &path, MetaData &metadata, const CallbackType &callback=nullptr) const
Definition repositoryIf.cpp:367
void CreateSymlink(const DataPointPath &dp, const DataPointPath &link, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:383
void PartialWriteDataPoint(const DataPointPath &path, const T &buffer, size_t first, size_t last, size_t d_first, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Definition repositoryIf.ipp:1681
void ReadMetaData(const DataPointPath &path, MetaData &&metadata, const CallbackType &callback=nullptr) const =delete
Reading metadata into an rvalue reference is not allowed.
void CreateDataPoint(const DataPointPath &path, const T &initial_value, std::optional< std::reference_wrapper< const MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Definition repositoryIf.ipp:1385
friend RepositoryIf
Definition repositoryIf.hpp:921
void UpdateSymlink(const DataPointPath &dp, const DataPointPath &link, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:392
void WriteMetaData(const DataPointPath &path, const MetaData &metadata, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:375
Definition repositoryIf.hpp:941
std::vector< std::future< void > > ResponseList
Definition repositoryIf.hpp:943
void Wait()
Definition repositoryIf.cpp:645
ResponseList m_responses
Definition repositoryIf.hpp:957
BatchResponse(ResponseList futures)
Definition repositoryIf.cpp:641
bool WaitFor(const std::chrono::duration< Rep, Period > &timeout)
Definition repositoryIf.ipp:1801
bool WaitUntil(const std::chrono::time_point< Clk, Duration > &timeout)
Definition repositoryIf.ipp:1812
BufferTooSmall(const std::size_t actual, const std::size_t expected)
Construct exception object.
Definition exceptions.cpp:159
Definition repositoryIf.hpp:86
Definition repositoryIf.hpp:82
Definition repositoryIf.hpp:78
Definition repositoryIf.hpp:74
const std::vector< Info > & GetInfo() const
Definition repositoryIf.cpp:140
MultipleRequestsFailed(const std::vector< Info > &info)
Definition repositoryIf.cpp:135
Status
Definition repositoryIf.hpp:105
@ Success
Definition repositoryIf.hpp:105
@ Failed
Definition repositoryIf.hpp:105
@ Skipped
Definition repositoryIf.hpp:105
Definition repositoryIf.hpp:99
Definition repositoryIf.hpp:66
Definition repositoryIf.hpp:70
static const std::type_info & StringToType(const std::string &arg)
Converts an RTC datapoint type string to a type_info.
Definition repositoryIf.cpp:881
virtual BatchResponse ProcessRequests(const RequestList &requests)=0
std::optional< T > TryGetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1861
Clock::time_point Timestamp
Definition repositoryIf.hpp:58
void WriteDataPoints(const T &... args)
Definition repositoryIf.ipp:1901
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1843
static std::string TypeToString(const std::type_info &arg)
Converts a type_info to an RTC datapoint type string.
Definition repositoryIf.cpp:889
void ReadDataPoints(T &... args) const
Definition repositoryIf.ipp:1917
size_t GetDataPointSize(const DataPointPath &path) const
Fetches the size of the datapoint's data.
Definition repositoryIf.cpp:702
void CreateDataPoint(const DataPointPath &path)
Creates a new empty datapoint in the repository.
Definition repositoryIf.ipp:1826
std::pair< PathList, PathList > GetChildren(const DataPointPath &path, bool recurse=false) const
Queries the child datapoints and paths for a given parent path.
Definition repositoryIf.cpp:775
static std::any MakeAnyBuffer(const MetaData &metadata)
Helper method to create an std::any buffer compatible with a specific datapoint.
Definition repositoryIf.cpp:897
void SetDataPoint(const DataPointPath &path, const T &value)
Sets a datapoint in the repository.
Definition repositoryIf.ipp:1869
taiclock::TaiClock Clock
Definition repositoryIf.hpp:57
RtcVectorUInt64 GetDataPointShape(const DataPointPath &path) const
Fetches the shape of the datapoint's data.
Definition repositoryIf.cpp:757
std::vector< std::any > RequestList
Definition repositoryIf.hpp:53
void WriteDataPoint(const DataPointPath &path, const T &buffer)
Writes a datapoint to the repository.
Definition repositoryIf.ipp:1894
std::vector< DataPointPath > PathList
Definition repositoryIf.hpp:56
BatchResponse SendRequest(const BatchRequest &request)
Definition repositoryIf.cpp:669
void ReadDataPoint(const DataPointPath &path, T &buffer) const
Reads a datapoint from the repository.
Definition repositoryIf.ipp:1876
std::function< void(const DataPointPath &)> CallbackType
Signature of the callback functions that can be registered with the repository requests.
Definition repositoryIf.hpp:61
const std::type_info & GetDataPointType(const DataPointPath &path) const
Fetches the type of the datapoint.
Definition repositoryIf.cpp:693
void DeleteDataPoint(const DataPointPath &path, bool recurse=false)
Deletes a datapoint.
Definition repositoryIf.cpp:678
virtual ~RepositoryIf()=default
bool DataPointExists(const DataPointPath &path) const
Checks for the existence of a datapoint in the repository.
Definition repositoryIf.cpp:766
RtctkException() noexcept
Definition exceptions.cpp:113
UnsupportedTypeException(const std::string &type)
Definition exceptions.cpp:131
Project-wide configuration header.
#define RTCTK_LOCAL
Helper to hide a class or function from the public symbol table.
Definition config.hpp:60
#define RTCTK_API
Helper to indicate that a class or function must be exported in the public symbol table.
Definition config.hpp:33
Header file for DataPointPath.
Provides macros and utilities for exception handling.
Declaration of the MatrixBuffer template class used in APIs.
Declaration of the MatrixSpan template class used in APIs.
Definition commandReplier.cpp:22
bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:368
constexpr bool operator!=(const MatrixBuffer< T, A > &lhs, const MatrixBuffer< T, A > &rhs) noexcept
Compares two MatrixBuffer objects and returns true if they do not have the same shape or the elements...
Definition matrixBuffer.hpp:117
RtcVector< RtcUInt64 > RtcVectorUInt64
Definition basicTypes.hpp:58
Definition ddsSub.hpp:156
Implementation file for RepositoryIf template methods and related classes.
Definition repositoryIf.hpp:107
Status status
Definition repositoryIf.hpp:108
std::exception_ptr exception
Definition repositoryIf.hpp:109