ice_conversions.cpp
Go to the documentation of this file.
1 #include "ice_conversions.h"
2 
5 
7 
8 #include <RobotAPI/interface/armem/actions.h>
9 #include <RobotAPI/interface/armem/commit.h>
10 #include <RobotAPI/interface/armem/memory.h>
11 
12 #include "actions.h"
13 #include "Commit.h"
14 #include "MemoryID.h"
15 #include "Time.h"
16 
17 
18 namespace armarx
19 {
20 
21  void armem::toIce(data::MemoryID& ice, const MemoryID& id)
22  {
23  ice.memoryName = id.memoryName;
24  ice.coreSegmentName = id.coreSegmentName;
25  ice.providerSegmentName = id.providerSegmentName;
26  ice.entityName = id.entityName;
27  toIce(ice.timestamp, id.timestamp);
28  ice.instanceIndex = id.instanceIndex;
29  }
30 
31  void armem::fromIce(const data::MemoryID& ice, MemoryID& id)
32  {
33  id.memoryName = ice.memoryName;
34  id.coreSegmentName = ice.coreSegmentName;
35  id.providerSegmentName = ice.providerSegmentName;
36  id.entityName = ice.entityName;
37  fromIce(ice.timestamp, id.timestamp);
38  id.instanceIndex = ice.instanceIndex;
39  }
40 
41  void armem::fromIce(const data::Commit& ice, Commit& commit)
42  {
43  commit.updates.clear();
44  for (const auto& ice_update : ice.updates)
45  {
46  EntityUpdate& update = commit.updates.emplace_back();
47  fromIce(ice_update, update);
48  }
49  }
50 
51  void armem::toIce(data::Commit& ice, const Commit& commit)
52  {
53  ice.updates.clear();
54  for (const auto& update : commit.updates)
55  {
56  data::EntityUpdate& ice_update = ice.updates.emplace_back();
57  toIce(ice_update, update);
58  }
59  }
60 
61  void armem::fromIce(const data::CommitResult& ice, CommitResult& result)
62  {
63  result.results.clear();
64  for (const auto& ice_res : ice.results)
65  {
66  EntityUpdateResult& res = result.results.emplace_back();
67  fromIce(ice_res, res);
68  }
69  }
70 
71  void armem::toIce(data::CommitResult& ice, const CommitResult& result)
72  {
73  ice.results.clear();
74  for (const auto& res : result.results)
75  {
76  data::EntityUpdateResult& ice_res = ice.results.emplace_back();
77  toIce(ice_res, res);
78  }
79  }
80 
81  void armem::fromIce(const data::EntityUpdate& ice, EntityUpdate& update)
82  {
83  fromIce(ice.entityID, update.entityID);
84 
85  update.instancesData.clear();
86  update.instancesData.reserve(ice.instancesData.size());
87  std::transform(ice.instancesData.begin(), ice.instancesData.end(), std::back_inserter(update.instancesData),
89 
90  fromIce(ice.referencedTime, update.referencedTime);
91 
92  update.confidence = ice.confidence;
93  fromIce(ice.timeSent, update.sentTime);
94  }
95 
96  void armem::toIce(data::EntityUpdate& ice, const EntityUpdate& update)
97  {
98  toIce(ice.entityID, update.entityID);
99 
100  ice.instancesData.clear();
101  ice.instancesData.reserve(update.instancesData.size());
102  std::transform(update.instancesData.begin(), update.instancesData.end(), std::back_inserter(ice.instancesData),
104 
105  toIce(ice.referencedTime, update.referencedTime);
106 
107  ice.confidence = update.confidence;
108  toIce(ice.timeSent, update.sentTime);
109  }
110 
111  void armem::fromIce(const data::EntityUpdateResult& ice, EntityUpdateResult& result)
112  {
113  result.success = ice.success;
114  fromIce(ice.snapshotID, result.snapshotID);
115  fromIce(ice.timeArrived, result.arrivedTime);
116  result.errorMessage = ice.errorMessage;
117  }
118 
119  void armem::toIce(data::EntityUpdateResult& ice, const EntityUpdateResult& result)
120  {
121  ice.success = result.success;
122  toIce(ice.snapshotID, result.snapshotID);
123  toIce(ice.timeArrived, result.arrivedTime);
124  ice.errorMessage = result.errorMessage;
125  }
126 
127  void armem::fromIce(const data::Commit& ice, Commit& commit, Time timeArrived)
128  {
129  commit.updates.clear();
130  for (const auto& ice_update : ice.updates)
131  {
132  EntityUpdate& update = commit.updates.emplace_back(EntityUpdate());
133  fromIce(ice_update, update, timeArrived);
134  }
135  }
136 
137  void armem::fromIce(const data::EntityUpdate& ice, EntityUpdate& update, Time timeArrived)
138  {
139  fromIce(ice, update);
140  update.arrivedTime = timeArrived;
141  }
142 
144  {
145  menu = actions::Menu::fromIce(ice);
146  }
147 
149  {
150  ice = menu.toIce();
151  }
152 }
153 
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
armarx::armem::actions::Menu::toIce
data::MenuPtr toIce() const
Definition: actions.cpp:92
armarx::armem::EntityUpdateResult
Result of an EntityUpdate.
Definition: Commit.h:72
armarx::armem::EntityUpdateResult::arrivedTime
Time arrivedTime
Definition: Commit.h:77
MemoryID.h
armarx::armem::toIce
void toIce(data::MemoryID &ice, const MemoryID &id)
Definition: ice_conversions.cpp:21
ice_conversions.h
Dict.h
armarx::aron::data::Dict::FromAronDictDTO
static PointerType FromAronDictDTO(const data::dto::DictPtr &aron)
Definition: Dict.cpp:129
armarx::armem::Commit::updates
std::vector< EntityUpdate > updates
The entity updates.
Definition: Commit.h:97
IceInternal::Handle
Definition: forward_declarations.h:8
visionx::armem::camera::fromIce
void fromIce(visionx::arondto::StereoCameraCalibration &aron, const visionx::StereoCalibration &ice)
Definition: ice_conversions.cpp:79
armarx::toIce
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:15
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
actions.h
armarx::armem::EntityUpdate
An update of an entity for a specific point in time.
Definition: Commit.h:27
armarx::armem::CommitResult
Result of a Commit.
Definition: Commit.h:110
armarx::aron::data::Dict::ToAronDictDTO
static data::dto::DictPtr ToAronDictDTO(const PointerType &navigator)
Definition: Dict.cpp:139
armarx::armem::fromIce
void fromIce(const data::MemoryID &ice, MemoryID &id)
Definition: ice_conversions.cpp:31
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
armarx::armem::EntityUpdateResult::snapshotID
MemoryID snapshotID
Definition: Commit.h:76
armarx::fromIce
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:26
Commit.h
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::CommitResult::results
std::vector< EntityUpdateResult > results
Definition: Commit.h:112
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:315
Time.h
armarx::armem::EntityUpdateResult::errorMessage
std::string errorMessage
Definition: Commit.h:79
ice_conversions_templates.h
armarx::armem::EntityUpdateResult::success
bool success
Definition: Commit.h:74
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::armem::actions::Menu
Definition: actions.h:51
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29