RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
repositoryIf.ipp
Go to the documentation of this file.
1
11
12// Note this is a template implementation file and should not be included directly.
13// The typical header protection macro is not added to avoid it showing up in Doxygen API
14// documentation.
15#pragma once
16
18
19#include <fmt/format.h>
20
21#include <boost/container/vector.hpp>
22#include <boost/core/demangle.hpp>
23
24#include <cassert>
25#include <exception>
26#include <memory>
27#include <unordered_set>
28#include <utility>
29
31
32// NOLINTBEGIN(readability-identifier-naming)
34// NOLINTEND(readability-identifier-naming)
35
36namespace detail {
37
38template <typename T>
46
51
57
60 bool recurse;
61 std::pair<RepositoryIf::PathList, RepositoryIf::PathList>& result;
63};
64
65template <typename T>
67 using ElementType = T;
68 using PrepareFunctionType = std::function<gsl::span<T>(const RepositoryIf::MetaData&)>;
70 // The following function is given by the caller to prepare the buffer to be filled.
71 // It can use the metadata available for the datapoint to resize the buffer object for
72 // example. This is called by the adapter just before filling the returned span with
73 // deserialised data.
75 std::optional<std::reference_wrapper<RepositoryIf::MetaData>> metadata;
77};
78
79template <typename T>
81 using ElementType = T;
83 gsl::span<const T> data;
85 std::optional<std::reference_wrapper<RepositoryIf::MetaData>> output_metadata;
87};
88
89template <typename T>
91 using ElementType = T;
93 gsl::span<T> data;
95 std::optional<std::reference_wrapper<RepositoryIf::MetaData>> output_metadata;
96 size_t offset;
98};
99
100template <typename T>
102 using ElementType = T;
104 gsl::span<const T> data;
106 size_t offset;
107 std::optional<std::reference_wrapper<RepositoryIf::MetaData>> output_metadata;
109};
110
116
122
128
134
136 RtcUInt64 nelements = 1;
137 for (auto dimention : shape) {
138 // cppcheck-suppress useStlAlgorithm
139 nelements *= dimention;
140 }
141 return nelements;
142}
143
144inline void EnsureAbsolutePath(const DataPointPath& path) {
145 if (not path.IsAbsolutePath()) {
146 throw CII_MAKE_EXCEPTION(RepositoryIf::DataPointPathNotAbsolute,
147 fmt::format("DataPointPath is not absolute: '{}'.", path));
148 }
149}
150
151template <typename T>
154 using BufferType = T;
155
157 using ElementType = std::remove_cv_t<T>;
158
160 using DataPointType = T;
161
163 static const bool USES_TEMP_BUFFER = false;
164
166 using TempBufferType = void;
167
175 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
176 static_assert(
177 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
178 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
179 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
180 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
181 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
182 std::is_same_v<ElementType, RtcDouble>,
183 "The scalar type is not supported.");
184 return {};
185 }
186
192 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
193 return {&buffer, 1};
194 }
195
201 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
202 return {&buffer, 1};
203 }
204
218 // cppcheck-suppress constParameterReference
219 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
220 if (shape.size() == 0) {
221 // The shape is for a scalar, so confirm the buffer size is correct.
222 return true;
223 } else {
224 return false;
225 }
226 }
227
241 static void CopyToTempBuffer(const BufferType& buffer,
242 std::shared_ptr<TempBufferType>& temp_buffer,
243 size_t offset,
244 size_t count) = delete;
245
259 static void CopyFromTempBuffer(BufferType& buffer,
260 const std::shared_ptr<TempBufferType>& temp_buffer,
261 size_t offset,
262 size_t count) = delete;
263};
264
265template <>
266struct UserTypeHandler<std::string> {
267 using BufferType = std::string;
268 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
270 static const bool USES_TEMP_BUFFER = false;
271 using TempBufferType = void;
272
273 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
274 return {buffer.size()};
275 }
276
277 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
278 return {buffer};
279 }
280
281 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
282 return {buffer};
283 }
284
285 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
286 if (shape.size() == 1) {
287 buffer.resize(shape[0]);
288 } else {
289 buffer.resize(GetNumOfElements(shape));
290 }
291 return true;
292 }
293};
294
295template <>
296struct UserTypeHandler<std::string_view> {
297 using BufferType = std::string_view;
298 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
300 static const bool USES_TEMP_BUFFER = false;
301 using TempBufferType = void;
302
303 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
304 return {buffer.size()};
305 }
306
310 static gsl::span<ElementType> MakeSpan(BufferType& buffer) = delete;
311
312 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
313 return {buffer.data(), buffer.size()};
314 }
315
316 // cppcheck-suppress constParameterReference
317 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
318 if (shape.size() == 1 and shape[0] == buffer.size()) {
319 // Cannot resize, but the shape and size is correct, so return true.
320 return true;
321 } else {
322 return false;
323 }
324 }
325};
326
327template <typename T, typename A>
328struct UserTypeHandler<std::vector<T, A>> {
329 using BufferType = std::vector<T, A>;
330 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
332 static const bool USES_TEMP_BUFFER = false;
333 using TempBufferType = void;
334
335 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
336 static_assert(
337 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
338 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
339 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
340 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
341 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
342 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString> or
343 std::is_same_v<ElementType, std::byte>,
344 "The vector type is not supported.");
345 return {buffer.size()};
346 }
347
348 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
349 return {buffer};
350 }
351
352 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
353 return {buffer};
354 }
355
356 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
357 if (shape.size() == 1) {
358 buffer.resize(shape[0]);
359 } else {
360 buffer.resize(GetNumOfElements(shape));
361 }
362 return true;
363 }
364};
365
366template <typename A>
367struct UserTypeHandler<std::vector<bool, A>> {
368 using BufferType = std::vector<bool, A>;
369 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
371 static const bool USES_TEMP_BUFFER = true;
372 using TempBufferType = boost::container::vector<bool>;
373
374 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
375 return {buffer.size()};
376 }
377
381 static gsl::span<ElementType> MakeSpan(BufferType& buffer) = delete;
382
386 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) = delete;
387
388 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
389 if (shape.size() == 1) {
390 buffer.resize(shape[0]);
391 } else {
392 buffer.resize(GetNumOfElements(shape));
393 }
394 return true;
395 }
396
397 static void CopyToTempBuffer(const BufferType& buffer,
398 std::shared_ptr<TempBufferType>& temp_buffer,
399 size_t offset,
400 size_t count) {
401 // cppcheck-suppress incorrectStringBooleanError
402 assert((buffer.size() >= offset + count) && ("The input buffer is too small."));
403 // cppcheck-suppress incorrectStringBooleanError
404 assert((temp_buffer->size() >= count) && ("The temporary buffer is too small."));
405 std::copy(buffer.begin() + offset, buffer.begin() + offset + count, temp_buffer->begin());
406 }
407
408 static void CopyFromTempBuffer(BufferType& buffer,
409 const std::shared_ptr<TempBufferType>& temp_buffer,
410 size_t offset,
411 size_t count) {
412 // cppcheck-suppress incorrectStringBooleanError
413 assert((buffer.size() >= offset + count) && ("The output buffer is too small."));
414 // cppcheck-suppress incorrectStringBooleanError
415 assert((temp_buffer->size() >= count) && ("The temporary buffer is too small."));
416 std::copy(temp_buffer->begin(), temp_buffer->begin() + count, buffer.begin() + offset);
417 }
418};
419
420template <typename T, typename A>
421struct UserTypeHandler<boost::container::vector<T, A>> {
422 using BufferType = boost::container::vector<T, A>;
423 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
425 static const bool USES_TEMP_BUFFER = false;
426 using TempBufferType = void;
427
428 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
429 static_assert(
430 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
431 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
432 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
433 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
434 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
435 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString> or
436 std::is_same_v<ElementType, std::byte>,
437 "The vector type is not supported.");
438 return {buffer.size()};
439 }
440
441 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
442 return {buffer};
443 }
444
445 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
446 return {buffer};
447 }
448
449 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
450 if (shape.size() == 1) {
451 buffer.resize(shape[0]);
452 } else {
453 buffer.resize(GetNumOfElements(shape));
454 }
455 return true;
456 }
457};
458
459template <typename T, decltype(gsl::dynamic_extent) N>
460struct UserTypeHandler<gsl::span<T, N>> {
461 using BufferType = gsl::span<T, N>;
462 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
464 static const bool USES_TEMP_BUFFER = false;
465 using TempBufferType = void;
466
467 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
468 static_assert(
469 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
470 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
471 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
472 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
473 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
474 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString> or
475 std::is_same_v<ElementType, std::byte>,
476 "The vector type is not supported.");
477 return {buffer.size()};
478 }
479
480 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
481 return {buffer};
482 }
483
484 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
485 return {buffer};
486 }
487
488 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
489 if (shape.size() == 1 and shape[0] == buffer.size()) {
490 // Cannot resize, but the shape and size is correct, so return true.
491 return true;
492 } else {
493 return false;
494 }
495 }
496};
497
498template <decltype(gsl::dynamic_extent) N>
499struct UserTypeHandler<gsl::span<char, N>> {
500 using BufferType = gsl::span<char, N>;
501 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
503 static const bool USES_TEMP_BUFFER = false;
504 using TempBufferType = void;
505
506 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
507 return {buffer.size()};
508 }
509
510 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
511 return {buffer};
512 }
513
514 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
515 return {buffer};
516 }
517
518 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
519 return false;
520 }
521};
522
523template <decltype(gsl::dynamic_extent) N>
524struct UserTypeHandler<gsl::span<const char, N>> {
525 using BufferType = gsl::span<const char, N>;
526 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
528 static const bool USES_TEMP_BUFFER = false;
529 using TempBufferType = void;
530
531 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
532 return {buffer.size()};
533 }
534
535 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
536 return {buffer};
537 }
538
539 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
540 return {buffer};
541 }
542
543 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
544 return false;
545 }
546};
547
548template <typename T, typename A>
551 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
553 static const bool USES_TEMP_BUFFER = false;
554 using TempBufferType = void;
555
556 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
557 static_assert(
558 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
559 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
560 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
561 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
562 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
563 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString>,
564 "The matrix type is not supported.");
565 return {buffer.GetNrows(), buffer.GetNcols()};
566 }
567
568 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
569 return {buffer.data(), GetNumOfElements(GetShape(buffer))};
570 }
571
572 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
573 return {buffer.data(), buffer.GetNrows() * buffer.GetNcols()};
574 }
575
576 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
577 if (shape.size() == 2) {
578 buffer.resize(shape[0], shape[1]);
579 } else {
580 buffer.resize(1, GetNumOfElements(shape));
581 }
582 return true;
583 }
584};
585
586template <typename A>
589 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
591 static const bool USES_TEMP_BUFFER = true;
592 using TempBufferType = boost::container::vector<bool>;
593
594 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
595 return {buffer.GetNrows(), buffer.GetNcols()};
596 }
597
601 static gsl::span<ElementType> MakeSpan(BufferType& buffer) = delete;
602
606 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) = delete;
607
608 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
609 if (shape.size() == 2) {
610 buffer.resize(shape[0], shape[1]);
611 } else {
612 buffer.resize(1, GetNumOfElements(shape));
613 }
614 return true;
615 }
616
617 static void CopyToTempBuffer(const BufferType& buffer,
618 std::shared_ptr<TempBufferType>& temp_buffer,
619 size_t offset,
620 size_t count) {
621 // cppcheck-suppress incorrectStringBooleanError
622 assert((buffer.size() >= offset + count) && ("The input buffer is too small."));
623 // cppcheck-suppress incorrectStringBooleanError
624 assert((temp_buffer->size() >= count) && ("The temporary buffer is too small."));
625 std::copy(buffer.begin() + offset, buffer.begin() + offset + count, temp_buffer->begin());
626 }
627
628 static void CopyFromTempBuffer(BufferType& buffer,
629 const std::shared_ptr<TempBufferType>& temp_buffer,
630 size_t offset,
631 size_t count) {
632 // cppcheck-suppress incorrectStringBooleanError
633 assert((buffer.size() >= offset + count) && ("The output buffer is too small."));
634 // cppcheck-suppress incorrectStringBooleanError
635 assert((temp_buffer->size() >= count) && ("The temporary buffer is too small."));
636 std::copy(temp_buffer->begin(), temp_buffer->begin() + count, buffer.begin() + offset);
637 }
638};
639
640template <typename T>
643 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
645 static const bool USES_TEMP_BUFFER = false;
646 using TempBufferType = void;
647
648 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
649 static_assert(
650 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
651 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
652 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
653 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
654 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
655 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString>,
656 "The matrix type is not supported.");
657 return {buffer.GetNrows(), buffer.GetNcols()};
658 }
659
660 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
661 return {buffer.data(), GetNumOfElements(GetShape(buffer))};
662 }
663
664 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
665 return {buffer.data(), buffer.GetNrows() * buffer.GetNcols()};
666 }
667
668 static bool ResizeBuffer(BufferType& buffer, const RtcVectorUInt64& shape) {
669 if (shape.size() == 2 and shape[0] == buffer.GetNrows() and shape[1] == buffer.GetNcols()) {
670 // Cannot resize, but the shape and size is correct, so return true.
671 return true;
672 } else {
673 return false;
674 }
675 }
676};
677
678template <typename T, std::size_t N>
679struct UserTypeHandler<std::array<T, N>> {
680 using BufferType = std::array<T, N>;
681 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
683 static const bool USES_TEMP_BUFFER = false;
684 using TempBufferType = void;
685
686 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
687 static_assert(
688 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
689 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
690 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
691 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
692 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
693 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString> or
694 std::is_same_v<ElementType, std::byte>,
695 "The array type is not supported.");
696 return {buffer.size()};
697 }
698
699 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
700 return {buffer};
701 }
702
703 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
704 return {buffer};
705 }
706
707 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
708 if (shape.size() == 1 and shape[0] == buffer.size()) {
709 // Cannot resize, but the shape and size is correct, so return true.
710 return true;
711 } else {
712 return false;
713 }
714 }
715};
716
717template <std::size_t N>
718struct UserTypeHandler<std::array<char, N>> {
719 using BufferType = std::array<char, N>;
720 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
722 static const bool USES_TEMP_BUFFER = false;
723 using TempBufferType = void;
724
725 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
726 return {buffer.size()};
727 }
728
729 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
730 return {buffer};
731 }
732
733 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
734 return {buffer};
735 }
736
737 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
738 if (shape.size() == 1 and shape[0] == buffer.size()) {
739 // Cannot resize, but the shape and size is correct, so return true.
740 return true;
741 } else {
742 return false;
743 }
744 }
745};
746
747template <typename T, std::size_t N, std::size_t M>
748struct UserTypeHandler<std::array<std::array<T, M>, N>> {
749 using BufferType = std::array<std::array<T, M>, N>;
750 using ElementType = std::remove_cv_t<T>;
752 static const bool USES_TEMP_BUFFER = false;
753 using TempBufferType = void;
754
755 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
756 static_assert(
757 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
758 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
759 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
760 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
761 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
762 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString>,
763 "The array type is not supported.");
764 return {N, M};
765 }
766
767 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
768 static_assert(sizeof(BufferType) == sizeof(ElementType) * N * M);
769 ElementType* begin = &buffer[0][0];
770 return {begin, N * M};
771 }
772
773 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
774 static_assert(sizeof(BufferType) == sizeof(ElementType) * N * M);
775 const ElementType* begin = &buffer[0][0];
776 return {begin, N * M};
777 }
778
779 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
780 if (shape.size() == 2 and shape[0] == N and shape[1] == M) {
781 // Cannot resize, but the shape and size is correct, so return true.
782 return true;
783 } else {
784 return false;
785 }
786 }
787};
788
789// We provide C-style array support in the API on purpose.
790// NOLINTBEGIN(modernize-avoid-c-arrays)
791
795template <typename T, std::size_t N>
796struct UserTypeHandler<T[N]> {
797 using BufferType = T[N];
798 using ElementType = std::remove_cv_t<T>;
800 static const bool USES_TEMP_BUFFER = false;
801 using TempBufferType = void;
802
803 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
804 static_assert(
805 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
806 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
807 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
808 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
809 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
810 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString> or
811 std::is_same_v<ElementType, std::byte>,
812 "The array type is not supported.");
813 return {N};
814 }
815
816 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
817 return {buffer};
818 }
819
820 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
821 return {buffer};
822 }
823
824 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
825 if (shape.size() == 1 and shape[0] == N) {
826 // Cannot resize, but the shape and size is correct, so return true.
827 return true;
828 } else {
829 return false;
830 }
831 }
832};
833
834template <std::size_t N>
835struct UserTypeHandler<char[N]> {
836 using BufferType = char[N];
837 using ElementType = char;
839 static const bool USES_TEMP_BUFFER = false;
840 using TempBufferType = void;
841
842 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
843 return {N};
844 }
845
846 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
847 return {buffer};
848 }
849
850 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
851 return {buffer};
852 }
853
854 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
855 if (shape.size() == 1 and shape[0] == N) {
856 // Cannot resize, but the shape and size is correct, so return true.
857 return true;
858 } else {
859 return false;
860 }
861 }
862};
863
867template <typename T, std::size_t N, std::size_t M>
868struct UserTypeHandler<T[N][M]> {
869 using BufferType = T[N][M];
870 using ElementType = std::remove_cv_t<T>;
872 static const bool USES_TEMP_BUFFER = false;
873 using TempBufferType = void;
874
875 static RtcVectorUInt64 GetShape(const BufferType& buffer) {
876 static_assert(
877 std::is_same_v<ElementType, RtcBool> or std::is_same_v<ElementType, RtcInt8> or
878 std::is_same_v<ElementType, RtcInt16> or std::is_same_v<ElementType, RtcInt32> or
879 std::is_same_v<ElementType, RtcInt64> or std::is_same_v<ElementType, RtcUInt8> or
880 std::is_same_v<ElementType, RtcUInt16> or std::is_same_v<ElementType, RtcUInt32> or
881 std::is_same_v<ElementType, RtcUInt64> or std::is_same_v<ElementType, RtcFloat> or
882 std::is_same_v<ElementType, RtcDouble> or std::is_same_v<ElementType, RtcString>,
883 "The array type is not supported.");
884 return {N, M};
885 }
886
887 static gsl::span<ElementType> MakeSpan(BufferType& buffer) {
888 static_assert(sizeof(BufferType) == sizeof(ElementType) * N * M);
889 return {&buffer[0][0], N * M};
890 }
891
892 static gsl::span<const ElementType> MakeSpan(const BufferType& buffer) {
893 static_assert(sizeof(BufferType) == sizeof(ElementType) * N * M);
894 return {&buffer[0][0], N * M};
895 }
896
897 static bool ResizeBuffer([[maybe_unused]] BufferType& buffer, const RtcVectorUInt64& shape) {
898 if (shape.size() == 2 and shape[0] == N and shape[1] == M) {
899 // Cannot resize, but the shape and size is correct, so return true.
900 return true;
901 } else {
902 return false;
903 }
904 }
905};
906
907// NOLINTEND(modernize-avoid-c-arrays)
908
909} // namespace detail
910
911namespace {
912
919inline bool TypeIsAllowedForValue(const std::type_info& type) {
920 static const std::unordered_set<std::type_index> valid_types = {
921 // Void values are acceptable and represent null values, e.g. equivalent to Python None.
922 std::type_index(typeid(void)),
923 std::type_index(typeid(RtcBool)),
924 std::type_index(typeid(RtcInt8)),
925 std::type_index(typeid(RtcInt16)),
926 std::type_index(typeid(RtcInt32)),
927 std::type_index(typeid(RtcInt64)),
928 std::type_index(typeid(RtcUInt8)),
929 std::type_index(typeid(RtcUInt16)),
930 std::type_index(typeid(RtcUInt32)),
931 std::type_index(typeid(RtcUInt64)),
932 std::type_index(typeid(RtcFloat)),
933 std::type_index(typeid(RtcDouble)),
934 std::type_index(typeid(RtcString))};
935 return valid_types.contains(std::type_index(type));
936}
937
945inline const std::type_info& GetMetaDataReservedKeyType(const std::string& key) {
946 static const std::map<std::string, const std::type_info&> reserved_key_types = {
947 {"type", typeid(std::reference_wrapper<const std::type_info>)},
948 {"shape", typeid(RtcVectorUInt64)},
949 {"timestamp", typeid(RepositoryIf::Timestamp)},
950 {"sequence_id", typeid(RtcUInt64)},
951 {"symlink_target", typeid(DataPointPath)},
952 {"symlinks", typeid(std::set<DataPointPath>)},
953 };
954 auto iter = reserved_key_types.find(key);
955 if (iter != reserved_key_types.end()) {
956 return iter->second;
957 } else {
958 return typeid(void);
959 }
960}
961
971inline void CheckMetaDataTypeForReservedKeys(const std::string& key, const std::type_info& type) {
972 const std::type_info& type_expected = GetMetaDataReservedKeyType(key);
973 if (type_expected == typeid(void)) {
974 throw CII_MAKE_EXCEPTION(RepositoryIf::MetaData::UnsupportedType, type);
975 }
976 if (type != typeid(void) and type_expected != type) {
977 throw CII_MAKE_EXCEPTION(RepositoryIf::MetaData::TypeMismatch, key, type, type_expected);
978 }
979}
980
989inline void CheckMetaDataValueType(const std::string& key, const std::type_info& type) {
990 const std::type_info& type_expected = GetMetaDataReservedKeyType(key);
991 if (type_expected != typeid(void)) {
992 // Dealing with a reserved key. Therefore check that the type being assigned is the one that
993 // is expected for such a key. Note that "type" being effectively a null value is OK.
994 if (type != typeid(void) and type_expected != type) {
995 throw CII_MAKE_EXCEPTION(
996 RepositoryIf::MetaData::TypeMismatch, key, type, type_expected);
997 }
998 } else {
999 // Dealing with a general unreserved user key. Therefore check that the type being assigned
1000 // is from the list of allowed types.
1001 if (not TypeIsAllowedForValue(type)) {
1002 throw CII_MAKE_EXCEPTION(RepositoryIf::MetaData::UnsupportedType, type);
1003 }
1004 }
1005}
1006
1018template <typename T>
1019void CheckMetaDataValueType(const std::string& key) {
1020 static_assert(
1021 std::is_same_v<T, RtcBool> or std::is_same_v<T, RtcInt8> or std::is_same_v<T, RtcInt16> or
1022 std::is_same_v<T, RtcInt32> or std::is_same_v<T, RtcInt64> or
1023 std::is_same_v<T, RtcUInt8> or std::is_same_v<T, RtcUInt16> or
1024 std::is_same_v<T, RtcUInt32> or std::is_same_v<T, RtcUInt64> or
1025 std::is_same_v<T, RtcFloat> or std::is_same_v<T, RtcDouble> or
1026 std::is_same_v<T, RtcString> or std::is_same_v<T, RtcBinary> or
1027 std::is_same_v<T, RtcVectorUInt64> or std::is_same_v<T, const std::type_info&> or
1028 std::is_same_v<T, RepositoryIf::Timestamp> or std::is_same_v<T, DataPointPath> or
1029 std::is_same_v<T, std::set<DataPointPath>>,
1030 "The type is not supported for MetaData values.");
1031 if constexpr (std::is_same_v<T, const std::type_info&>) {
1032 // Note (1): type_info can only be applicable to the reserved "type" metadata key.
1033 // Therefore we can call CheckMetaDataTypeForReservedKeys directly.
1034 CheckMetaDataTypeForReservedKeys(key, typeid(std::reference_wrapper<const std::type_info>));
1035 } else {
1036 CheckMetaDataValueType(key, typeid(T));
1037 }
1038}
1039
1047inline bool MetaDataKeyValueIsValid(const std::string& key, const std::any& value) {
1048 const std::type_info& type_expected = GetMetaDataReservedKeyType(key);
1049 if (type_expected != typeid(void)) {
1050 // Dealing with a reserved key. Therefore just check that the type of the value is the same
1051 // as the one expected.
1052 if (value.type() != typeid(void)) {
1053 return type_expected == value.type();
1054 } else {
1055 // If value has a void type, i.e. std::any is unassigned, this is a valid state.
1056 return true;
1057 }
1058 } else {
1059 // Dealing with a general unreserved user key. Therefore check that the value has a type
1060 // from the allowed list.
1061 return TypeIsAllowedForValue(value.type());
1062 }
1063}
1064
1077template <typename T>
1078void CheckSpanSize(const T& span, const RepositoryIf::MetaData& metadata) {
1079 size_t expected_size = detail::GetNumOfElements(metadata["shape"].Cast<RtcVectorUInt64>());
1080 if (expected_size > span.size()) {
1081 throw CII_MAKE_EXCEPTION(RepositoryIf::BufferTooSmall, span.size(), expected_size);
1082 }
1083}
1084
1085} // namespace
1086
1087inline bool RepositoryIf::MetaData::ConstValueProxy::HasValue() const noexcept {
1088 return m_value.has_value();
1089}
1090
1091inline RepositoryIf::MetaData::ConstValueProxy::operator const std::any&() const {
1092 return m_value;
1093}
1094
1095template <typename T>
1096const T& RepositoryIf::MetaData::ConstValueProxy::Cast() const {
1097 CheckMetaDataValueType<T>(m_key);
1098 if constexpr (std::is_same_v<T, const std::type_info&>) {
1099 return std::any_cast<std::reference_wrapper<const std::type_info>>(m_value).get();
1100 } else {
1101 return std::any_cast<const T&>(m_value);
1102 }
1103}
1104
1105// cppcheck-suppress uninitMemberVarPrivate
1107 const std::any& value)
1108 : m_key(key), m_value(value) {
1109}
1110
1111inline bool RepositoryIf::MetaData::ValueProxy::HasValue() const noexcept {
1112 return m_value.has_value();
1113}
1114
1115inline RepositoryIf::MetaData::ValueProxy::operator const std::any&() const {
1116 return m_value;
1117}
1118
1119template <typename T>
1120T& RepositoryIf::MetaData::ValueProxy::Cast() {
1121 CheckMetaDataValueType<T>(m_key);
1122 if constexpr (std::is_same_v<T, const std::type_info&>) {
1123 return std::any_cast<std::reference_wrapper<const std::type_info>>(m_value).get();
1124 } else {
1125 return std::any_cast<T&>(m_value);
1126 }
1127}
1128
1129template <typename T>
1130const T& RepositoryIf::MetaData::ValueProxy::Cast() const {
1131 CheckMetaDataValueType<T>(m_key);
1132 if constexpr (std::is_same_v<T, const std::type_info&>) {
1133 return std::any_cast<std::reference_wrapper<const std::type_info>>(m_value).get();
1134 } else {
1135 return std::any_cast<const T&>(m_value);
1136 }
1137}
1138
1139template <typename T>
1141 using U = std::remove_cv_t<std::remove_reference_t<T>>;
1142 if constexpr (std::is_same_v<U, ValueProxy> or std::is_same_v<U, ConstValueProxy>) {
1143 // If assigning from ValueProxy or ConstValueProxy then just copy the value.
1144 CheckMetaDataValueType(m_key, rhs.m_value.type());
1145 m_value = rhs.m_value;
1146 } else if constexpr (std::is_rvalue_reference_v<decltype(rhs)>) {
1147 // Handle the case where we get an rvalue reference, i.e. dealing with a temp object.
1148 // Move/forward where possible to be more efficient.
1149 if constexpr (std::is_same_v<U, std::type_info>) {
1150 // See "Note (1)" above.
1151 CheckMetaDataTypeForReservedKeys(m_key,
1152 typeid(std::reference_wrapper<const std::type_info>));
1153 m_value = std::make_any<std::reference_wrapper<const std::type_info>>(rhs);
1154 } else if constexpr (std::is_same_v<U, std::any>) {
1155 CheckMetaDataValueType(m_key, rhs.type());
1156 m_value = std::forward<T>(rhs);
1157 } else {
1158 CheckMetaDataValueType<U>(m_key);
1159 m_value = std::forward<T>(rhs);
1160 }
1161 } else {
1162 // Handle the case where we get an lvalue reference.
1163 if constexpr (std::is_same_v<U, std::type_info>) {
1164 // See "Note (1)" above.
1165 CheckMetaDataTypeForReservedKeys(m_key,
1166 typeid(std::reference_wrapper<const std::type_info>));
1167 m_value = std::make_any<std::reference_wrapper<const std::type_info>>(rhs);
1168 } else if constexpr (std::is_same_v<U, std::any>) {
1169 CheckMetaDataValueType(m_key, rhs.type());
1170 m_value = rhs;
1171 } else {
1172 CheckMetaDataValueType<U>(m_key);
1173 m_value = rhs;
1174 }
1175 }
1176 assert(MetaDataKeyValueIsValid(m_key, m_value) &&
1177 // cppcheck-suppress incorrectStringBooleanError
1178 ("Metadata was modified in an invalid manner."));
1179 return *this;
1180}
1181
1182inline void RepositoryIf::MetaData::ValueProxy::Reset() noexcept {
1183 return m_value.reset();
1184}
1185
1186// cppcheck-suppress uninitMemberVarPrivate
1187inline RepositoryIf::MetaData::ValueProxy::ValueProxy(const std::string& key, std::any& value)
1188 : m_key(key), m_value(value) {
1189}
1190
1191template <typename MapIterType, typename ProxyType>
1192typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type&
1193RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator*() {
1194 m_pair.emplace(m_iterator->first, ProxyType(m_iterator->first, m_iterator->second));
1195 return m_pair.value();
1196}
1197
1198template <typename MapIterType, typename ProxyType>
1199typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type
1200RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator*() const {
1201 return value_type(m_iterator->first, ProxyType(m_iterator->first, m_iterator->second));
1202}
1203
1204template <typename MapIterType, typename ProxyType>
1205typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type*
1206RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator->() {
1207 m_pair.emplace(m_iterator->first, ProxyType(m_iterator->first, m_iterator->second));
1208 return &m_pair.value();
1209}
1210
1211template <typename MapIterType, typename ProxyType>
1212const typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type*
1213RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator->() const {
1214 m_pair.emplace(m_iterator->first, ProxyType(m_iterator->first, m_iterator->second));
1215 return &m_pair.value();
1216}
1217
1218template <typename MapIterType, typename ProxyType>
1219RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>&
1220RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator++() {
1221 ++m_iterator;
1222 return *this;
1223}
1224
1225template <typename MapIterType, typename ProxyType>
1226RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>
1227RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator++(int) {
1228 auto tmp = *this;
1229 ++m_iterator;
1230 return tmp;
1231}
1232
1233template <typename MapIterType, typename ProxyType>
1234RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>&
1235RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator--() {
1236 --m_iterator;
1237 return *this;
1238}
1239
1240template <typename MapIterType, typename ProxyType>
1241RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>
1242RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator--(int) {
1243 auto tmp = *this;
1244 --m_iterator;
1245 return tmp;
1246}
1247
1248template <typename MapIterType, typename ProxyType>
1249bool RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator==(
1250 const RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>& rhs) const {
1251 return m_iterator == rhs.m_iterator;
1252}
1253
1254template <typename MapIterType, typename ProxyType>
1255bool RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator!=(
1256 const RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>& rhs) const {
1257 return m_iterator != rhs.m_iterator;
1258}
1259
1260template <typename MapIterType, typename ProxyType>
1261// cppcheck-suppress uninitMemberVar
1262RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::IteratorImpl(MapIterType&& iter)
1263 : m_iterator(std::forward<MapIterType>(iter)) {
1264}
1265
1266inline RepositoryIf::MetaData::Iterator::Iterator(RepositoryIf::MetaData::MapType::iterator&& iter)
1267 : RepositoryIf::MetaData::IteratorImpl<RepositoryIf::MetaData::MapType::iterator,
1268 RepositoryIf::MetaData::ValueProxy>(
1269 std::forward<RepositoryIf::MetaData::MapType::iterator>(iter)) {
1270}
1271
1273 RepositoryIf::MetaData::MapType::const_iterator&& iter)
1274 : RepositoryIf::MetaData::IteratorImpl<RepositoryIf::MetaData::MapType::const_iterator,
1275 RepositoryIf::MetaData::ConstValueProxy>(
1276 std::forward<RepositoryIf::MetaData::MapType::const_iterator>(iter)) {
1277}
1278
1280 RepositoryIf::MetaData::MapType::reverse_iterator&& iter)
1281 : RepositoryIf::MetaData::IteratorImpl<RepositoryIf::MetaData::MapType::reverse_iterator,
1282 RepositoryIf::MetaData::ValueProxy>(
1283 std::forward<RepositoryIf::MetaData::MapType::reverse_iterator>(iter)) {
1284}
1285
1287 MapType::const_reverse_iterator&& iter)
1288 : RepositoryIf::MetaData::IteratorImpl<RepositoryIf::MetaData::MapType::const_reverse_iterator,
1289 RepositoryIf::MetaData::ConstValueProxy>(
1290 std::forward<RepositoryIf::MetaData::MapType::const_reverse_iterator>(iter)) {
1291}
1292
1293inline RepositoryIf::MetaData::TypeMismatch::Attributes::Attributes(
1294 const std::string& key, const std::type_info& type_used, const std::type_info& type_expected)
1295 : m_key(key), m_type_used(type_used), m_type_expected(type_expected) {
1296}
1297
1299 return m_metadata.empty();
1300}
1301
1302inline size_t RepositoryIf::MetaData::GetSize() const noexcept {
1303 return m_metadata.size();
1304}
1305
1306inline bool RepositoryIf::MetaData::Contains(const std::string& key) const {
1307 return m_metadata.contains(key);
1308}
1309
1310template <typename T>
1311auto& RepositoryIf::MetaData::Insert(const std::string& key, T&& value) {
1312 std::string key_copy = key;
1313 return Insert(std::move(key_copy), std::forward<T>(value));
1314}
1315
1316template <typename T>
1317auto& RepositoryIf::MetaData::Insert(std::string&& key, T&& value) {
1318 using U = std::remove_cv_t<std::remove_reference_t<T>>;
1319 decltype(m_metadata)::iterator iter;
1320 bool inserted;
1321 if constexpr (std::is_same_v<U, std::type_info>) {
1322 // Handle the case where we are assigning a type_info as the value. See "Note (1)" above.
1323 CheckMetaDataTypeForReservedKeys(key, typeid(std::reference_wrapper<const std::type_info>));
1324 auto type = std::make_any<std::reference_wrapper<const std::type_info>>(value);
1325 std::tie(iter, inserted) = m_metadata.try_emplace(std::forward<std::string>(key), type);
1326 } else {
1327 CheckMetaDataValueType<U>(key);
1328 std::tie(iter, inserted) =
1329 m_metadata.try_emplace(std::forward<std::string>(key), std::forward<T>(value));
1330 }
1331 if (not inserted) {
1332 // The try_emplace documentation indicates that it does not move the key if the insertion
1333 // did not occur. Therefore the following std::forward is OK at this point.
1334 // NOLINTNEXTLINE(bugprone-use-after-move)
1335 throw CII_MAKE_EXCEPTION(KeyAlreadyExists, std::forward<std::string>(key));
1336 }
1337 assert(MetaDataKeyValueIsValid(iter->first, iter->second) &&
1338 // cppcheck-suppress incorrectStringBooleanError
1339 ("Metadata was modified in an invalid manner."));
1340 if constexpr (std::is_same_v<U, std::type_info>) {
1341 return std::any_cast<std::reference_wrapper<const std::type_info>>(iter->second).get();
1342 } else {
1343 return std::any_cast<U&>(iter->second);
1344 }
1345}
1346
1347// The following methods are for STL compatibility and therefore must use lower case.
1348// NOLINTBEGIN(readability-identifier-naming)
1350 return m_metadata.begin();
1351};
1352
1354 return m_metadata.begin();
1355};
1356
1358 return m_metadata.cbegin();
1359};
1360
1362 return m_metadata.end();
1363};
1364
1366 return m_metadata.end();
1367};
1368
1370 return m_metadata.cend();
1371};
1372
1374 return m_metadata.rbegin();
1375};
1376
1378 return m_metadata.rbegin();
1379};
1380
1383 return m_metadata.crbegin();
1384};
1385
1387 return m_metadata.rend();
1388};
1389
1391 return m_metadata.rend();
1392};
1393
1395 return m_metadata.crend();
1396};
1397// NOLINTEND(readability-identifier-naming)
1398
1399template <typename T>
1401 const DataPointPath& path,
1402 const T& initial_value,
1403 std::optional<std::reference_wrapper<const MetaData>> metadata,
1404 const CallbackType& callback) {
1405 using TypeHandler = detail::UserTypeHandler<T>;
1406
1408
1409 MetaData merged_metadata;
1410 if (metadata.has_value()) {
1411 merged_metadata = metadata.value();
1412 }
1413 auto shape = TypeHandler::GetShape(initial_value);
1414 merged_metadata["type"] = typeid(typename TypeHandler::DataPointType);
1415 merged_metadata["shape"] = shape;
1416
1417 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1418 // If the type handler indicates it needs a temporary buffer, then we need to create it from
1419 // the initial_value buffer by resizing it appropriately and copying the data over.
1420 // Next, we create a span compatible with the new temporary buffer (not a span from the
1421 // original initial_value!), which is passed onto the actual request.
1422 using TempBufferType = typename TypeHandler::TempBufferType;
1423 using TempBufferHandler = detail::UserTypeHandler<TempBufferType>;
1424 auto temp_buffer = std::make_shared<TempBufferType>();
1425 bool buffer_resized = TempBufferHandler::ResizeBuffer(*temp_buffer, shape);
1426 if (not buffer_resized) {
1427 throw CII_MAKE_EXCEPTION(
1429 fmt::format("Resizing of a '{}' buffer should have succeeded.",
1430 boost::core::demangle(typeid(TempBufferType).name())));
1431 }
1432 auto count = detail::GetNumOfElements(shape);
1433 TypeHandler::CopyToTempBuffer(initial_value, temp_buffer, 0, count);
1434 auto span = TempBufferHandler::MakeSpan(*temp_buffer);
1435
1436 // A customised callback is also needed to cleanup the buffer once the request has
1437 // completed. Also need to remember to call the actual user callback if one was provided.
1438 auto cb = [temp_buffer, callback](const DataPointPath& path) mutable {
1439 temp_buffer.reset();
1440 if (callback) {
1441 callback(path);
1442 }
1443 };
1444
1445 using ElementType = typename TempBufferHandler::ElementType;
1447 path, std::move(span), std::move(merged_metadata), std::move(cb)});
1448 } else {
1449 // If a temporary buffer is not needed then just create the appropriate span directly from
1450 // the initial_value buffer and register the request.
1451 auto span = TypeHandler::MakeSpan(initial_value);
1452 using ElementType = typename TypeHandler::ElementType;
1454 path, std::move(span), std::move(merged_metadata), callback});
1455 }
1456}
1457
1458template <typename T>
1460 const DataPointPath& path,
1461 T& buffer,
1462 std::optional<std::reference_wrapper<MetaData>> metadata,
1463 const CallbackType& callback) const {
1464 // Note (2): Just call the internal implementation method. The reason for having an internal
1465 // implementation method is to avoid compiler errors about ambiguous methods when trying to
1466 // specialise this template method for std::any. There are two methods in the public API, one
1467 // that takes an lvalue buffer argument and the deleted method signature that takes an rvalue
1468 // buffer argument. Trying to specialise the public method leads to the compiler error.
1469 // This ambiguity is avoided by having just one internal implementation method, and specialising
1470 // the internal method.
1471 ReadDataPointImpl(path, buffer, metadata, callback);
1472}
1473
1474template <typename T>
1475void RepositoryIf::BatchRequest::ReadDataPointImpl(
1476 const DataPointPath& path,
1477 T& buffer,
1478 std::optional<std::reference_wrapper<MetaData>> metadata,
1479 const CallbackType& callback) const {
1480 static_assert(not std::is_same_v<T, std::string_view>,
1481 "It is not possible to read data from a datapoint into a read-only string_view.");
1482
1483 using TypeHandler = detail::UserTypeHandler<T>;
1484 using DataPointType = typename TypeHandler::DataPointType; // Expected type of the data point.
1485
1487
1488 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1489 using TempBufferType = typename TypeHandler::TempBufferType;
1490 using TempBufferHandler = detail::UserTypeHandler<TempBufferType>;
1491 auto temp_buffer = std::make_shared<TempBufferType>();
1492
1493 // If a temporary buffer is needed to handle the given data type T, we need to setup a
1494 // prepare_buffer callback that will allocate the temporary buffer and resize it to the
1495 // required size.
1496 // Note: "buffer" is maintained by the user, therefore its lifetime outlasts the request
1497 // and this callback invocation, therefore it can be captured by reference. The other
1498 // "temp_buffer" and user provided "callback" must be captured by value to have a copy that
1499 // will have a lifetime compatible with the invocation of the "prepare_buffer" and "cb"
1500 // functions.
1501 auto prepare_buffer = [&, temp_buffer](const MetaData& md) {
1502 // cppcheck-suppress incorrectStringBooleanError
1503 assert((md.Contains("type")) && ("Adapter must provide the type in the metadata."));
1504 // cppcheck-suppress incorrectStringBooleanError
1505 assert((md.Contains("shape")) && ("Adapter must provide the shape in the metadata."));
1506 if (md["type"].Cast<const std::type_info&>() != typeid(DataPointType)) {
1507 throw CII_MAKE_EXCEPTION(IncompatibleType, "Datapoint type mismatch.");
1508 }
1509 const auto& shape = md["shape"].Cast<RtcVectorUInt64>();
1510 TypeHandler::ResizeBuffer(buffer, shape);
1511 TempBufferHandler::ResizeBuffer(*temp_buffer, shape);
1512 // Note: no need to check if buffer was actually resized at this point.
1513 // This is effectively checked by the call to CheckSpanSize later.
1514 auto span = TempBufferHandler::MakeSpan(*temp_buffer);
1515 CheckSpanSize(span, md);
1516 return span;
1517 };
1518
1519 // In the callback we copy the data from the temporary buffer into the original buffer.
1520 // Once the data is copied, cleanup the temporary buffer and remember to call the actual
1521 // user callback if one was provided.
1522 auto cb = [&, temp_buffer, callback](const DataPointPath& path) mutable {
1523 auto shape = TempBufferHandler::GetShape(*temp_buffer);
1524 auto count = detail::GetNumOfElements(shape);
1525 TypeHandler::CopyFromTempBuffer(buffer, temp_buffer, 0, count);
1526 temp_buffer.reset();
1527 if (callback) {
1528 callback(path);
1529 }
1530 };
1531
1532 using ElementType = typename TempBufferHandler::ElementType;
1533 m_requests.push_back(detail::ReadRequest<ElementType>{
1534 path, std::move(prepare_buffer), metadata, std::move(cb)});
1535 } else {
1536 auto prepare_buffer = [&](const MetaData& md) {
1537 // cppcheck-suppress incorrectStringBooleanError
1538 assert((md.Contains("type")) && ("Adapter must provide the type in the metadata."));
1539 // cppcheck-suppress incorrectStringBooleanError
1540 assert((md.Contains("shape")) && ("Adapter must provide the shape in the metadata."));
1541 if (md["type"].Cast<const std::type_info&>() != typeid(DataPointType)) {
1542 throw CII_MAKE_EXCEPTION(IncompatibleType, "Datapoint type mismatch.");
1543 }
1544 TypeHandler::ResizeBuffer(buffer, md["shape"].Cast<RtcVectorUInt64>());
1545 auto span = TypeHandler::MakeSpan(buffer);
1546 CheckSpanSize(span, md);
1547 return span;
1548 };
1549
1550 using ElementType = typename TypeHandler::ElementType;
1551 m_requests.push_back(
1552 detail::ReadRequest<ElementType>{path, std::move(prepare_buffer), metadata, callback});
1553 }
1554}
1555
1556template <typename T>
1558 const DataPointPath& path,
1559 const T& buffer,
1560 std::optional<std::reference_wrapper<MetaData>> metadata,
1561 const CallbackType& callback) {
1562 using TypeHandler = detail::UserTypeHandler<T>;
1563
1565
1566 MetaData merged_metadata;
1567 if (metadata.has_value()) {
1568 merged_metadata = metadata.value();
1569 }
1570 auto shape = TypeHandler::GetShape(buffer);
1571 merged_metadata["type"] = typeid(typename TypeHandler::DataPointType);
1572 merged_metadata["shape"] = shape;
1573
1574 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1575 // If the type handler indicates it needs a temporary buffer, then create it, resize it to
1576 // the required size and copy the data from the input buffer into the temporary buffer.
1577 // Next, we create a span compatible with the new temporary buffer (not a span from the
1578 // original initial_value!), which is passed onto the actual request.
1579 using TempBufferType = typename TypeHandler::TempBufferType;
1580 using TempBufferHandler = detail::UserTypeHandler<TempBufferType>;
1581 auto temp_buffer = std::make_shared<TempBufferType>();
1582 bool buffer_resized = TempBufferHandler::ResizeBuffer(*temp_buffer, shape);
1583 if (not buffer_resized) {
1584 throw CII_MAKE_EXCEPTION(
1586 fmt::format("Resizing of a '{}' buffer should have succeeded.",
1587 boost::core::demangle(typeid(TempBufferType).name())));
1588 }
1589 auto count = detail::GetNumOfElements(shape);
1590 TypeHandler::CopyToTempBuffer(buffer, temp_buffer, 0, count);
1591 auto span = TempBufferHandler::MakeSpan(*temp_buffer);
1592
1593 // A customised callback is also needed to cleanup the buffer once the request has
1594 // completed. Remember to call the actual user callback if one was provided.
1595 auto cb = [temp_buffer, callback](const DataPointPath& path) mutable {
1596 temp_buffer.reset();
1597 if (callback) {
1598 callback(path);
1599 }
1600 };
1601
1602 using ElementType = typename TempBufferHandler::ElementType;
1604 path, std::move(span), std::move(merged_metadata), metadata, std::move(cb)});
1605 } else {
1606 auto span = TypeHandler::MakeSpan(buffer);
1607 using ElementType = typename TypeHandler::ElementType;
1609 path, std::move(span), std::move(merged_metadata), metadata, callback});
1610 }
1611}
1612
1613template <typename T>
1615 const DataPointPath& path,
1616 T& buffer,
1617 size_t first,
1618 size_t last,
1619 size_t d_first,
1620 std::optional<std::reference_wrapper<MetaData>> metadata,
1621 const CallbackType& callback) const {
1622 // See "Note (2)" above.
1623 PartialReadDataPointImpl(path, buffer, first, last, d_first, metadata, callback);
1624}
1625
1626template <typename T>
1627void RepositoryIf::BatchRequest::PartialReadDataPointImpl(
1628 const DataPointPath& path,
1629 T& buffer,
1630 size_t first,
1631 size_t last,
1632 size_t d_first,
1633 std::optional<std::reference_wrapper<MetaData>> metadata,
1634 const CallbackType& callback) const {
1635 using TypeHandler = detail::UserTypeHandler<T>;
1636
1638
1639 auto shape = TypeHandler::GetShape(buffer);
1640 size_t buffer_size = detail::GetNumOfElements(shape);
1641 size_t expected_size = d_first + last - first;
1642 if (first > last or expected_size > buffer_size) {
1643 throw CII_MAKE_EXCEPTION(BufferTooSmall,
1644 buffer_size,
1645 expected_size,
1646 "Make sure first <= last and d_first + last - first <= number of "
1647 "elements in the output buffer.");
1648 }
1649 MetaData input_metadata;
1650 input_metadata["type"] = typeid(typename TypeHandler::DataPointType);
1651 input_metadata["shape"] = shape;
1652
1653 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1654 // If a temporary buffer is needed to handle the given data type T, we create the temporary
1655 // buffer and resize it as a one dimensional array. It should hold just enough elements to
1656 // store the actual number that will be read from the datapoint.
1657 // Next, we create a span compatible with the new temporary buffer (not a span from the
1658 // original output buffer!), which is passed onto the actual request. Thus, the repository
1659 // adapter will actually write into the temporary buffer, from which we later copy back into
1660 // the original output buffer.
1661 using TempBufferType = typename TypeHandler::TempBufferType;
1662 using TempBufferHandler = detail::UserTypeHandler<TempBufferType>;
1663 auto temp_buffer = std::make_shared<TempBufferType>();
1664 bool buffer_resized = TempBufferHandler::ResizeBuffer(*temp_buffer, {last - first});
1665 if (not buffer_resized) {
1666 throw CII_MAKE_EXCEPTION(
1667 RepositoryIf::ServiceFailure,
1668 fmt::format("Resizing of a '{}' buffer should have succeeded.",
1669 boost::core::demangle(typeid(TempBufferType).name())));
1670 }
1671 auto span = TempBufferHandler::MakeSpan(*temp_buffer);
1672 assert((span.size() >= last - first) &&
1673 // cppcheck-suppress incorrectStringBooleanError
1674 ("The temporary buffer was not resized correctly."));
1675
1676 // In the callback we copy the data from the temporary buffer into the original buffer.
1677 // Note: the temporary buffer is treated as a one dimensional array.
1678 // Once the data is copied, cleanup the temporary buffer and remember to call the actual
1679 // user callback if one was provided.
1680 auto cb =
1681 [&, temp_buffer, callback, first, last, d_first](const DataPointPath& path) mutable {
1682 TypeHandler::CopyFromTempBuffer(buffer, temp_buffer, d_first, last - first);
1683 temp_buffer.reset();
1684 if (callback) {
1685 callback(path);
1686 }
1687 };
1688
1689 using ElementType = typename TempBufferHandler::ElementType;
1690 m_requests.push_back(detail::PartialReadRequest<ElementType>{
1691 path, span, input_metadata, metadata, first, std::move(cb)});
1692 } else {
1693 auto span = TypeHandler::MakeSpan(buffer);
1694 using ElementType = typename TypeHandler::ElementType;
1695 m_requests.push_back(detail::PartialReadRequest<ElementType>{
1696 path, span.subspan(d_first, last - first), input_metadata, metadata, first, callback});
1697 }
1698}
1699
1700template <typename T>
1702 const DataPointPath& path,
1703 const T& buffer,
1704 size_t first,
1705 size_t last,
1706 size_t d_first,
1707 std::optional<std::reference_wrapper<MetaData>> metadata,
1708 const CallbackType& callback) {
1709 using TypeHandler = detail::UserTypeHandler<T>;
1710
1712
1713 auto shape = TypeHandler::GetShape(buffer);
1714 size_t buffer_size = detail::GetNumOfElements(shape);
1715 if (first > last or last > buffer_size) {
1716 throw CII_MAKE_EXCEPTION(
1718 buffer_size,
1719 last,
1720 "Make sure first <= last <= number of elements in the input buffer.");
1721 }
1722
1723 MetaData merged_metadata;
1724 if (metadata.has_value()) {
1725 merged_metadata = metadata.value();
1726 }
1727 merged_metadata["type"] = typeid(typename TypeHandler::DataPointType);
1728 merged_metadata["shape"] = shape;
1729
1730 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1731 // If a temporary buffer is needed to handle the given data type T, we create the temporary
1732 // buffer and resize it as a one dimensional array. It should hold just enough elements to
1733 // store the actual number that will be written to the datapoint.
1734 // The data from the original input buffer is then copied into the temporary buffer.
1735 // Next, we create a span compatible with the new temporary buffer (not a span from the
1736 // original input buffer!), which is passed onto the actual request.
1737 using TempBufferType = typename TypeHandler::TempBufferType;
1738 using TempBufferHandler = detail::UserTypeHandler<TempBufferType>;
1739 auto temp_buffer = std::make_shared<TempBufferType>();
1740 bool buffer_resized = TempBufferHandler::ResizeBuffer(*temp_buffer, {last - first});
1741 if (not buffer_resized) {
1742 throw CII_MAKE_EXCEPTION(
1744 fmt::format("Resizing of a '{}' buffer should have succeeded.",
1745 boost::core::demangle(typeid(TempBufferType).name())));
1746 }
1747 TypeHandler::CopyToTempBuffer(buffer, temp_buffer, 0, last - first);
1748 auto span = TempBufferHandler::MakeSpan(*temp_buffer);
1749 assert((span.size() >= last - first) &&
1750 // cppcheck-suppress incorrectStringBooleanError
1751 ("The temporary buffer was not resized correctly."));
1752
1753 // A customised callback is also needed to cleanup the buffer once the request has
1754 // completed. Remember to call the actual user callback if one was provided.
1755 auto cb = [temp_buffer, callback](const DataPointPath& path) mutable {
1756 temp_buffer.reset();
1757 if (callback) {
1758 callback(path);
1759 }
1760 };
1761
1762 using ElementType = typename TempBufferHandler::ElementType;
1764 path, span, std::move(merged_metadata), d_first, metadata, std::move(cb)});
1765 } else {
1766 auto span = TypeHandler::MakeSpan(buffer);
1767 using ElementType = typename TypeHandler::ElementType;
1768 m_requests.push_back(
1770 span.subspan(first, last - first),
1771 std::move(merged_metadata),
1772 d_first,
1773 metadata,
1774 callback});
1775 }
1776}
1777
1778// The following template specialisations are forward declarations for handling std::any as the
1779// buffer type. Their implementations are in the .cpp file for correct linking.
1780template <>
1782 const DataPointPath& path,
1783 const std::any& initial_value,
1784 std::optional<std::reference_wrapper<const MetaData>> metadata,
1785 const CallbackType& callback);
1786
1787template <>
1788void RepositoryIf::BatchRequest::ReadDataPointImpl(
1789 const DataPointPath& path,
1790 std::any& buffer,
1791 std::optional<std::reference_wrapper<MetaData>> metadata,
1792 const CallbackType& callback) const;
1793
1794template <>
1796 const DataPointPath& path,
1797 const std::any& buffer,
1798 std::optional<std::reference_wrapper<MetaData>> metadata,
1799 const CallbackType& callback);
1800
1801template <>
1802void RepositoryIf::BatchRequest::PartialReadDataPointImpl(
1803 const DataPointPath& path,
1804 std::any& buffer,
1805 size_t first,
1806 size_t last,
1807 size_t d_first,
1808 std::optional<std::reference_wrapper<MetaData>> metadata,
1809 const CallbackType& callback) const;
1810
1811template <>
1813 const DataPointPath& path,
1814 const std::any& buffer,
1815 size_t first,
1816 size_t last,
1817 size_t d_first,
1818 std::optional<std::reference_wrapper<MetaData>> metadata,
1819 const CallbackType& callback);
1820
1821template <typename Rep, typename Period>
1822bool RepositoryIf::BatchResponse::WaitFor(const std::chrono::duration<Rep, Period>& timeout) {
1823 // Calculate a timepoint in future that will correspond to the requested timeout period and then
1824 // invoke the WaitUntil implementation. We do it this way since we may have multiple futures to
1825 // check. Using WaitUntil will make sure the original timeout period is more closely adhered to
1826 // in such a case.
1827 auto maxtime = Clock::now();
1828 maxtime += std::chrono::duration_cast<Clock::duration>(timeout);
1829 return WaitUntil(maxtime);
1830}
1831
1832template <typename Clk, typename Duration>
1833bool RepositoryIf::BatchResponse::WaitUntil(const std::chrono::time_point<Clk, Duration>& timeout) {
1834 // Check if every future in the responses list is ready.
1835 for (auto& response : m_responses) {
1836 if (response.wait_until(timeout) != std::future_status::ready) {
1837 return false;
1838 }
1839 }
1840 // If we got here then all futures are ready, therefore the call to Wait() should complete
1841 // without blocking.
1842 Wait();
1843 return true;
1844}
1845
1846template <typename T>
1848 static_assert(not std::is_same_v<T, std::any>,
1849 "Cannot create a datapoint using an empty std::any. Datapoint type is unknown.");
1850 BatchRequest req;
1851 T value{};
1852 req.CreateDataPoint(path, value);
1853 SendRequest(req).Wait();
1854}
1855
1856template <typename T>
1857void RepositoryIf::CreateDataPoint(const DataPointPath& path, const T& initial_value) {
1858 BatchRequest req;
1859 req.CreateDataPoint(path, initial_value);
1860 SendRequest(req).Wait();
1861}
1862
1863template <typename T>
1865 BatchRequest req;
1866 T result;
1867 // If we are dealing with T == std::any then fill the result buffer with an initial object of
1868 // the appropriate type, i.e. the datapoint's type.
1869 if constexpr (std::is_same_v<T, std::any>) {
1870 MetaData metadata;
1871 BatchRequest meta_req;
1872 meta_req.ReadMetaData(path, metadata);
1873 SendRequest(meta_req).Wait();
1874 result = MakeAnyBuffer(metadata);
1875 }
1876 req.ReadDataPoint(path, result);
1877 SendRequest(req).Wait();
1878 return result;
1879}
1880
1881template <typename T>
1882std::optional<T> RepositoryIf::TryGetDataPoint(const DataPointPath& path) const {
1883 if (DataPointExists(path)) {
1884 return GetDataPoint<T>(path);
1885 }
1886 return std::nullopt;
1887}
1888
1889template <typename T>
1890void RepositoryIf::SetDataPoint(const DataPointPath& path, const T& value) {
1891 BatchRequest req;
1892 req.WriteDataPoint(path, value);
1893 SendRequest(req).Wait();
1894}
1895
1896template <typename T>
1897void RepositoryIf::ReadDataPoint(const DataPointPath& path, T& buffer) const {
1898 // If we are dealing with T == std::any and the buffer is empty, then fill it with an initial
1899 // object of the appropriate type, i.e. the datapoint's type.
1900 if constexpr (std::is_same_v<T, std::any>) {
1901 if (not buffer.has_value()) {
1902 MetaData metadata;
1903 BatchRequest meta_req;
1904 meta_req.ReadMetaData(path, metadata);
1905 SendRequest(meta_req).Wait();
1906 buffer = MakeAnyBuffer(metadata);
1907 }
1908 }
1909 BatchRequest req;
1910 req.ReadDataPoint(path, buffer);
1911 SendRequest(req).Wait();
1912}
1913
1914template <typename T>
1915void RepositoryIf::WriteDataPoint(const DataPointPath& path, const T& buffer) {
1916 BatchRequest req;
1917 req.WriteDataPoint(path, buffer);
1918 SendRequest(req).Wait();
1919}
1920
1921template <typename... T>
1922void RepositoryIf::WriteDataPoints(const T&... args) {
1923 std::optional<std::reference_wrapper<const DataPointPath>> path_ref;
1924 BatchRequest req;
1925 (
1926 [&] {
1927 if constexpr (std::is_same_v<const DataPointPath&, decltype(args)>) {
1928 path_ref = args;
1929 } else {
1930 req.WriteDataPoint(path_ref.value().get(), args);
1931 }
1932 }(),
1933 ...);
1934 SendRequest(req).Wait();
1935}
1936
1937template <typename... T>
1938void RepositoryIf::ReadDataPoints(T&... args) const {
1939 std::optional<std::reference_wrapper<const DataPointPath>> path_ref;
1940
1941 // If there are std::any arguments given and the corresponding buffers are empty, then fill them
1942 // with an initial object of the appropriate type, i.e. the datapoint's type.
1943 if constexpr ((std::is_same_v<T, std::any> or ...)) {
1944 using Entry = std::pair<std::reference_wrapper<std::any>, MetaData>;
1945 std::vector<Entry> any_buffers;
1946 // Make sure to reserve enough space in any_buffers to prevent reallocations, otherwise
1947 // the memory addresses given to the ReadMetaData calls will become invalidated.
1948 any_buffers.reserve(sizeof...(T));
1949 BatchRequest meta_req;
1950 (
1951 [&] {
1952 if constexpr (std::is_same_v<DataPointPath&, decltype(args)>) {
1953 path_ref = args;
1954 } else if constexpr (std::is_same_v<std::any&, decltype(args)>) {
1955 if (not args.has_value()) {
1956 auto& metadata = any_buffers.emplace_back(Entry(args, MetaData{})).second;
1957 meta_req.ReadMetaData(path_ref.value().get(), metadata);
1958 }
1959 }
1960 }(),
1961 ...);
1962 if (not any_buffers.empty()) {
1963 SendRequest(meta_req).Wait();
1964 for (const auto& [buffer, metadata] : any_buffers) {
1965 buffer.get() = MakeAnyBuffer(metadata);
1966 }
1967 }
1968 }
1969
1970 BatchRequest req;
1971 (
1972 [&] {
1973 if constexpr (std::is_same_v<DataPointPath&, decltype(args)>) {
1974 path_ref = args;
1975 } else {
1976 req.ReadDataPoint(path_ref.value().get(), args);
1977 }
1978 }(),
1979 ...);
1980 SendRequest(req).Wait();
1981}
1982
1983} // namespace rtctk::componentFramework
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:76
bool IsAbsolutePath() const
Checks whether the path is an absolute path.
Definition dataPointPath.cpp:144
A buffer class representing 2D matrix data.
Definition matrixBuffer.hpp:27
size_type GetNcols() const
Definition matrixBuffer.hpp:88
size_type GetNrows() const
Definition matrixBuffer.hpp:84
constexpr void resize(size_type n, size_type m)
Definition matrixBuffer.hpp:59
A span referencing a 2D matrix buffer.
Definition matrixSpan.hpp:35
size_type GetNrows() const
Definition matrixSpan.hpp:155
size_type GetNcols() const
Definition matrixSpan.hpp:159
An object representing one or more asynchronous I/O requests to a repository.
Definition repositoryIf.hpp:638
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 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 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 ReadMetaData(const DataPointPath &path, MetaData &metadata, const CallbackType &callback=nullptr) const
Definition repositoryIf.cpp:372
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 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
void Wait()
Definition repositoryIf.cpp:650
ResponseList m_responses
Definition repositoryIf.hpp:963
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
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
Bidirectional forward iterator returned by the begin/end methods.
Definition repositoryIf.hpp:354
Exception indicating that the metadata already contains the given key.
Definition repositoryIf.hpp:407
Bidirectional reverse iterator returned by the rbegin/rend methods.
Definition repositoryIf.hpp:375
Exception indicating that a value with the wrong type was being assigned to a reserved key.
Definition repositoryIf.hpp:420
Exception indicating that an unsupported type was used for the metadata value.
Definition repositoryIf.hpp:445
Interface class to an underlying metadata value.
Definition repositoryIf.hpp:207
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
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
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
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
void ReadDataPoints(T &... args) const
Definition repositoryIf.ipp:1938
void CreateDataPoint(const DataPointPath &path)
Creates a new empty datapoint in the repository.
Definition repositoryIf.ipp:1847
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
void WriteDataPoint(const DataPointPath &path, const T &buffer)
Writes a datapoint to the repository.
Definition repositoryIf.ipp:1915
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
bool DataPointExists(const DataPointPath &path) const
Checks for the existence of a datapoint in the repository.
Definition repositoryIf.cpp:771
Definition measurable.hpp:25
RtcUInt64 GetNumOfElements(const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:135
void EnsureAbsolutePath(const DataPointPath &path)
Definition repositoryIf.ipp:144
Definition commandReplier.cpp:21
RepositoryIf::MetaData MetaData
Definition oldbAdapter.cpp:57
void to_json(JsonPayload &j, const DataPointPath &v)
Definition dataPointPath.cpp:217
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:24
std::int64_t RtcInt64
Definition basicTypes.hpp:40
std::int16_t RtcInt16
Definition basicTypes.hpp:38
std::uint16_t RtcUInt16
Definition basicTypes.hpp:42
float RtcFloat
Definition basicTypes.hpp:45
std::int32_t RtcInt32
Definition basicTypes.hpp:39
componentFramework::MatrixBuffer< T > RtcMatrix
Definition basicTypes.hpp:34
std::int8_t RtcInt8
Definition basicTypes.hpp:37
std::string RtcString
Definition basicTypes.hpp:47
std::vector< T > RtcVector
Definition basicTypes.hpp:28
bool RtcBool
Definition basicTypes.hpp:36
std::uint32_t RtcUInt32
Definition basicTypes.hpp:43
RtcMatrix< RtcBool > RtcMatrixBool
Definition basicTypes.hpp:61
std::uint8_t RtcUInt8
Definition basicTypes.hpp:41
RtcVector< RtcBool > RtcVectorBool
Definition basicTypes.hpp:49
RtcVector< RtcUInt64 > RtcVectorUInt64
Definition basicTypes.hpp:57
std::uint64_t RtcUInt64
Definition basicTypes.hpp:44
double RtcDouble
Definition basicTypes.hpp:46
Definition ddsSub.hpp:155
gsl::span< const T > data
Definition repositoryIf.ipp:42
DataPointPath path
Definition repositoryIf.ipp:41
T ElementType
Definition repositoryIf.ipp:40
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:44
RepositoryIf::MetaData metadata
Definition repositoryIf.ipp:43
DataPointPath link_path
Definition repositoryIf.ipp:125
DataPointPath path
Definition repositoryIf.ipp:124
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:126
DataPointPath path
Definition repositoryIf.ipp:48
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:49
DataPointPath path
Definition repositoryIf.ipp:53
bool & result
Definition repositoryIf.ipp:54
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:55
bool recurse
Definition repositoryIf.ipp:60
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:62
std::pair< RepositoryIf::PathList, RepositoryIf::PathList > & result
Definition repositoryIf.ipp:61
DataPointPath path
Definition repositoryIf.ipp:59
DataPointPath path
Definition repositoryIf.ipp:92
gsl::span< T > data
Definition repositoryIf.ipp:93
RepositoryIf::MetaData input_metadata
Definition repositoryIf.ipp:94
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:97
std::optional< std::reference_wrapper< RepositoryIf::MetaData > > output_metadata
Definition repositoryIf.ipp:95
size_t offset
Definition repositoryIf.ipp:96
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:108
DataPointPath path
Definition repositoryIf.ipp:103
RepositoryIf::MetaData metadata
Definition repositoryIf.ipp:105
gsl::span< const T > data
Definition repositoryIf.ipp:104
size_t offset
Definition repositoryIf.ipp:106
std::optional< std::reference_wrapper< RepositoryIf::MetaData > > output_metadata
Definition repositoryIf.ipp:107
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:114
RepositoryIf::MetaData & metadata
Definition repositoryIf.ipp:113
DataPointPath path
Definition repositoryIf.ipp:112
T ElementType
Definition repositoryIf.ipp:67
std::function< gsl::span< T >(const RepositoryIf::MetaData &)> PrepareFunctionType
Definition repositoryIf.ipp:68
std::optional< std::reference_wrapper< RepositoryIf::MetaData > > metadata
Definition repositoryIf.ipp:75
PrepareFunctionType prepare_buffer
Definition repositoryIf.ipp:74
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:76
DataPointPath path
Definition repositoryIf.ipp:69
DataPointPath path
Definition repositoryIf.ipp:130
DataPointPath link_path
Definition repositoryIf.ipp:131
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:132
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:551
MatrixBuffer< T, A > BufferType
Definition repositoryIf.ipp:550
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:556
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:572
RtcMatrix< ElementType > DataPointType
Definition repositoryIf.ipp:552
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:576
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:553
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:568
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:591
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:608
static gsl::span< ElementType > MakeSpan(BufferType &buffer)=delete
Span not constructable from a MatrixBuffer<bool> type.
boost::container::vector< bool > TempBufferType
Definition repositoryIf.ipp:592
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)=delete
Span not constructable from a MatrixBuffer<bool> type.
static void CopyToTempBuffer(const BufferType &buffer, std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)
Definition repositoryIf.ipp:617
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:589
static void CopyFromTempBuffer(BufferType &buffer, const std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)
Definition repositoryIf.ipp:628
MatrixBuffer< bool, A > BufferType
Definition repositoryIf.ipp:588
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:594
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:648
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:660
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:668
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:643
MatrixSpan< T > BufferType
Definition repositoryIf.ipp:642
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:645
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:664
RtcMatrix< ElementType > DataPointType
Definition repositoryIf.ipp:644
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:872
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:892
std::remove_cv_t< T > ElementType
Definition repositoryIf.ipp:870
T[N][M] BufferType
Definition repositoryIf.ipp:869
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:875
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:897
RtcMatrix< ElementType > DataPointType
Definition repositoryIf.ipp:871
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:887
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:820
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:800
T[N] BufferType
Definition repositoryIf.ipp:797
void TempBufferType
Definition repositoryIf.ipp:801
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:799
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:803
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:824
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:816
std::remove_cv_t< T > ElementType
Definition repositoryIf.ipp:798
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:445
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:424
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:449
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:423
boost::container::vector< T, A > BufferType
Definition repositoryIf.ipp:422
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:428
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:441
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:850
RtcString DataPointType
Definition repositoryIf.ipp:838
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:846
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:854
char[N] BufferType
Definition repositoryIf.ipp:836
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:839
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:842
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:484
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:467
gsl::span< T, N > BufferType
Definition repositoryIf.ipp:461
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:462
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:463
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:488
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:480
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:464
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:501
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:514
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:510
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:518
gsl::span< char, N > BufferType
Definition repositoryIf.ipp:500
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:503
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:506
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:539
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:543
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:526
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:535
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:531
gsl::span< const char, N > BufferType
Definition repositoryIf.ipp:525
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:683
std::array< T, N > BufferType
Definition repositoryIf.ipp:680
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:707
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:703
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:682
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:699
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:686
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:681
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:725
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:722
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:737
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:733
std::array< char, N > BufferType
Definition repositoryIf.ipp:719
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:720
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:729
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:767
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:755
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:779
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:773
std::array< std::array< T, M >, N > BufferType
Definition repositoryIf.ipp:749
std::string BufferType
Definition repositoryIf.ipp:267
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:273
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:277
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:270
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:285
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:281
RtcString DataPointType
Definition repositoryIf.ipp:269
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:268
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:303
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:317
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:300
static gsl::span< ElementType > MakeSpan(BufferType &buffer)=delete
It is not possible to create mutable span from a read-only string view.
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:312
std::string_view BufferType
Definition repositoryIf.ipp:297
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:298
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:330
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:335
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:348
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:332
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:331
std::vector< T, A > BufferType
Definition repositoryIf.ipp:329
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:352
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:356
static const bool USES_TEMP_BUFFER
Definition repositoryIf.ipp:371
static gsl::span< ElementType > MakeSpan(BufferType &buffer)=delete
Span not constructable from a std::vector<bool> type.
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)=delete
Span not constructable from a std::vector<bool> type.
boost::container::vector< bool > TempBufferType
Definition repositoryIf.ipp:372
static void CopyFromTempBuffer(BufferType &buffer, const std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)
Definition repositoryIf.ipp:408
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:369
std::vector< bool, A > BufferType
Definition repositoryIf.ipp:368
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:374
static void CopyToTempBuffer(const BufferType &buffer, std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)
Definition repositoryIf.ipp:397
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:388
void TempBufferType
Defines the temporary buffer type (set to void if USES_TEMP_BUFFER is false).
Definition repositoryIf.ipp:166
static const bool USES_TEMP_BUFFER
Flag indicating if a temporary buffer is required to read/write this type.
Definition repositoryIf.ipp:163
static void CopyToTempBuffer(const BufferType &buffer, std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)=delete
Copy data from the original buffer into the temporary buffer.
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Creates a span from a read-only buffer object.
Definition repositoryIf.ipp:201
std::remove_cv_t< T > ElementType
Defines the element type of the buffer object.
Definition repositoryIf.ipp:157
T DataPointType
Defines the corresponding data point type that type T is compatible with.
Definition repositoryIf.ipp:160
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Creates a span from a buffer object.
Definition repositoryIf.ipp:192
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Returns the shape of a buffer object.
Definition repositoryIf.ipp:175
T BufferType
Defines the type of the buffer object that handles type T.
Definition repositoryIf.ipp:154
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Tries to resize the buffer to the given shape.
Definition repositoryIf.ipp:219
static void CopyFromTempBuffer(BufferType &buffer, const std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)=delete
Copy data from the temporary buffer into the original buffer.
DataPointPath path
Definition repositoryIf.ipp:118
RepositoryIf::MetaData metadata
Definition repositoryIf.ipp:119
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:120
RepositoryIf::MetaData metadata
Definition repositoryIf.ipp:84
DataPointPath path
Definition repositoryIf.ipp:82
gsl::span< const T > data
Definition repositoryIf.ipp:83
std::optional< std::reference_wrapper< RepositoryIf::MetaData > > output_metadata
Definition repositoryIf.ipp:85
T ElementType
Definition repositoryIf.ipp:81
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:86
Provides useful mechanisms to test various type traits.