RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
repositoryIf.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
13#define RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
14
15#include <any>
16#include <chrono>
17#include <exception>
18#include <functional>
19#include <future>
20#include <initializer_list>
21#include <map>
22#include <memory>
23#include <optional>
24#include <type_traits>
25#include <vector>
26
27#include <gsl/span>
28
29#include <taiclock/taiClock.hpp>
30
31#include <rtctk/basicTypes.hpp>
32#include <rtctk/config.hpp>
33
38
40
51protected:
52 using RequestList = std::vector<std::any>;
53
54public:
55 using PathList = std::vector<DataPointPath>;
56 using Clock = taiclock::TaiClock;
57 using Timestamp = Clock::time_point;
58
60 using CallbackType = std::function<void(const DataPointPath&)>;
61
62 RepositoryIf() = default;
63 virtual ~RepositoryIf() = default;
64
65 class RTCTK_API ServiceFailure : public RtctkException {
67 };
68
69 class RTCTK_API UnsupportedType : public UnsupportedTypeException {
71 };
72
73 class RTCTK_API IncompatibleType : public RtctkException {
75 };
76
77 class RTCTK_API DataPointPathNotAbsolute : public RtctkException {
79 };
80
81 class RTCTK_API DataPointDoesNotExist : public RtctkException {
83 };
84
85 class RTCTK_API DataPointAlreadyExists : public RtctkException {
87 };
88
93
94 class RTCTK_API AccessOutOfBounds : public RtctkException {
96 };
97
98 class RTCTK_API OperationNotAllowed : public RtctkException {
100 };
101
103 public:
104 enum class Status : uint8_t { Success, Failed, Skipped };
105
106 struct Info {
108 std::exception_ptr exception;
109 };
110
111 explicit MultipleRequestsFailed(const std::vector<Info>& info);
112 const std::vector<Info>& GetInfo() const;
113
114 private:
115 static RTCTK_LOCAL std::string InfoToString(const std::vector<Info>& info);
116 // Note that using shared_ptr makes the exception's copy constructor noexcept.
117 std::shared_ptr<std::vector<Info>> m_info;
118 };
119
145 class RTCTK_API MetaData final {
146 public:
154 public:
155 ConstValueProxy() = delete;
156 ConstValueProxy(const ConstValueProxy& rhs) = default;
158 ~ConstValueProxy() = default;
159
165 inline bool HasValue() const noexcept;
166
171 const std::type_info& GetValueType() const noexcept;
172
177 inline operator const std::any&() const;
178
186 template <typename T>
187 const T& Cast() const;
188
189 private:
190 friend MetaData;
191
192 RTCTK_LOCAL inline ConstValueProxy(const std::string& key, const std::any& value);
193
195 const std::string& m_key;
196
198 const std::any& m_value;
199 };
200
207 class RTCTK_API ValueProxy final {
208 public:
209 ValueProxy() = delete;
210 ValueProxy(const ValueProxy& rhs) = default;
211 ValueProxy(ValueProxy&& rhs) = default;
212 ~ValueProxy() = default;
213
219 inline bool HasValue() const noexcept;
220
225 const std::type_info& GetValueType() const noexcept;
226
231 inline operator const std::any&() const;
232
240 template <typename T>
241 T& Cast();
242
250 template <typename T>
251 const T& Cast() const;
252
260 ValueProxy& operator=(const ValueProxy& rhs);
261
272 template <typename T>
273 ValueProxy& operator=(T&& rhs);
274
280 inline void Reset() noexcept;
281
282 private:
283 friend MetaData;
284
285 RTCTK_LOCAL inline ValueProxy(const std::string& key, std::any& value);
286
288 const std::string& m_key;
289
291 std::any& m_value;
292 };
293
294 private:
295 using MapType = std::map<std::string, std::any>;
296
304 template <typename MapIterType, typename ProxyType>
305 class RTCTK_LOCAL IteratorImpl {
306 public:
307 using iterator_concept = std::bidirectional_iterator_tag;
308 using iterator_category = std::bidirectional_iterator_tag;
309 using value_type = std::pair<const MapType::key_type&, ProxyType>;
310 using difference_type = MapType::difference_type;
311 using pointer = void;
312 using reference = std::conditional_t<std::is_same_v<ProxyType, ConstValueProxy>,
313 const value_type&,
314 value_type&>;
315
316 // uninitMemberVar: The members will be initialised correctly.
317 // noExplicitConstructor: The constructors should be called implicitly for an iterator.
318 // cppcheck-suppress uninitMemberVar
319 IteratorImpl() = default;
320 // cppcheck-suppress [uninitMemberVar, noExplicitConstructor]
321 IteratorImpl(const IteratorImpl& rhs) = default;
322 // cppcheck-suppress [uninitMemberVar, noExplicitConstructor]
323 IteratorImpl(IteratorImpl&& rhs) noexcept = default;
324 ~IteratorImpl() = default;
325 IteratorImpl& operator=(const IteratorImpl& rhs) = default;
326 IteratorImpl& operator=(IteratorImpl&& rhs) noexcept = default;
327 value_type& operator*();
328 value_type operator*() const;
329 value_type* operator->();
330 const value_type* operator->() const;
331 IteratorImpl& operator++();
332 IteratorImpl operator++(int);
333 IteratorImpl& operator--();
334 IteratorImpl operator--(int);
335 bool operator==(const IteratorImpl& rhs) const;
336 bool operator!=(const IteratorImpl& rhs) const;
337
338 protected:
339 RTCTK_LOCAL explicit IteratorImpl(MapIterType&& iter);
340
341 MapIterType m_iterator; // The underlying map iterator.
342
347 std::optional<value_type> m_pair;
348 };
349
350 public:
354 class RTCTK_API Iterator final : public IteratorImpl<MapType::iterator, ValueProxy> {
355 private:
356 friend MetaData;
357 RTCTK_LOCAL inline Iterator(MapType::iterator&& iter);
358 };
359
364 class RTCTK_API ConstIterator final
365 : public IteratorImpl<MapType::const_iterator, ConstValueProxy> {
366 private:
367 friend MetaData;
368 RTCTK_LOCAL inline ConstIterator(MapType::const_iterator&& iter);
369 };
370
374 class RTCTK_API ReverseIterator final
375 : public IteratorImpl<MapType::reverse_iterator, ValueProxy> {
376 private:
377 friend MetaData;
378 RTCTK_LOCAL inline ReverseIterator(MapType::reverse_iterator&& iter);
379 };
380
385 class RTCTK_API ConstReverseIterator final
386 : public IteratorImpl<MapType::const_reverse_iterator, ConstValueProxy> {
387 private:
388 friend MetaData;
389 RTCTK_LOCAL inline ConstReverseIterator(MapType::const_reverse_iterator&& iter);
390 };
391
396 public:
397 explicit KeyDoesNotExist(const std::string& key);
398 const std::string& GetKey() const;
399
400 private:
401 std::shared_ptr<std::string> m_key;
402 };
403
408 public:
409 explicit KeyAlreadyExists(const std::string& key);
410 const std::string& GetKey() const;
411
412 private:
413 std::shared_ptr<std::string> m_key;
414 };
415
421 public:
422 explicit TypeMismatch(const std::string& key,
423 const std::type_info& type_used,
424 const std::type_info& type_expected);
425 const std::string& GetKey() const;
426 const std::type_info& GetTypeUsed() const;
427 const std::type_info& GetTypeExpected() const;
428
429 private:
430 struct RTCTK_LOCAL Attributes {
431 inline Attributes(const std::string& key,
432 const std::type_info& type_used,
433 const std::type_info& type_expected);
434 std::string m_key;
435 std::reference_wrapper<const std::type_info> m_type_used;
436 std::reference_wrapper<const std::type_info> m_type_expected;
437 };
438 // Note that using shared_ptr makes the exception's copy constructor noexcept.
439 std::shared_ptr<Attributes> m_attribs;
440 };
441
449
450 MetaData() = default;
451 MetaData(const MetaData& rhs) = default;
452 MetaData(MetaData&& rhs) = default;
453 MetaData(std::initializer_list<std::pair<std::string, std::any>> init_list);
454 ~MetaData() = default;
455 MetaData& operator=(const MetaData& rhs) = default;
456 MetaData& operator=(MetaData&& rhs) = default;
457
462 inline bool Empty() const;
463
468 inline size_t GetSize() const noexcept;
469
475 inline bool Contains(const std::string& key) const;
476
483 ValueProxy Insert(const std::string& key);
484
491 ValueProxy Insert(std::string&& key);
492
501 template <typename T>
502 auto& Insert(const std::string& key, T&& value);
503
512 template <typename T>
513 auto& Insert(std::string&& key, T&& value);
514
520 bool Remove(const std::string& key);
521
527 ValueProxy operator[](const std::string& key);
528
534 ValueProxy operator[](std::string&& key);
535
542 ConstValueProxy operator[](const std::string& key) const;
543
548 void Merge(const MetaData& source);
549
559 void Merge(MetaData&& source);
560
561 // The following methods are for STL compatibility and therefore must use lower case.
562 // NOLINTBEGIN(readability-identifier-naming)
566 inline Iterator begin();
567
571 inline ConstIterator begin() const;
572
576 inline ConstIterator cbegin() const noexcept;
577
581 inline Iterator end();
582
586 inline ConstIterator end() const;
587
591 inline ConstIterator cend() const noexcept;
592
596 inline ReverseIterator rbegin();
597
601 inline ConstReverseIterator rbegin() const;
602
606 inline ConstReverseIterator crbegin() const noexcept;
607
611 inline ReverseIterator rend();
612
616 inline ConstReverseIterator rend() const;
617
621 inline ConstReverseIterator crend() const noexcept;
622 // NOLINTEND(readability-identifier-naming)
623
624 private:
625 friend RepositoryIf;
626
627 // We are using an std::map because it is often faster to copy/manipulate for a small number
628 // of keys compared to std::unordered_map.
629 MapType m_metadata;
630 };
631
639 public:
640 virtual ~BatchRequest() = default;
641
642 // Due to Doxygen limitations the multi-line @async_exceptions command cannot have the '*'
643 // character on each line.
668 template <typename T>
669 void CreateDataPoint(
670 const DataPointPath& path,
671 const T& initial_value,
672 std::optional<std::reference_wrapper<const MetaData>> metadata = std::nullopt,
673 const CallbackType& callback = nullptr);
674
678 template <typename T>
680 const DataPointPath& path,
681 const T&& initial_value,
682 std::optional<std::reference_wrapper<const MetaData>> metadata = std::nullopt,
683 const CallbackType& callback = nullptr) = delete;
684
685 void DeleteDataPoint(const DataPointPath& path, const CallbackType& callback = nullptr);
686
687 void DataPointExists(const DataPointPath& path,
688 bool& result,
689 const CallbackType& callback = nullptr) const;
690
722 void GetChildren(const DataPointPath& path,
723 std::pair<PathList, PathList>& result,
724 bool recurse = false,
725 const CallbackType& callback = nullptr) const;
726
730 void GetChildren(const DataPointPath& path,
731 std::pair<PathList, PathList>&& result,
732 bool recurse = false,
733 const CallbackType& callback = nullptr) const = delete;
734
735 template <typename T>
736 void ReadDataPoint(const DataPointPath& path,
737 T& buffer,
738 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
739 const CallbackType& callback = nullptr) const;
740
744 template <typename T>
745 void ReadDataPoint(const DataPointPath& path,
746 T&& buffer,
747 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
748 const CallbackType& callback = nullptr) const = delete;
749
773 template <typename T>
774 void WriteDataPoint(const DataPointPath& path,
775 const T& buffer,
776 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
777 const CallbackType& callback = nullptr);
778
782 template <typename T>
784 const T&& buffer,
785 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
786 const CallbackType& callback = nullptr) = delete;
787
824 template <typename T>
826 const DataPointPath& path,
827 T& buffer,
828 size_t first,
829 size_t last,
830 size_t d_first,
831 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
832 const CallbackType& callback = nullptr) const;
833
837 template <typename T>
839 const DataPointPath& path,
840 T&& buffer,
841 size_t first,
842 size_t last,
843 size_t d_first,
844 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
845 const CallbackType& callback = nullptr) const = delete;
846
880 template <typename T>
882 const DataPointPath& path,
883 const T& buffer,
884 size_t first,
885 size_t last,
886 size_t d_first,
887 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
888 const CallbackType& callback = nullptr);
889
893 template <typename T>
895 const DataPointPath& path,
896 const T&& buffer,
897 size_t first,
898 size_t last,
899 size_t d_first,
900 std::optional<std::reference_wrapper<MetaData>> metadata = std::nullopt,
901 const CallbackType& callback = nullptr) = delete;
902
903 void ReadMetaData(const DataPointPath& path,
904 MetaData& metadata,
905 const CallbackType& callback = nullptr) const;
906
910 void ReadMetaData(const DataPointPath& path,
911 MetaData&& metadata,
912 const CallbackType& callback = nullptr) const = delete;
913
914 void WriteMetaData(const DataPointPath& path,
915 const MetaData& metadata,
916 const CallbackType& callback = nullptr);
917
918 void CreateSymlink(const DataPointPath& dp,
919 const DataPointPath& link,
920 const CallbackType& callback = nullptr);
921
922 void UpdateSymlink(const DataPointPath& dp,
923 const DataPointPath& link,
924 const CallbackType& callback = nullptr);
925
926 protected:
929
930 private:
931 template <typename T>
932 void ReadDataPointImpl(const DataPointPath& path,
933 T& buffer,
934 std::optional<std::reference_wrapper<MetaData>> metadata,
935 const CallbackType& callback) const;
936
937 template <typename T>
938 void PartialReadDataPointImpl(const DataPointPath& path,
939 T& buffer,
940 size_t first,
941 size_t last,
942 size_t d_first,
943 std::optional<std::reference_wrapper<MetaData>> metadata,
944 const CallbackType& callback) const;
945 };
946
948 public:
949 using ResponseList = std::vector<std::future<void>>;
950
951 explicit BatchResponse(ResponseList futures);
952
953 // await all
954 void Wait();
955
956 template <typename Rep, typename Period>
957 bool WaitFor(const std::chrono::duration<Rep, Period>& timeout);
958
959 template <typename Clk, typename Duration>
960 bool WaitUntil(const std::chrono::time_point<Clk, Duration>& timeout);
961
962 protected:
964 };
965
966 BatchResponse SendRequest(const BatchRequest& request);
967 BatchResponse SendRequest(const BatchRequest& request) const;
968
969 // The following are synchronous convenience methods.
970
983 template <typename T>
984 void CreateDataPoint(const DataPointPath& path);
985
999 template <typename T>
1000 void CreateDataPoint(const DataPointPath& path, const T& initial_value);
1001
1002 void CreateDataPoint(const DataPointPath& path, const char* initial_value);
1003
1013 void DeleteDataPoint(const DataPointPath& path, bool recurse = false);
1014
1028 const std::type_info& GetDataPointType(const DataPointPath& path) const;
1029
1051 size_t GetDataPointSize(const DataPointPath& path) const;
1052
1078
1088 bool DataPointExists(const DataPointPath& path) const;
1089
1118 std::pair<PathList, PathList>
1119 GetChildren(const DataPointPath& path, bool recurse = false) const;
1120
1135 template <typename T>
1136 T GetDataPoint(const DataPointPath& path) const;
1137
1152 template <typename T>
1153 std::optional<T> TryGetDataPoint(const DataPointPath& path) const;
1154
1169 template <typename T>
1170 void SetDataPoint(const DataPointPath& path, const T& value);
1171
1172 void SetDataPoint(const DataPointPath& path, const char* value);
1173
1189 template <typename T>
1190 void ReadDataPoint(const DataPointPath& path, T& buffer) const;
1191
1210 template <typename T>
1211 void WriteDataPoint(const DataPointPath& path, const T& buffer);
1212
1213 void WriteDataPoint(const DataPointPath& path, const char* buffer);
1214
1215 template <typename... T>
1216 void WriteDataPoints(const T&... args);
1217
1218 template <typename... T>
1219 void ReadDataPoints(T&... args) const;
1220
1228 static const std::type_info& StringToType(const std::string& arg);
1229
1237 static std::string TypeToString(const std::type_info& arg);
1238
1248 static std::any MakeAnyBuffer(const MetaData& metadata);
1249
1250protected:
1251 virtual BatchResponse ProcessRequests(const RequestList& requests) = 0;
1252};
1253
1254} // namespace rtctk::componentFramework
1255
1257
1258#endif // RTCTK_COMPONENTFRAMEWORK_REPOSITORYIF_HPP
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:273
BufferTooSmall(const std::size_t actual, const std::size_t expected)
Construct exception object.
Definition exceptions.cpp:158
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:76
An object representing one or more asynchronous I/O requests to a repository.
Definition repositoryIf.hpp:638
void DataPointExists(const DataPointPath &path, bool &result, const CallbackType &callback=nullptr) const
Definition repositoryIf.cpp:350
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:928
void WriteDataPoint(const DataPointPath &path, const T &buffer, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Add request to write a datapoint.
Definition repositoryIf.ipp:1557
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:344
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:1459
void GetChildren(const DataPointPath &path, std::pair< PathList, PathList > &result, bool recurse=false, const CallbackType &callback=nullptr) const
Add request to query the child datapoints and paths for a given parent path.
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
Add request to partially read a datapoint.
Definition repositoryIf.ipp:1614
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:372
void CreateSymlink(const DataPointPath &dp, const DataPointPath &link, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:388
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)
Add request to partially write a datapoint.
Definition repositoryIf.ipp:1701
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)
Add a request to create a new datapoint.
Definition repositoryIf.ipp:1400
friend RepositoryIf
Definition repositoryIf.hpp:927
void UpdateSymlink(const DataPointPath &dp, const DataPointPath &link, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:397
void WriteMetaData(const DataPointPath &path, const MetaData &metadata, const CallbackType &callback=nullptr)
Definition repositoryIf.cpp:380
std::vector< std::future< void > > ResponseList
Definition repositoryIf.hpp:949
void Wait()
Definition repositoryIf.cpp:650
ResponseList m_responses
Definition repositoryIf.hpp:963
BatchResponse(ResponseList futures)
Definition repositoryIf.cpp:646
bool WaitFor(const std::chrono::duration< Rep, Period > &timeout)
Definition repositoryIf.ipp:1822
bool WaitUntil(const std::chrono::time_point< Clk, Duration > &timeout)
Definition repositoryIf.ipp:1833
BufferTooSmall(const std::size_t actual, const std::size_t expected)
Construct exception object.
Definition exceptions.cpp:158
Constant version of the bidirectional forward iterator returned by the cbegin/cend methods.
Definition repositoryIf.hpp:365
Constant version of the bidirectional reverse iterator returned by the crbegin/crend methods.
Definition repositoryIf.hpp:386
A read-only interface class to an underlying metadata value.
Definition repositoryIf.hpp:153
bool HasValue() const noexcept
Check if a value was assigned to the metadata value.
Definition repositoryIf.ipp:1087
const std::type_info & GetValueType() const noexcept
Get the type of the metadata value stored.
Definition repositoryIf.cpp:211
const T & Cast() const
Cast the value to the given C++ type.
Definition repositoryIf.ipp:1096
Bidirectional forward iterator returned by the begin/end methods.
Definition repositoryIf.hpp:354
KeyAlreadyExists(const std::string &key)
Definition repositoryIf.cpp:179
const std::string & GetKey() const
Definition repositoryIf.cpp:184
const std::string & GetKey() const
Definition repositoryIf.cpp:175
KeyDoesNotExist(const std::string &key)
Definition repositoryIf.cpp:170
Bidirectional reverse iterator returned by the rbegin/rend methods.
Definition repositoryIf.hpp:375
TypeMismatch(const std::string &key, const std::type_info &type_used, const std::type_info &type_expected)
Definition repositoryIf.cpp:188
const std::type_info & GetTypeExpected() const
Definition repositoryIf.cpp:207
const std::type_info & GetTypeUsed() const
Definition repositoryIf.cpp:203
const std::string & GetKey() const
Definition repositoryIf.cpp:199
Exception indicating that an unsupported type was used for the metadata value.
Definition repositoryIf.hpp:445
UnsupportedTypeException(const std::string &type)
Definition exceptions.cpp:130
Interface class to an underlying metadata value.
Definition repositoryIf.hpp:207
ValueProxy & operator=(const ValueProxy &rhs)
Assign a new value to this object from an existing metadata value.
Definition repositoryIf.cpp:228
bool HasValue() const noexcept
Check if a value was assigned to the metadata value.
Definition repositoryIf.ipp:1111
void Reset() noexcept
Delete the value assigned to this metadata value.
Definition repositoryIf.ipp:1182
T & Cast()
Cast the value to the given C++ type.
Definition repositoryIf.ipp:1120
const std::type_info & GetValueType() const noexcept
Get the type of the metadata value stored.
Definition repositoryIf.cpp:219
Class for passing/receiving metadata to/from the repository.
Definition repositoryIf.hpp:145
ConstIterator cbegin() const noexcept
Return a read-only forward iterator to the beginning of the metadata entries.
Definition repositoryIf.ipp:1357
MetaData & operator=(const MetaData &rhs)=default
ValueProxy Insert(const std::string &key)
Add a new metadata key.
Definition repositoryIf.cpp:244
MetaData & operator=(MetaData &&rhs)=default
size_t GetSize() const noexcept
Get the number of entries in the metadata.
Definition repositoryIf.ipp:1302
Iterator end()
Return a forward iterator to the end of the metadata entries.
Definition repositoryIf.ipp:1361
ReverseIterator rbegin()
Return a reverse iterator to the beginning of the metadata entries.
Definition repositoryIf.ipp:1373
Iterator begin()
Return a forward iterator to the beginning of the metadata entries.
Definition repositoryIf.ipp:1349
ConstReverseIterator crend() const noexcept
Return a read-only reverse iterator to the end of the metadata entries.
Definition repositoryIf.ipp:1394
bool Remove(const std::string &key)
Remove a metadata key.
Definition repositoryIf.cpp:263
ConstReverseIterator crbegin() const noexcept
Return a read-only reverse iterator to the beginning of the metadata entries.
Definition repositoryIf.ipp:1382
bool Empty() const
Check if the metadata contains any values.
Definition repositoryIf.ipp:1298
ReverseIterator rend()
Return a reverse iterator to the end of the metadata entries.
Definition repositoryIf.ipp:1386
bool Contains(const std::string &key) const
Check if the metadata contains a specific key.
Definition repositoryIf.ipp:1306
ConstIterator cend() const noexcept
Return a read-only forward iterator to the end of the metadata entries.
Definition repositoryIf.ipp:1369
void Merge(const MetaData &source)
Merge entries from the source metadata object into this one.
Definition repositoryIf.cpp:295
const std::vector< Info > & GetInfo() const
Definition repositoryIf.cpp:139
MultipleRequestsFailed(const std::vector< Info > &info)
Definition repositoryIf.cpp:134
static const std::type_info & StringToType(const std::string &arg)
Converts an RTC datapoint type string to a type_info.
Definition repositoryIf.cpp:886
virtual BatchResponse ProcessRequests(const RequestList &requests)=0
std::optional< T > TryGetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1882
Clock::time_point Timestamp
Definition repositoryIf.hpp:57
void WriteDataPoints(const T &... args)
Definition repositoryIf.ipp:1922
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1864
static std::string TypeToString(const std::type_info &arg)
Converts a type_info to an RTC datapoint type string.
Definition repositoryIf.cpp:894
void ReadDataPoints(T &... args) const
Definition repositoryIf.ipp:1938
size_t GetDataPointSize(const DataPointPath &path) const
Fetches the size of the datapoint's data.
Definition repositoryIf.cpp:707
void CreateDataPoint(const DataPointPath &path)
Creates a new empty datapoint in the repository.
Definition repositoryIf.ipp:1847
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:780
static std::any MakeAnyBuffer(const MetaData &metadata)
Helper method to create an std::any buffer compatible with a specific datapoint.
Definition repositoryIf.cpp:902
void SetDataPoint(const DataPointPath &path, const T &value)
Sets a datapoint in the repository.
Definition repositoryIf.ipp:1890
taiclock::TaiClock Clock
Definition repositoryIf.hpp:56
RtcVectorUInt64 GetDataPointShape(const DataPointPath &path) const
Fetches the shape of the datapoint's data.
Definition repositoryIf.cpp:762
std::vector< std::any > RequestList
Definition repositoryIf.hpp:52
void WriteDataPoint(const DataPointPath &path, const T &buffer)
Writes a datapoint to the repository.
Definition repositoryIf.ipp:1915
std::vector< DataPointPath > PathList
Definition repositoryIf.hpp:55
BatchResponse SendRequest(const BatchRequest &request)
Definition repositoryIf.cpp:674
void ReadDataPoint(const DataPointPath &path, T &buffer) const
Reads a datapoint from the repository.
Definition repositoryIf.ipp:1897
std::function< void(const DataPointPath &)> CallbackType
Signature of the callback functions that can be registered with the repository requests.
Definition repositoryIf.hpp:60
const std::type_info & GetDataPointType(const DataPointPath &path) const
Fetches the type of the datapoint.
Definition repositoryIf.cpp:698
void DeleteDataPoint(const DataPointPath &path, bool recurse=false)
Deletes a datapoint.
Definition repositoryIf.cpp:683
bool DataPointExists(const DataPointPath &path) const
Checks for the existence of a datapoint in the repository.
Definition repositoryIf.cpp:771
RtctkException() noexcept
Definition exceptions.cpp:112
UnsupportedTypeException(const std::string &type)
Definition exceptions.cpp:130
Project-wide configuration header.
#define RTCTK_LOCAL
Helper to hide a class or function from the public symbol table.
Definition config.hpp:59
#define RTCTK_API
Helper to indicate that a class or function must be exported in the public symbol table.
Definition config.hpp:32
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:21
bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:367
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:116
RtcVector< RtcUInt64 > RtcVectorUInt64
Definition basicTypes.hpp:57
Definition ddsSub.hpp:155
Implementation file for RepositoryIf template methods and related classes.
std::exception_ptr exception
Definition repositoryIf.hpp:108