20#include <fmt/format.h>
22#include <boost/container/vector.hpp>
23#include <boost/core/demangle.hpp>
28#include <unordered_set>
58 std::pair<RepositoryIf::PathList, RepositoryIf::PathList>&
result;
72 std::optional<std::reference_wrapper<RepositoryIf::MetaData>>
metadata;
163 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
164 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
165 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
166 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
167 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
168 std::is_same_v<T, RtcDouble>,
169 "The scalar type is not supported.");
205 if (shape.size() == 0) {
229 size_t count) =
delete;
245 const std::shared_ptr<TempBufferType>&
temp_buffer,
247 size_t count) =
delete;
253 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
271 if (shape.size() == 1) {
283 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
302 if (shape.size() == 1
and shape[0] ==
buffer.size()) {
311template <
typename T,
typename A>
314 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
320 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
321 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
322 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
323 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
324 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
325 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>
or
326 std::is_same_v<T, std::byte>,
327 "The vector type is not supported.");
340 if (shape.size() == 1) {
352 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
372 if (shape.size() == 1) {
390 const std::shared_ptr<TempBufferType>&
temp_buffer,
393 assert((
buffer.size() >= offset +
count) && (
"The output buffer is too small."));
399template <
typename T,
typename A>
402 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
408 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
409 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
410 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
411 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
412 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
413 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>
or
414 std::is_same_v<T, std::byte>,
415 "The vector type is not supported.");
428 if (shape.size() == 1) {
437template <
typename T, decltype(gsl::dynamic_extent) N>
440 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
446 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
447 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
448 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
449 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
450 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
451 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>
or
452 std::is_same_v<T, std::byte>,
453 "The vector type is not supported.");
466 if (shape.size() == 1
and shape[0] ==
buffer.size()) {
475template <decltype(gsl::dynamic_extent) N>
478 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
500template <
typename T,
typename A>
503 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
509 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
510 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
511 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
512 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
513 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
514 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>,
515 "The matrix type is not supported.");
528 if (shape.size() == 2) {
529 buffer.resize(shape[0], shape[1]);
540 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
560 if (shape.size() == 2) {
561 buffer.resize(shape[0], shape[1]);
578 const std::shared_ptr<TempBufferType>&
temp_buffer,
581 assert((
buffer.size() >= offset +
count) && (
"The output buffer is too small."));
590 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
596 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
597 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
598 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
599 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
600 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
601 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>,
602 "The matrix type is not supported.");
615 if (shape.size() == 2
and shape[0] ==
buffer.GetNrows()
and shape[1] ==
buffer.GetNcols()) {
624template <
typename T, std::
size_t N>
627 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
633 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
634 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
635 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
636 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
637 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
638 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>
or
639 std::is_same_v<T, std::byte>,
640 "The array type is not supported.");
653 if (shape.size() == 1
and shape[0] ==
buffer.size()) {
662template <std::
size_t N>
665 using ElementType = std::remove_cv_t<typename BufferType::value_type>;
683 if (shape.size() == 1
and shape[0] ==
buffer.size()) {
692template <
typename T, std::
size_t N, std::
size_t M>
701 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
702 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
703 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
704 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
705 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
706 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>,
707 "The array type is not supported.");
714 return {begin,
N *
M};
720 return {begin,
N *
M};
724 if (shape.size() == 2
and shape[0] ==
N and shape[1] ==
M) {
736template <
typename T, std::
size_t N>
745 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
746 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
747 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
748 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
749 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
750 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>
or
751 std::is_same_v<T, std::byte>,
752 "The array type is not supported.");
765 if (shape.size() == 1
and shape[0] ==
N) {
774template <std::
size_t N>
795 if (shape.size() == 1
and shape[0] ==
N) {
807template <
typename T, std::
size_t N, std::
size_t M>
816 static_assert(std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or
817 std::is_same_v<T, RtcInt16>
or std::is_same_v<T, RtcInt32>
or
818 std::is_same_v<T, RtcInt64>
or std::is_same_v<T, RtcUInt8>
or
819 std::is_same_v<T, RtcUInt16>
or std::is_same_v<T, RtcUInt32>
or
820 std::is_same_v<T, RtcUInt64>
or std::is_same_v<T, RtcFloat>
or
821 std::is_same_v<T, RtcDouble>
or std::is_same_v<T, RtcString>,
822 "The array type is not supported.");
837 if (shape.size() == 2
and shape[0] ==
N and shape[1] ==
M) {
857 static const std::unordered_set<std::type_index>
valid_types = {
859 std::type_index(
typeid(
void)),
860 std::type_index(
typeid(
RtcBool)),
861 std::type_index(
typeid(
RtcInt8)),
875 std::type_index(
typeid(std::reference_wrapper<const std::type_info>)),
877 std::type_index(
typeid(DataPointPath)),
878 std::type_index(
typeid(std::set<DataPointPath>))};
880#if __cplusplus >= 202002L
881 return valid_types.contains(std::type_index(type));
896 {
"type",
typeid(std::reference_wrapper<const std::type_info>)},
900 {
"symlink_target",
typeid(DataPointPath)},
901 {
"symlinks",
typeid(std::set<DataPointPath>)},
966 std::is_same_v<T, RtcBool>
or std::is_same_v<T, RtcInt8>
or std::is_same_v<T, RtcInt16>
or
967 std::is_same_v<T, RtcInt32>
or std::is_same_v<T, RtcInt64>
or
968 std::is_same_v<T, RtcUInt8>
or std::is_same_v<T, RtcUInt16>
or
969 std::is_same_v<T, RtcUInt32>
or std::is_same_v<T, RtcUInt64>
or
970 std::is_same_v<T, RtcFloat>
or std::is_same_v<T, RtcDouble>
or
971 std::is_same_v<T, RtcString>
or std::is_same_v<T, RtcBinary>
or
972 std::is_same_v<T, RtcVectorUInt64>
or std::is_same_v<T, const std::type_info&>
or
973 std::is_same_v<T, RepositoryIf::Timestamp>
or std::is_same_v<T, DataPointPath>
or
974 std::is_same_v<T, std::set<DataPointPath>>,
975 "The type is not supported for MetaData values.");
976 if constexpr (std::is_same_v<T, const std::type_info&>) {
995 if (value.type() !=
typeid(
void)) {
1020template <
typename T>
1021void CheckSpanSize(
const T& span,
const RepositoryIf::MetaData& metadata) {
1031 return m_value.has_value();
1034inline RepositoryIf::MetaData::ConstValueProxy::operator
const std::any&()
const {
1038template <
typename T>
1039const T& RepositoryIf::MetaData::ConstValueProxy::Cast()
const {
1041 if constexpr (std::is_same_v<T, const std::type_info&>) {
1042 return std::any_cast<std::reference_wrapper<const std::type_info>>(m_value).
get();
1044 return std::any_cast<const T&>(m_value);
1049 const std::any& value)
1050 : m_key(
key), m_value(value) {
1054 return m_value.has_value();
1057inline RepositoryIf::MetaData::ValueProxy::operator
const std::any&()
const {
1061template <
typename T>
1062T& RepositoryIf::MetaData::ValueProxy::Cast() {
1064 if constexpr (std::is_same_v<T, const std::type_info&>) {
1065 return std::any_cast<std::reference_wrapper<const std::type_info>>(m_value).
get();
1067 return std::any_cast<T&>(m_value);
1071template <
typename T>
1072const T& RepositoryIf::MetaData::ValueProxy::Cast()
const {
1074 if constexpr (std::is_same_v<T, const std::type_info&>) {
1075 return std::any_cast<std::reference_wrapper<const std::type_info>>(m_value).
get();
1077 return std::any_cast<const T&>(m_value);
1081template <
typename T>
1083 using U = std::remove_cv_t<std::remove_reference_t<T>>;
1084 if constexpr (std::is_same_v<U, ValueProxy>
or std::is_same_v<U, ConstValueProxy>) {
1087 m_value =
rhs.m_value;
1088 }
else if constexpr (std::is_rvalue_reference_v<
decltype(
rhs)>) {
1091 if constexpr (std::is_same_v<U, std::type_info>) {
1093 typeid(std::reference_wrapper<const std::type_info>));
1094 m_value = std::make_any<std::reference_wrapper<const std::type_info>>(
rhs);
1095 }
else if constexpr (std::is_same_v<U, std::any>) {
1097 m_value = std::move(
rhs);
1100 m_value = std::forward<T>(
rhs);
1104 if constexpr (std::is_same_v<U, std::type_info>) {
1106 typeid(std::reference_wrapper<const std::type_info>));
1107 m_value = std::make_any<std::reference_wrapper<const std::type_info>>(
rhs);
1108 }
else if constexpr (std::is_same_v<U, std::any>) {
1117 (
"Metadata was modified in an invalid manner."));
1121inline void RepositoryIf::MetaData::ValueProxy::Reset()
noexcept {
1122 return m_value.reset();
1126 : m_key(
key), m_value(value) {
1129template <
typename MapIterType,
typename ProxyType>
1130typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type&
1131RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator*() {
1132 m_pair.emplace(m_iterator->first,
ProxyType(m_iterator->first, m_iterator->second));
1133 return m_pair.value();
1136template <
typename MapIterType,
typename ProxyType>
1137typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type
1138RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator*()
const {
1139 return value_type(m_iterator->first,
ProxyType(m_iterator->first, m_iterator->second));
1142template <
typename MapIterType,
typename ProxyType>
1143typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type*
1144RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator->() {
1145 m_pair.emplace(m_iterator->first,
ProxyType(m_iterator->first, m_iterator->second));
1146 return &m_pair.value();
1149template <
typename MapIterType,
typename ProxyType>
1150const typename RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::value_type*
1151RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator->()
const {
1152 m_pair.emplace(m_iterator->first,
ProxyType(m_iterator->first, m_iterator->second));
1153 return &m_pair.value();
1156template <
typename MapIterType,
typename ProxyType>
1157RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>&
1158RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator++() {
1163template <
typename MapIterType,
typename ProxyType>
1164RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>
1165RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator++(
int) {
1171template <
typename MapIterType,
typename ProxyType>
1172RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>&
1173RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator--() {
1178template <
typename MapIterType,
typename ProxyType>
1179RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>
1180RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator--(
int) {
1186template <
typename MapIterType,
typename ProxyType>
1187bool RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator==(
1188 const RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>&
rhs)
const {
1189 return m_iterator ==
rhs.m_iterator;
1192template <
typename MapIterType,
typename ProxyType>
1193bool RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::operator!=(
1194 const RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>&
rhs)
const {
1195 return m_iterator !=
rhs.m_iterator;
1198template <
typename MapIterType,
typename ProxyType>
1199RepositoryIf::MetaData::IteratorImpl<MapIterType, ProxyType>::IteratorImpl(
MapIterType&&
iter)
1203inline RepositoryIf::MetaData::Iterator::Iterator(RepositoryIf::MetaData::MapType::iterator&&
iter)
1204 : RepositoryIf::
MetaData::IteratorImpl<RepositoryIf::
MetaData::MapType::iterator,
1205 RepositoryIf::
MetaData::ValueProxy>(
1209inline RepositoryIf::MetaData::ConstIterator::ConstIterator(
1210 RepositoryIf::MetaData::MapType::const_iterator&&
iter)
1211 : RepositoryIf::
MetaData::IteratorImpl<RepositoryIf::
MetaData::MapType::const_iterator,
1212 RepositoryIf::
MetaData::ConstValueProxy>(
1216inline RepositoryIf::MetaData::ReverseIterator::ReverseIterator(
1217 RepositoryIf::MetaData::MapType::reverse_iterator&&
iter)
1219 RepositoryIf::
MetaData::ValueProxy>(
1223inline RepositoryIf::MetaData::ConstReverseIterator::ConstReverseIterator(
1224 MapType::const_reverse_iterator&&
iter)
1226 RepositoryIf::
MetaData::ConstValueProxy>(
1230inline RepositoryIf::MetaData::TypeMismatch::Attributes::Attributes(
1236 return m_metadata.empty();
1240 return m_metadata.size();
1244#if __cplusplus >= 202002L
1245 return m_metadata.contains(
key);
1247 return m_metadata.find(
key) != m_metadata.end();
1251template <
typename T>
1257template <
typename T>
1259 using U = std::remove_cv_t<std::remove_reference_t<T>>;
1260 decltype(m_metadata)::iterator
iter;
1262 if constexpr (std::is_same_v<U, std::type_info>) {
1265 typeid(std::reference_wrapper<const std::type_info>));
1266 auto type = std::make_any<std::reference_wrapper<const std::type_info>>(value);
1267 std::tie(
iter,
inserted) = m_metadata.try_emplace(std::forward<std::string>(
key), type);
1271 m_metadata.try_emplace(std::forward<std::string>(
key), std::forward<T>(value));
1277 (
"Metadata was modified in an invalid manner."));
1278 if constexpr (std::is_same_v<U, std::type_info>) {
1279 return std::any_cast<std::reference_wrapper<const std::type_info>>(
iter->second).
get();
1281 return std::any_cast<U&>(
iter->second);
1288 return m_metadata.begin();
1292 return m_metadata.begin();
1296 return m_metadata.cbegin();
1300 return m_metadata.end();
1304 return m_metadata.end();
1308 return m_metadata.cend();
1312 return m_metadata.rbegin();
1316 return m_metadata.rbegin();
1321 return m_metadata.crbegin();
1325 return m_metadata.rend();
1329 return m_metadata.rend();
1333 return m_metadata.crend();
1337template <
typename T>
1341 std::optional<std::reference_wrapper<const MetaData>> metadata,
1346 if (metadata.has_value()) {
1350 merged_metadata[
"type"] =
typeid(
typename TypeHandler::DataPointType);
1353 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1358 using TempBufferType =
typename TypeHandler::TempBufferType;
1360 auto temp_buffer = std::make_shared<TempBufferType>();
1365 fmt::format(
"Resizing of a '{}' buffer should have succeeded.",
1366 boost::core::demangle(
typeid(TempBufferType).name())));
1370 auto span = TempBufferHandler::MakeSpan(*
temp_buffer);
1381 using ElementType =
typename TempBufferHandler::ElementType;
1388 using ElementType =
typename TypeHandler::ElementType;
1394template <
typename T>
1398 std::optional<std::reference_wrapper<MetaData>> metadata,
1400 static_assert(
not std::is_same_v<T, std::string_view>,
1401 "It is not possible to read data from a datapoint into a read-only string_view.");
1404 using DataPointType =
typename TypeHandler::DataPointType;
1406 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1407 using TempBufferType =
typename TypeHandler::TempBufferType;
1409 auto temp_buffer = std::make_shared<TempBufferType>();
1420 assert((
md.Contains(
"type")) && (
"Adapter must provide the type in the metadata."));
1421 assert((
md.Contains(
"shape")) && (
"Adapter must provide the shape in the metadata."));
1426 TypeHandler::ResizeBuffer(
buffer, shape);
1427 TempBufferHandler::ResizeBuffer(*
temp_buffer, shape);
1430 auto span = TempBufferHandler::MakeSpan(*
temp_buffer);
1439 auto shape = TempBufferHandler::GetShape(*
temp_buffer);
1448 using ElementType =
typename TempBufferHandler::ElementType;
1450 path, std::move(prepare_buffer), metadata, std::move(
cb)});
1452 auto prepare_buffer = [&](
const MetaData&
md) {
1453 assert((
md.Contains(
"type")) && (
"Adapter must provide the type in the metadata."));
1454 assert((
md.Contains(
"shape")) && (
"Adapter must provide the shape in the metadata."));
1459 auto span = TypeHandler::MakeSpan(
buffer);
1464 using ElementType =
typename TypeHandler::ElementType;
1465 m_requests.push_back(
1470template <
typename T>
1474 std::optional<std::reference_wrapper<const MetaData>> metadata,
1479 if (metadata.has_value()) {
1482 auto shape = TypeHandler::GetShape(
buffer);
1483 merged_metadata[
"type"] =
typeid(
typename TypeHandler::DataPointType);
1486 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1491 using TempBufferType =
typename TypeHandler::TempBufferType;
1493 auto temp_buffer = std::make_shared<TempBufferType>();
1498 fmt::format(
"Resizing of a '{}' buffer should have succeeded.",
1499 boost::core::demangle(
typeid(TempBufferType).name())));
1503 auto span = TempBufferHandler::MakeSpan(*
temp_buffer);
1514 using ElementType =
typename TempBufferHandler::ElementType;
1518 auto span = TypeHandler::MakeSpan(
buffer);
1519 using ElementType =
typename TypeHandler::ElementType;
1525template <
typename T>
1532 std::optional<std::reference_wrapper<MetaData>> metadata,
1536 auto shape = TypeHandler::GetShape(
buffer);
1543 "Make sure first <= last and d_first + last - first <= number of "
1544 "elements in the output buffer.");
1547 input_metadata[
"type"] =
typeid(
typename TypeHandler::DataPointType);
1548 input_metadata[
"shape"] = shape;
1550 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1558 using TempBufferType =
typename TypeHandler::TempBufferType;
1560 auto temp_buffer = std::make_shared<TempBufferType>();
1565 fmt::format(
"Resizing of a '{}' buffer should have succeeded.",
1566 boost::core::demangle(
typeid(TempBufferType).name())));
1568 auto span = TempBufferHandler::MakeSpan(*
temp_buffer);
1570 (
"The temporary buffer was not resized correctly."));
1585 using ElementType =
typename TempBufferHandler::ElementType;
1587 path, span, input_metadata, metadata,
first, std::move(
cb)});
1589 auto span = TypeHandler::MakeSpan(
buffer);
1590 using ElementType =
typename TypeHandler::ElementType;
1596template <
typename T>
1603 std::optional<std::reference_wrapper<const MetaData>> metadata,
1607 auto shape = TypeHandler::GetShape(
buffer);
1614 "Make sure first <= last <= number of elements in the input buffer.");
1618 if (metadata.has_value()) {
1621 merged_metadata[
"type"] =
typeid(
typename TypeHandler::DataPointType);
1624 if constexpr (TypeHandler::USES_TEMP_BUFFER) {
1631 using TempBufferType =
typename TypeHandler::TempBufferType;
1633 auto temp_buffer = std::make_shared<TempBufferType>();
1638 fmt::format(
"Resizing of a '{}' buffer should have succeeded.",
1639 boost::core::demangle(
typeid(TempBufferType).name())));
1642 auto span = TempBufferHandler::MakeSpan(*
temp_buffer);
1644 (
"The temporary buffer was not resized correctly."));
1655 using ElementType =
typename TempBufferHandler::ElementType;
1659 auto span = TypeHandler::MakeSpan(
buffer);
1660 using ElementType =
typename TypeHandler::ElementType;
1661 m_requests.push_back(
1670template <
typename Rep,
typename Period>
1681template <
typename Clk,
typename Duration>
1684 for (
auto&
response : m_responses) {
1695template <
typename T>
1703template <
typename T>
1710template <
typename T>
1719template <
typename T>
1726template <
typename T>
1733template <
typename T>
1740template <
typename... T>
1742 std::optional<std::reference_wrapper<const DataPointPath>>
path_ref;
1756template <
typename... T>
1758 std::optional<std::reference_wrapper<const DataPointPath>>
path_ref;
1785template <
typename T>
1818template <
typename T,
typename F>
1820 static_assert(std::is_convertible_v<
F, std::function<
void(T&)>>,
1821 "The handler callback must have a signature compatible with void(T&).");
1839template <
typename T>
1870template <
typename T,
typename F>
1872 static_assert(std::is_convertible_v<
F, std::function<
void(
const T&)>>,
1873 "The handler callback must have a signature compatible with void(const T&).");
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:74
A buffer class representing 2D matrix data.
Definition matrixBuffer.hpp:28
A span referencing a 2D matrix buffer.
Definition matrixSpan.hpp:35
An object representing one or more asynchronous I/O requests to a repository.
Definition repositoryIf.hpp:683
void ReadDataPoint(const DataPointPath &path, T &buffer, std::optional< std::reference_wrapper< MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr) const
Definition repositoryIf.ipp:1395
void PartialWriteDataPoint(const DataPointPath &path, const T &buffer, size_t first, size_t last, size_t d_first, std::optional< std::reference_wrapper< const MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Definition repositoryIf.ipp:1597
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:1526
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:1338
void WriteDataPoint(const DataPointPath &path, const T &buffer, std::optional< std::reference_wrapper< const MetaData > > metadata=std::nullopt, const CallbackType &callback=nullptr)
Definition repositoryIf.ipp:1471
void Wait()
Definition repositoryIf.cpp:342
bool WaitFor(const std::chrono::duration< Rep, Period > &timeout)
Definition repositoryIf.ipp:1671
bool WaitUntil(const std::chrono::time_point< Clk, Duration > &timeout)
Definition repositoryIf.ipp:1682
Definition repositoryIf.hpp:139
Definition repositoryIf.hpp:127
A structure to hold the arguments passed with one of the Add methods.
Definition repositoryIf.hpp:1212
void Add(const DataPointPath &path, T &buffer)
Adds a datapoint to the request for reading.
Definition repositoryIf.ipp:1786
Definition repositoryIf.hpp:119
A structure to hold the arguments passed with one of the Add methods.
Definition repositoryIf.hpp:1285
void Add(const DataPointPath &path, const T &buffer)
Adds a datapoint to the request for writing.
Definition repositoryIf.ipp:1840
Clock::time_point Timestamp
Definition repositoryIf.hpp:111
void WriteDataPoints(const T &... args)
Definition repositoryIf.ipp:1741
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1711
void ReadDataPoints(T &... args) const
Definition repositoryIf.ipp:1757
void CreateDataPoint(const DataPointPath &path)
Creates a new datapoint in the repository.
Definition repositoryIf.ipp:1696
void SetDataPoint(const DataPointPath &path, const T &value)
Sets a datapoint in the repository.
Definition repositoryIf.ipp:1720
void WriteDataPoint(const DataPointPath &path, const T &buffer)
Writes a datapoint to the repository.
Definition repositoryIf.ipp:1734
BatchResponse SendRequest(const BatchRequest &request)
Definition repositoryIf.cpp:364
void ReadDataPoint(const DataPointPath &path, T &buffer) const
Reads a datapoint from the repository.
Definition repositoryIf.ipp:1727
std::function< void(const DataPointPath &)> CallbackType
Signature of the callback functions that can be registered with the repository requests.
Definition repositoryIf.hpp:114
RtcUInt64 GetNumOfElements(const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:130
Definition commandReplier.cpp:22
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
uint64_t RtcUInt64
Definition repositoryIf.hpp:61
uint8_t RtcUInt8
Definition repositoryIf.hpp:58
int64_t RtcInt64
Definition repositoryIf.hpp:57
float RtcFloat
Definition repositoryIf.hpp:62
std::string RtcString
Definition repositoryIf.hpp:64
int8_t RtcInt8
Definition repositoryIf.hpp:54
std::vector< T > RtcVector
Definition repositoryIf.hpp:45
uint32_t RtcUInt32
Definition repositoryIf.hpp:60
bool RtcBool
Definition repositoryIf.hpp:53
int16_t RtcInt16
Definition repositoryIf.hpp:55
RtcMatrix< RtcBool > RtcMatrixBool
Definition repositoryIf.hpp:78
uint16_t RtcUInt16
Definition repositoryIf.hpp:59
RtcVector< RtcBool > RtcVectorBool
Definition repositoryIf.hpp:66
int32_t RtcInt32
Definition repositoryIf.hpp:56
RtcVector< RtcUInt64 > RtcVectorUInt64
Definition repositoryIf.hpp:74
std::vector< std::byte > RtcBinary
Definition repositoryIf.hpp:65
double RtcDouble
Definition repositoryIf.hpp:63
Definition repositoryIf.ipp:36
gsl::span< const T > data
Definition repositoryIf.ipp:39
DataPointPath path
Definition repositoryIf.ipp:38
T ElementType
Definition repositoryIf.ipp:37
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:41
RepositoryIf::MetaData metadata
Definition repositoryIf.ipp:40
Definition repositoryIf.ipp:118
DataPointPath link_path
Definition repositoryIf.ipp:120
DataPointPath path
Definition repositoryIf.ipp:119
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:121
Definition repositoryIf.ipp:44
DataPointPath path
Definition repositoryIf.ipp:45
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:46
Definition repositoryIf.ipp:49
DataPointPath path
Definition repositoryIf.ipp:50
bool & result
Definition repositoryIf.ipp:51
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:52
Definition repositoryIf.ipp:55
bool recurse
Definition repositoryIf.ipp:57
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:59
std::pair< RepositoryIf::PathList, RepositoryIf::PathList > & result
Definition repositoryIf.ipp:58
DataPointPath path
Definition repositoryIf.ipp:56
Definition repositoryIf.ipp:86
DataPointPath path
Definition repositoryIf.ipp:88
gsl::span< T > data
Definition repositoryIf.ipp:89
T ElementType
Definition repositoryIf.ipp:87
RepositoryIf::MetaData input_metadata
Definition repositoryIf.ipp:90
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:93
std::optional< std::reference_wrapper< RepositoryIf::MetaData > > output_metadata
Definition repositoryIf.ipp:91
size_t offset
Definition repositoryIf.ipp:92
Definition repositoryIf.ipp:97
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:103
DataPointPath path
Definition repositoryIf.ipp:99
RepositoryIf::MetaData metadata
Definition repositoryIf.ipp:101
gsl::span< const T > data
Definition repositoryIf.ipp:100
size_t offset
Definition repositoryIf.ipp:102
T ElementType
Definition repositoryIf.ipp:98
Definition repositoryIf.ipp:63
T ElementType
Definition repositoryIf.ipp:64
std::function< gsl::span< T >(const RepositoryIf::MetaData &)> PrepareFunctionType
Definition repositoryIf.ipp:65
std::optional< std::reference_wrapper< RepositoryIf::MetaData > > metadata
Definition repositoryIf.ipp:72
PrepareFunctionType prepare_buffer
Definition repositoryIf.ipp:71
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:73
DataPointPath path
Definition repositoryIf.ipp:66
Definition repositoryIf.ipp:124
DataPointPath path
Definition repositoryIf.ipp:125
DataPointPath link_path
Definition repositoryIf.ipp:126
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:127
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:503
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:508
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:523
void TempBufferType
Definition repositoryIf.ipp:506
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:527
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:519
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:559
static gsl::span< ElementType > MakeSpan(BufferType &buffer)=delete
Span not constructable from a MatrixBuffer<bool> type.
boost::container::vector< bool > TempBufferType
Definition repositoryIf.ipp:543
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:568
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:540
static void CopyFromTempBuffer(BufferType &buffer, const std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)
Definition repositoryIf.ipp:577
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:545
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:595
void TempBufferType
Definition repositoryIf.ipp:593
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:606
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:614
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:590
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:610
void TempBufferType
Definition repositoryIf.ipp:813
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:831
std::remove_cv_t< T > ElementType
Definition repositoryIf.ipp:810
T[N][M] BufferType
Definition repositoryIf.ipp:809
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:815
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:836
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:826
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:760
T[N] BufferType
Definition repositoryIf.ipp:738
void TempBufferType
Definition repositoryIf.ipp:742
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:740
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:744
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:764
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:756
std::remove_cv_t< T > ElementType
Definition repositoryIf.ipp:739
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:423
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:403
void TempBufferType
Definition repositoryIf.ipp:405
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:427
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:402
boost::container::vector< T, A > BufferType
Definition repositoryIf.ipp:401
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:407
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:419
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:790
RtcString DataPointType
Definition repositoryIf.ipp:778
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:786
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:794
void TempBufferType
Definition repositoryIf.ipp:780
char ElementType
Definition repositoryIf.ipp:777
char[N] BufferType
Definition repositoryIf.ipp:776
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:782
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:461
void TempBufferType
Definition repositoryIf.ipp:443
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:445
gsl::span< T, N > BufferType
Definition repositoryIf.ipp:439
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:440
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:441
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:465
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:457
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:478
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:491
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:487
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:495
gsl::span< char, N > BufferType
Definition repositoryIf.ipp:477
void TempBufferType
Definition repositoryIf.ipp:481
RtcString DataPointType
Definition repositoryIf.ipp:479
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:483
std::array< T, N > BufferType
Definition repositoryIf.ipp:626
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:652
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:648
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:628
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:644
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:632
void TempBufferType
Definition repositoryIf.ipp:630
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:627
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:670
void TempBufferType
Definition repositoryIf.ipp:668
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:682
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:678
std::array< char, N > BufferType
Definition repositoryIf.ipp:664
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:665
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:674
RtcString DataPointType
Definition repositoryIf.ipp:666
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:711
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:700
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:723
std::remove_cv_t< T > ElementType
Definition repositoryIf.ipp:695
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:717
void TempBufferType
Definition repositoryIf.ipp:698
std::array< std::array< T, M >, N > BufferType
Definition repositoryIf.ipp:694
std::string BufferType
Definition repositoryIf.ipp:252
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:258
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:262
void TempBufferType
Definition repositoryIf.ipp:256
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:270
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:266
RtcString DataPointType
Definition repositoryIf.ipp:254
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:253
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:288
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:301
RtcString DataPointType
Definition repositoryIf.ipp:284
static gsl::span< ElementType > MakeSpan(BufferType &buffer)=delete
It is not possible to create mutable span from a read-only string view.
void TempBufferType
Definition repositoryIf.ipp:286
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:297
std::string_view BufferType
Definition repositoryIf.ipp:282
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:283
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:314
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:319
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Definition repositoryIf.ipp:331
RtcVector< ElementType > DataPointType
Definition repositoryIf.ipp:315
std::vector< T, A > BufferType
Definition repositoryIf.ipp:313
void TempBufferType
Definition repositoryIf.ipp:317
static gsl::span< const ElementType > MakeSpan(const BufferType &buffer)
Definition repositoryIf.ipp:335
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:339
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:355
static void CopyFromTempBuffer(BufferType &buffer, const std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)
Definition repositoryIf.ipp:389
RtcVectorBool DataPointType
Definition repositoryIf.ipp:353
std::remove_cv_t< typename BufferType::value_type > ElementType
Definition repositoryIf.ipp:352
std::vector< bool, A > BufferType
Definition repositoryIf.ipp:351
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Definition repositoryIf.ipp:357
static void CopyToTempBuffer(const BufferType &buffer, std::shared_ptr< TempBufferType > &temp_buffer, size_t offset, size_t count)
Definition repositoryIf.ipp:380
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Definition repositoryIf.ipp:371
Definition repositoryIf.ipp:139
void TempBufferType
Defines the temporary buffer type (set to void if USES_TEMP_BUFFER is false).
Definition repositoryIf.ipp:153
static const bool USES_TEMP_BUFFER
Flag indicating if a temporary buffer is required to read/write this type.
Definition repositoryIf.ipp:150
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:187
std::remove_cv_t< T > ElementType
Defines the element type of the buffer object.
Definition repositoryIf.ipp:144
T DataPointType
Defines the corresponding data point type that type T is compatible with.
Definition repositoryIf.ipp:147
static gsl::span< ElementType > MakeSpan(BufferType &buffer)
Creates a span from a buffer object.
Definition repositoryIf.ipp:178
static RtcVectorUInt64 GetShape(const BufferType &buffer)
Returns the shape of a buffer object.
Definition repositoryIf.ipp:162
T BufferType
Defines the type of the buffer object that handles type T.
Definition repositoryIf.ipp:141
static bool ResizeBuffer(BufferType &buffer, const RtcVectorUInt64 &shape)
Tries to resize the buffer to the given shape.
Definition repositoryIf.ipp:204
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.
Definition repositoryIf.ipp:77
RepositoryIf::MetaData metadata
Definition repositoryIf.ipp:81
DataPointPath path
Definition repositoryIf.ipp:79
gsl::span< const T > data
Definition repositoryIf.ipp:80
T ElementType
Definition repositoryIf.ipp:78
RepositoryIf::CallbackType callback
Definition repositoryIf.ipp:82
Provides useful mechanisms to test various type traits.