Skip to content
Snippets Groups Projects
Commit 533fdc09 authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Add RobotUnitDataStreamingReceiver::getAs interface

parent 91456581
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@
#pragma once
#include <mutex>
#include <type_traits>
#include <ArmarXCore/core/ManagedIceObject.h>
......@@ -79,6 +80,51 @@ namespace armarx
// *INDENT-ON*
}
template<class T>
static T getAs(const timestep_t& st, const entry_t& e)
{
using enum_t = RobotUnitDataStreaming::DataEntryType;
if constexpr(std::is_same_v<bool, T>)
{
ARMARX_CHECK_EQUAL(e.type, enum_t::NodeTypeBool);
return st.bools .at(e.index);
}
else if constexpr(std::is_same_v<Ice::Byte, T>)
{
ARMARX_CHECK_EQUAL(e.type, enum_t::NodeTypeByte);
return st.bytes .at(e.index);
}
else if constexpr(std::is_same_v<Ice::Short, T>)
{
ARMARX_CHECK_EQUAL(e.type, enum_t::NodeTypeShort);
return st.shorts .at(e.index);
}
else if constexpr(std::is_same_v<Ice::Int, T>)
{
ARMARX_CHECK_EQUAL(e.type, enum_t::NodeTypeInt);
return st.ints .at(e.index);
}
else if constexpr(std::is_same_v<Ice::Long, T>)
{
ARMARX_CHECK_EQUAL(e.type, enum_t::NodeTypeLong);
return st.longs .at(e.index);
}
else if constexpr(std::is_same_v<Ice::Float, T>)
{
ARMARX_CHECK_EQUAL(e.type, enum_t::NodeTypeFloat);
return st.floats .at(e.index);
}
else if constexpr(std::is_same_v<Ice::Double, T>)
{
ARMARX_CHECK_EQUAL(e.type, enum_t::NodeTypeDouble);
return st.doubles.at(e.index);
}
else
{
static_assert(!std::is_same_v<T, T>, "Type not supported!");
}
}
static void visitEntries(auto&& f, const timestep_t& st, const auto& cont)
{
for (const entry_t& e : cont)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment