ice_conversions.cpp
Go to the documentation of this file.
1 #include "ice_conversions.h"
2 
5 
6 #include <RobotAPI/interface/armem/actions.h>
7 #include <RobotAPI/interface/armem/commit.h>
8 #include <RobotAPI/interface/armem/memory.h>
10 
11 #include "Commit.h"
12 #include "MemoryID.h"
13 #include "Time.h"
14 #include "actions.h"
15 
16 namespace armarx
17 {
18 
19  void
21  {
22  ice.memoryName = id.memoryName;
23  ice.coreSegmentName = id.coreSegmentName;
24  ice.providerSegmentName = id.providerSegmentName;
25  ice.entityName = id.entityName;
26  toIce(ice.timestamp, id.timestamp);
27  ice.instanceIndex = id.instanceIndex;
28  }
29 
30  void
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
42  armem::fromIce(const data::Commit& ice, Commit& commit)
43  {
44  commit.updates.clear();
45  for (const auto& ice_update : ice.updates)
46  {
47  EntityUpdate& update = commit.updates.emplace_back();
48  fromIce(ice_update, update);
49  }
50  }
51 
52  void
53  armem::toIce(data::Commit& ice, const Commit& commit)
54  {
55  ice.updates.clear();
56  for (const auto& update : commit.updates)
57  {
58  data::EntityUpdate& ice_update = ice.updates.emplace_back();
59  toIce(ice_update, update);
60  }
61  }
62 
63  void
64  armem::fromIce(const data::CommitResult& ice, CommitResult& result)
65  {
66  result.results.clear();
67  for (const auto& ice_res : ice.results)
68  {
69  EntityUpdateResult& res = result.results.emplace_back();
70  fromIce(ice_res, res);
71  }
72  }
73 
74  void
75  armem::toIce(data::CommitResult& ice, const CommitResult& result)
76  {
77  ice.results.clear();
78  for (const auto& res : result.results)
79  {
80  data::EntityUpdateResult& ice_res = ice.results.emplace_back();
81  toIce(ice_res, res);
82  }
83  }
84 
85  void
86  armem::fromIce(const data::EntityUpdate& ice, EntityUpdate& update)
87  {
88  fromIce(ice.entityID, update.entityID);
89 
90  update.instancesData.clear();
91  update.instancesData.reserve(ice.instancesData.size());
92  std::transform(ice.instancesData.begin(),
93  ice.instancesData.end(),
94  std::back_inserter(update.instancesData),
96 
97  fromIce(ice.referencedTime, update.referencedTime);
98 
99  update.confidence = ice.confidence;
100  fromIce(ice.timeSent, update.sentTime);
101  update.origin = ice.origin;
102  }
103 
104  void
105  armem::toIce(data::EntityUpdate& ice, const EntityUpdate& update)
106  {
107  toIce(ice.entityID, update.entityID);
108 
109  ice.instancesData.clear();
110  ice.instancesData.reserve(update.instancesData.size());
111  std::transform(update.instancesData.begin(),
112  update.instancesData.end(),
113  std::back_inserter(ice.instancesData),
115 
116  toIce(ice.referencedTime, update.referencedTime);
117 
118  ice.confidence = update.confidence;
119  toIce(ice.timeSent, update.sentTime);
120  ice.origin = update.origin;
121  }
122 
123  void
124  armem::fromIce(const data::EntityUpdateResult& ice, EntityUpdateResult& result)
125  {
126  result.success = ice.success;
127  fromIce(ice.snapshotID, result.snapshotID);
128  fromIce(ice.timeArrived, result.arrivedTime);
129  result.errorMessage = ice.errorMessage;
130  }
131 
132  void
133  armem::toIce(data::EntityUpdateResult& ice, const EntityUpdateResult& result)
134  {
135  ice.success = result.success;
136  toIce(ice.snapshotID, result.snapshotID);
137  toIce(ice.timeArrived, result.arrivedTime);
138  ice.errorMessage = result.errorMessage;
139  }
140 
141  void
142  armem::fromIce(const data::Commit& ice, Commit& commit, Time timeArrived)
143  {
144  commit.updates.clear();
145  for (const auto& ice_update : ice.updates)
146  {
147  EntityUpdate& update = commit.updates.emplace_back(EntityUpdate());
148  fromIce(ice_update, update, timeArrived);
149  }
150  }
151 
152  void
153  armem::fromIce(const data::EntityUpdate& ice, EntityUpdate& update, Time timeArrived)
154  {
155  fromIce(ice, update);
156  update.arrivedTime = timeArrived;
157  }
158 
159  void
161  {
162  menu = actions::Menu::fromIce(ice);
163  }
164 
165  void
167  {
168  ice = menu.toIce();
169  }
170 } // namespace armarx
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:90
armarx::armem::EntityUpdateResult
Result of an EntityUpdate.
Definition: Commit.h:74
armarx::armem::EntityUpdateResult::arrivedTime
Time arrivedTime
Definition: Commit.h:79
MemoryID.h
armarx::armem::toIce
void toIce(data::MemoryID &ice, const MemoryID &id)
Definition: ice_conversions.cpp:20
ice_conversions.h
Dict.h
armarx::view_selection::gaze_targets::fromIce
void fromIce(const dto::TargetPriority &dto, TargetPriority &bo)
Definition: ice_conversions.cpp:66
armarx::aron::data::Dict::FromAronDictDTO
static PointerType FromAronDictDTO(const data::dto::DictPtr &aron)
Definition: Dict.cpp:130
armarx::armem::Commit::updates
std::vector< EntityUpdate > updates
The entity updates.
Definition: Commit.h:97
IceInternal::Handle
Definition: forward_declarations.h:8
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:25
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:140
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:68
armarx::armem::EntityUpdateResult::snapshotID
MemoryID snapshotID
Definition: Commit.h:78
armarx::fromIce
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:27
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:351
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
Time.h
armarx::armem::EntityUpdateResult::errorMessage
std::string errorMessage
Definition: Commit.h:81
ice_conversions_templates.h
armarx::armem::EntityUpdateResult::success
bool success
Definition: Commit.h:76
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::armem::actions::Menu
Definition: actions.h:49
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:28