Skip to content
Snippets Groups Projects
Commit 01a33c25 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add ice conversions

parent a948a138
No related branches found
No related tags found
1 merge request!94ArMem Queries
......@@ -4,6 +4,7 @@
namespace armarx
{
/*
void armem::fromIce(long ice, Time& time)
{
time = Time::microSeconds(ice);
......@@ -13,6 +14,7 @@ namespace armarx
{
ice = time.toMicroSeconds();
}
*/
void armem::fromIce(const data::Commit& ice, Commit& commit)
......@@ -98,3 +100,4 @@ namespace armarx
......@@ -7,11 +7,25 @@
#include "Commit.h"
namespace IceUtil
{
// Define in original namespace to allow ADL.
inline void fromIce(long ice, Time& time)
{
time = Time::microSeconds(ice);
}
inline void toIce(long& ice, const Time& time)
{
ice = time.toMicroSeconds();
}
}
namespace armarx::armem
{
void fromIce(long ice, Time& time);
void toIce(long& ice, const Time& time);
// void fromIce(long ice, Time& time);
// void toIce(long& ice, const Time& time);
void fromIce(const data::Commit& ice, Commit& commit);
......@@ -28,6 +42,12 @@ namespace armarx::armem
void toIce(data::EntityUpdateResult& ice, const EntityUpdateResult& result);
template <class T>
void toIce(T& ice, const T& cpp)
{
ice = cpp;
}
template <class IceT, class CppT>
IceT toIce(const CppT& cpp)
{
......@@ -68,4 +88,24 @@ namespace armarx::armem
return ices;
}
template <class IceKeyT, class IceValueT, class CppKeyT, class CppValueT>
void toIce(std::map<IceKeyT, IceValueT>& iceMap,
const std::map<CppKeyT, CppValueT>& cppMap)
{
iceMap.clear();
for (const auto& [key, value] : cppMap)
{
iceMap.emplace(toIce<IceKeyT>(key), toIce<IceValueT>(value));
}
}
template <class IceKeyT, class IceValueT, class CppKeyT, class CppValueT>
std::map<IceKeyT, IceValueT> toIce(const std::map<CppKeyT, CppValueT>& cppMap)
{
std::map<IceKeyT, IceValueT> iceMap;
toIce(iceMap, cppMap);
return iceMap;
}
}
......@@ -3,10 +3,10 @@
#include "../core/ice_conversions.h"
namespace armarx::armem
namespace armarx
{
void toIce(data::EntityMetadata& ice, const EntityMetadata& metadata)
void armem::toIce(data::EntityMetadata& ice, const EntityMetadata& metadata)
{
ice.confidence = metadata.confidence;
toIce(ice.timeArrivedMicroSeconds, metadata.timeArrived);
......@@ -14,22 +14,43 @@ namespace armarx::armem
toIce(ice.timeSentMicroSeconds, metadata.timeSent);
}
void toIce(data::EntityData& ice, const EntityData& data)
void armem::toIce(data::EntityData& ice, const EntityData& data)
{
ice.data = data.data;
ice.index = data.index;
toIce(ice.metadata, data.metadata);
}
void toIce(data::EntitySnapshot& ice, const EntitySnapshot& snapshot)
void armem::toIce(data::EntitySnapshot& ice, const EntitySnapshot& snapshot)
{
toIce(ice.timeMicroSeconds, snapshot.time);
toIce(ice.instances, snapshot.instances);
}
void toIce(data::Entity& ice, const Entity& entity)
void armem::toIce(data::Entity& ice, const Entity& entity)
{
ice.name = entity.name;
toIce(ice.history, entity.history);
}
void armem::toIce(data::ProviderSegment& ice, const ProviderSegment& providerSegment)
{
ice.name = providerSegment.name;
toIce(ice.entities, providerSegment.entities);
}
void armem::toIce(data::CoreSegment& ice, const CoreSegment& coreSegment)
{
ice.name = coreSegment.name;
toIce(ice.providerSegments, coreSegment.providerSegments);
}
void armem::toIce(data::Memory& ice, const Memory& memory)
{
ice.name = memory.name;
toIce(ice.coreSegments, memory.coreSegments);
}
}
......@@ -8,11 +8,14 @@
namespace armarx::armem
{
// ice conversions
void toIce(data::EntityMetadata& ice, const EntityMetadata& metadata);
void toIce(data::EntityData& ice, const EntityData& data);
void toIce(data::EntitySnapshot& ice, const EntitySnapshot& snapshot);
void toIce(data::Entity& ice, const Entity& entity);
void toIce(data::ProviderSegment& ice, const ProviderSegment& providerSegment);
void toIce(data::CoreSegment& ice, const CoreSegment& coreSegment);
void toIce(data::Memory& ice, const Memory& memory);
}
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