25 #include <boost/hana/for_each.hpp>
27 #include <SimoxUtility/meta/boost_hana.h>
28 #include <SimoxUtility/meta/enum/adapt_enum.h>
32 #include <ArmarXCore/interface/observers/ObserverInterface.h>
60 bool batchmode =
false) :
86 const std::string& datafieldName,
89 const std::string& datafieldName,
92 const std::string& datafieldName,
98 const std::string& datafieldName,
107 const std::string& datafieldName,
114 [[maybe_unused]]
static constexpr std::uint64_t IceIntTMax =
116 if constexpr (std::is_same_v<T, IceUtil::Time> ||
117 meta::TypeTemplateTraits::IsInstanceOfV<std::chrono::duration, T> ||
118 meta::TypeTemplateTraits::IsInstanceOfV<std::chrono::time_point, T>)
123 else if constexpr (std::is_unsigned_v<T> && !std::is_same_v<bool, T>)
126 if (_float_fallback_for_big_too_large_ints)
128 if (
value < IceIntTMax)
146 else if constexpr (simox::meta::has_hana_accessor_v<T>)
149 namespace hana = boost::hana;
150 static constexpr
auto accessors = hana::accessors<T>();
151 hana::for_each(accessors,
155 const auto varname = hana::to<char const*>(hana::first(e));
156 const auto elemName = datafieldName +
'_' + varname;
158 channelName, elemName, time, hana::second(e)(
value));
162 else if constexpr (simox::meta::is_enum_adapted_v<T>)
167 else if constexpr (std::is_same_v<char, T>)
180 template <
class T,
class... Ts>
183 const std::string& datafieldName,
184 const std::chrono::duration<Ts...> duration,
191 IceUtil::Time::microSeconds(
192 std::chrono::duration_cast<std::chrono::microseconds>(duration).count()),
196 template <
class T,
class... Ts>
199 const std::string& datafieldName,
200 const std::chrono::time_point<Ts...> timepoint,
205 channelName, datafieldName, timepoint.time_since_epoch(),
value);
209 const std::string& datafieldName,
213 template <
class... Ts>
216 const std::string& datafieldName,
217 const std::chrono::duration<Ts...> duration,
224 IceUtil::Time::microSeconds(
225 std::chrono::duration_cast<std::chrono::microseconds>(duration).count()),
229 template <
class... Ts>
232 const std::string& datafieldName,
233 const std::chrono::time_point<Ts...> timepoint,
238 channelName, datafieldName, timepoint.time_since_epoch(),
value);
242 const std::string& datafieldName,
246 template <
class... Ts>
249 const std::string& datafieldName,
250 const std::chrono::duration<Ts...> duration,
257 IceUtil::Time::microSeconds(
258 std::chrono::duration_cast<std::chrono::microseconds>(duration).count()),
262 template <
class... Ts>
265 const std::string& datafieldName,
266 const std::chrono::time_point<Ts...> timepoint,
271 channelName, datafieldName, timepoint.time_since_epoch(),
value);
288 const std::string& datafieldName)
const;
297 std::string _channelName;
299 bool _batchMode{
false};
300 mutable std::map<std::string, StringVariantBaseMap> _batch;
301 bool _float_fallback_for_big_too_large_ints =
true;