EntityBase.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <string>
5
6#include <SimoxUtility/algorithm/get_map_keys_values.h>
7
10
13
14#include "EntitySnapshotBase.h"
19
20namespace armarx::armem::base
21{
22
23 /**
24 * @brief An entity over a period of time.
25 *
26 * An entity should be a physical thing or abstract concept existing
27 * (and potentially evolving) over time.
28 *
29 * Examples are:
30 * - objects (the green box)
31 * - agents (robot, human)
32 * - locations (frige, sink)
33 * - grasp affordances (general, or for a specific object)
34 * - images
35 * - point clouds
36 * - other sensory values
37 *
38 * At each point in time (`EntitySnapshot`), the entity can have a
39 * (potentially variable) number of instances (`EntityInstance`),
40 * each containing a single `AronData` object of a specific `AronType`.
41 */
42 template <class _EntitySnapshotT, class _Derived>
43 class EntityBase :
44 public detail::MemoryContainerBase<std::map<Time, _EntitySnapshotT>, _Derived>,
46 public detail::GetFindInstanceMixin<_Derived>,
47 public detail::GetLatestInstanceMixin<_Derived>,
48 public detail::GetLatestSnapshotMixin<_Derived>
49 {
51
52 public:
53 using typename Base::ContainerT;
54 using typename Base::DerivedT;
55
56 using EntitySnapshotT = _EntitySnapshotT;
57 using EntityInstanceT = typename EntitySnapshotT::EntityInstanceT;
58
60
62 {
65 std::vector<EntitySnapshotT> removedSnapshots;
66 std::vector<EntitySnapshotT> updatedSnapshots;
67
68 UpdateResult() = default;
69 };
70
71 public:
73 {
74 }
75
76 explicit EntityBase(const std::string& name, const MemoryID& parentID = {}) :
77 EntityBase(parentID.withEntityName(name))
78 {
79 }
80
81 explicit EntityBase(const MemoryID& id) : Base(id)
82 {
83 }
84
85 EntityBase(const EntityBase& other) = default;
86 EntityBase(EntityBase&& other) = default;
87 EntityBase& operator=(const EntityBase& other) = default;
88 EntityBase& operator=(EntityBase&& other) = default;
89
90 // READING
91
92 // Get key
93 inline std::string&
95 {
96 return this->id().entityName;
97 }
98
99 inline const std::string&
100 name() const
101 {
102 return this->id().entityName;
103 }
104
105 /// Indicate whether the entity has any snapshots.
106 bool
108 {
109 return not this->empty();
110 }
111
112 // Has child with key
113 /// Indicate whether a snapshot at the given time exists.
114 bool
115 hasSnapshot(const Time& time) const
116 {
117 return this->findSnapshot(time) != nullptr;
118 }
119
120 // Has child with MemoryID
121 /// Indicate whether a snapshot with the given ID exists.
122 bool
123 hasSnapshot(const MemoryID& snapshotID) const
124 {
125 return this->findSnapshot(snapshotID) != nullptr;
126 }
127
128 // Find child via key
131 {
133 }
134
135 const EntitySnapshotT*
137 {
139 }
140
141 // Get child via key
142 /**
143 * @brief Get a snapshot.
144 * @param time The time.
145 * @return The snapshot, if it exists.
146 *
147 * @throws `armem::error::MissingEntry` If there is no such entry.
148 */
150 getSnapshot(const Time& time)
151 {
152 return detail::getChildByKey(time,
153 this->_container,
154 *this,
155 [](const Time& time)
156 { return toDateTimeMilliSeconds(time); });
157 }
158
159 const EntitySnapshotT&
160 getSnapshot(const Time& time) const
161 {
162 return detail::getChildByKey(time,
163 this->_container,
164 *this,
165 [](const Time& time)
166 { return toDateTimeMilliSeconds(time); });
167 }
168
169 // Find child via MemoryID
171 findSnapshot(const MemoryID& snapshotID)
172 {
173 detail::checkHasTimestamp(snapshotID);
174 return this->findSnapshot(snapshotID.timestamp);
175 }
176
177 const EntitySnapshotT*
178 findSnapshot(const MemoryID& snapshotID) const
179 {
180 detail::checkHasTimestamp(snapshotID);
181 return this->findSnapshot(snapshotID.timestamp);
182 }
183
184 // Get child via MemoryID
186 getSnapshot(const MemoryID& snapshotID)
187 {
188 detail::checkHasTimestamp(snapshotID);
189 return this->getSnapshot(snapshotID.timestamp);
190 }
191
192 const EntitySnapshotT&
193 getSnapshot(const MemoryID& snapshotID) const
194 {
195 detail::checkHasTimestamp(snapshotID);
196 return this->getSnapshot(snapshotID.timestamp);
197 }
198
199 // get/findInstance are provided by GetFindInstanceMixin
200
201
202 // More getter/finder for snapshots
203
204 /**
205 * @brief Get the latest timestamp.
206 * @throw `armem::error::EntityHistoryEmpty` If the history is empty.
207 */
208 Time
210 {
211 return this->getLatestSnapshot().time();
212 }
213
214 /**
215 * @brief Get the oldest timestamp.
216 * @throw `armem::error::EntityHistoryEmpty` If the history is empty.
217 */
218 Time
220 {
221 return this->getFirstSnapshot().time();
222 }
223
224 /**
225 * @brief Return the snapshot with the most recent timestamp.
226 * @return The latest snapshot or nullptr if the entity is empty.
227 */
230 {
231 return this->empty() ? nullptr : &this->_container.rbegin()->second;
232 }
233
234 const EntitySnapshotT*
236 {
237 return this->empty() ? nullptr : &this->_container.rbegin()->second;
238 }
239
240 /**
241 * @brief Return the snapshot with the least recent timestamp.
242 * @return The first snapshot or nullptr if the entity is empty.
243 */
246 {
247 return this->empty() ? nullptr : &this->_container.begin()->second;
248 }
249
250 const EntitySnapshotT*
252 {
253 return this->empty() ? nullptr : &this->_container.begin()->second;
254 }
255
256 /**
257 * @brief Return the snapshot with the least recent timestamp.
258 * @return The first snapshot.
259 * @throw `armem::error::EntityHistoryEmpty` If the history is empty.
260 */
263 {
264 return const_cast<EntitySnapshotT&>(
265 const_cast<const EntityBase*>(this)->getFirstSnapshot());
266 }
267
268 const EntitySnapshotT&
270 {
271 if (const EntitySnapshotT* snapshot = this->findFirstSnapshot())
272 {
273 return *snapshot;
274 }
275 else
276 {
277 throw armem::error::EntityHistoryEmpty(name(), "when getting the first snapshot.");
278 }
279 }
280
281 /**
282 * @brief Return the lastest snapshot before time.
283 * @param time The time.
284 * @return The latest snapshot < time or nullptr if none was found.
285 */
286 const EntitySnapshotT*
288 {
289 if (this->empty())
290 {
291 return nullptr;
292 }
293
294 // We want the rightmost element < time
295 // lower_bound() gives us the the leftmost >= time, which is probably the right neighbour
296 typename ContainerT::const_iterator greaterEq = this->_container.lower_bound(time);
297 // Special cases:
298 // refIt = begin() => no element < time
299 if (greaterEq == this->_container.begin())
300 {
301 return nullptr;
302 }
303
304 // end(): No element >= time, we can still have one < time (rbegin()) => std::prev(end())
305 // empty has been checked above
306
307 // std::prev of end() is ok
308 typename ContainerT::const_iterator less = std::prev(greaterEq);
309
310 // we return the element before if possible
311 return &less->second;
312 }
313
314 /**
315 * @brief Return the latest snapshot before or at time.
316 * @param time The time.
317 * @return The latest snapshot <= time or nullptr if none was found.
318 */
319 const EntitySnapshotT*
321 {
323 }
324
325 /**
326 * @brief Return first snapshot after or at time.
327 * @param time The time.
328 * @return The first snapshot >= time or nullptr if none was found.
329 */
330 const EntitySnapshotT*
332 {
333 // We want the leftmost element >= time.
334 // That's lower bound.
335 typename ContainerT::const_iterator greaterEq = this->_container.lower_bound(time);
336
337 if (greaterEq == this->_container.end())
338 {
339 return nullptr;
340 }
341 return &greaterEq->second;
342 }
343
344 /**
345 * @brief Return first snapshot after time.
346 * @param time The time.
347 * @return The first snapshot > time or nullptr if none was found.
348 */
349 const EntitySnapshotT*
350 findFirstSnapshotAfter(const Time& time) const
351 {
353 }
354
355 auto*
356 findLatestInstance(int instanceIndex = 0)
357 {
358 auto* snapshot = this->findLatestSnapshot();
359 return snapshot ? snapshot->findInstance(instanceIndex) : nullptr;
360 }
361
362 const auto*
363 findLatestInstance(int instanceIndex = 0) const
364 {
365 auto* snapshot = this->findLatestSnapshot();
366 return snapshot ? snapshot->findInstance(instanceIndex) : nullptr;
367 }
368
369
370#if 0 // Do not offer this yet.
371 auto* findLatestInstanceData(int instanceIndex = 0)
372 {
373 auto* instance = this->findLatestInstance(instanceIndex);
374 return instance ? &instance->data() : nullptr;
375 }
376 const auto* findLatestInstanceData(int instanceIndex = 0) const
377 {
378 auto* instance = this->findLatestInstance(instanceIndex);
379 return instance ? &instance->data() : nullptr;
380 }
381#endif
382
383
384 // ITERATION
385
386 /**
387 * @param func Function like: bool process(EntitySnapshotT& snapshot)
388 */
389 template <class SnapshotFunctionT>
390 bool
391 forEachSnapshot(SnapshotFunctionT&& func)
392 {
393 return this->forEachChild(func);
394 }
395
396 /**
397 * @param func Function like void process(const EntitySnapshotT& snapshot)
398 */
399 template <class SnapshotFunctionT>
400 bool
401 forEachSnapshot(SnapshotFunctionT&& func) const
402 {
403 return this->forEachChild(func);
404 }
405
406 /**
407 * @param func Function like: bool process(EntitySnapshotT& snapshot)
408 */
409 template <class SnapshotFunctionT>
410 bool
411 forEachSnapshotIn(const MemoryID& id, SnapshotFunctionT&& func)
412 {
413 return this->forEachChild(func);
414 }
415
416 /**
417 * @param func Function like void process(const EntitySnapshotT& snapshot)
418 */
419 template <class SnapshotFunctionT>
420 bool
421 forEachSnapshotIn(const MemoryID& id, SnapshotFunctionT&& func) const
422 {
423 if (id.hasTimestamp())
424 {
425 if (const auto* child = findSnapshot(id.timestamp))
426 {
427 child->forEachChild(func);
428 }
429 }
430 return this->forEachChild(func);
431 }
432
433 // forEachInstance() is provided by ForEachEntityInstanceMixin.
434
435
436 /**
437 * @brief Return all snapshots before (excluding) time.
438 * @param time The time.
439 * @return The latest snapshots.
440 */
441 template <class FunctionT>
442 void
443 forEachSnapshotBefore(const Time& time, FunctionT&& func) const
444 {
445 for (const auto& [timestamp, snapshot] : this->_container)
446 {
447 if (timestamp >= time)
448 {
449 break;
450 }
451 if (not call(func, snapshot))
452 {
453 break;
454 }
455 }
456 }
457
458 /**
459 * @brief Iterate over all snapshots before (excluding) time in reverse order (newest first).
460 * @param time The time.
461 * @param func Function taking (const EntitySnapshotT&) and returning bool (false to stop).
462 */
463 template <class FunctionT>
464 void
465 forEachSnapshotBeforeReverse(const Time& time, FunctionT&& func) const
466 {
467 if (this->_container.empty())
468 {
469 return;
470 }
471
472 // lower_bound gives us the first element >= time
473 auto it = this->_container.lower_bound(time);
474
475 // If we're at the beginning, nothing is before time
476 if (it == this->_container.begin())
477 {
478 return;
479 }
480
481 // Move to the first element < time
482 --it;
483
484 // Iterate backwards from there
485 while (true)
486 {
487 if (not call(func, it->second))
488 {
489 break;
490 }
491 if (it == this->_container.begin())
492 {
493 break;
494 }
495 --it;
496 }
497 }
498
499 /**
500 * @brief Return all snapshots before or at time.
501 * @param time The time.
502 * @return The latest snapshots.
503 */
504 template <class FunctionT>
505 void
506 forEachSnapshotBeforeOrAt(const Time& time, FunctionT&& func) const
507 {
508 getSnapshotsBefore(time + Duration::MicroSeconds(1), func);
509 }
510
511 /**
512 * @brief Return all snapshots between, including, min and max.
513 * @param min The lowest time to include.
514 * @param min The highest time to include.
515 * @return The snapshots in [min, max].
516 */
517 template <class FunctionT>
518 void
519 forEachSnapshotInTimeRange(const Time& min, const Time& max, FunctionT&& func) const
520 {
521 // Returns an iterator pointing to the first element that is not less than (i.e. greater or equal to) key.
522 auto begin = min.toMicroSecondsSinceEpoch() > 0 ? this->_container.lower_bound(min)
523 : this->_container.begin();
524 // Returns an iterator pointing to the first element that is *greater than* key.
525 auto end = max.toMicroSecondsSinceEpoch() > 0 ? this->_container.upper_bound(max)
526 : this->_container.end();
527
528 for (auto it = begin; it != end && it != this->_container.end(); ++it)
529 {
530 if (not call(func, it->second))
531 {
532 break;
533 }
534 }
535 }
536
537 /**
538 * @brief Return all snapshots from first to last index.
539 *
540 * Negative index are counted from the end, e.g.
541 * last == -1 results in getting all queries until the end.
542 *
543 * @param first The first index to include.
544 * @param first The last index to include.
545 * @return The snapshots in [first, last].
546 */
547 template <class FunctionT>
548 void
549 forEachSnapshotInIndexRange(long first, long last, FunctionT&& func) const
550 {
551 if (this->empty())
552 {
553 return;
554 }
555
556 const size_t first_ = detail::negativeIndexSemantics(first, this->size());
557 const size_t last_ = detail::negativeIndexSemantics(last, this->size());
558
559 if (first_ <= last_)
560 {
561 auto it = this->_container.begin();
562 std::advance(it, first_);
563
564 size_t num = last_ - first_ + 1; // +1 to make last inclusive
565 for (size_t i = 0; i < num; ++i, ++it)
566 {
567 if (not call(func, it->second))
568 {
569 break;
570 }
571 }
572 }
573 }
574
575 /**
576 * @param func Function like void process(EntityInstanceT& instance)>
577 */
578 template <class InstanceFunctionT>
579 bool
580 forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func)
581 {
583 func,
584 *this,
585 id.hasTimestamp(),
586 id.hasTimestamp() ? this->findSnapshot(id.timestamp)
587 : nullptr);
588 }
589
590 /**
591 * @param func Function like void process(EntityInstanceT& instance)>
592 */
593 template <class InstanceFunctionT>
594 bool
595 forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func) const
596 {
598 func,
599 *this,
600 id.hasTimestamp(),
601 id.hasTimestamp() ? this->findSnapshot(id.timestamp)
602 : nullptr);
603 }
604
605 // Get child keys
606 /// @brief Get all timestamps in the history.
607 std::vector<Time>
609 {
610 return simox::alg::get_keys(this->_container);
611 }
612
613 // MODIFICATION
614
615 /**
616 * @brief Add the given update to this entity's history.
617 * @param update The update.
618 * @return The snapshot ID of the update.
619 */
620 UpdateResult
622 {
623 this->_checkContainerName(update.entityID.entityName, this->name());
624 UpdateResult ret;
625
626 EntitySnapshotT* snapshot;
627
628 auto it = this->_container.find(update.referencedTime);
629 if (it == this->_container.end())
630 {
631 // Insert into history.
632 snapshot = &addSnapshot(update.referencedTime);
633 // ret.removedSnapshots = this->truncate();
635 }
636 else
637 {
638 snapshot = &it->second;
640 }
641 // Update entry.
642 snapshot->update(update);
643 ret.id = snapshot->id();
644
645 ret.updatedSnapshots = {*snapshot};
646
647 return ret;
648 }
649
650 template <class OtherDerivedT>
651 void
652 append(const OtherDerivedT& other)
653 {
654 other.forEachSnapshot(
655 [this](const auto& snapshot)
656 {
657 auto it = this->_container.find(snapshot.time());
658 if (it == this->_container.end())
659 {
660 EntitySnapshotT copy{snapshot};
661 copy.id() = this->id().withTimestamp(
662 snapshot.time()); // update id (e.g. memory name) if necessary
663 this->_container.emplace(snapshot.time(), copy);
664 }
665 // else: snapshot already exists
666 // We assume that a snapshot does not change, so ignore
667 return true;
668 });
669 }
670
671 /// Add a snapshot at the given time.
674 {
675 return this->addSnapshot(timestamp, EntitySnapshotT(timestamp));
676 }
677
678 /// Copy and insert a snapshot
681 {
682 return this->addSnapshot(snapshot.time(), EntitySnapshotT(snapshot));
683 }
684
685 /// Move and insert a snapshot
688 {
689 Time timestamp = snapshot.time(); // Copy before move.
690 return this->addSnapshot(timestamp, std::move(snapshot));
691 }
692
693 /// Insert a snapshot in-place.
694 template <class... Args>
696 addSnapshot(const Time& timestamp, Args... args)
697 {
698 auto it = this->_container.emplace_hint(this->_container.end(), timestamp, args...);
699 it->second.id() = this->id().withTimestamp(timestamp);
700 return it->second;
701 }
702
703 // MISC
704
705 bool
706 equalsDeep(const DerivedT& other) const
707 {
708 //std::cout << "Entity::equalsDeep" << std::endl;
709 if (this->size() != other.size())
710 {
711 return false;
712 }
713 for (const auto& [key, snapshot] : this->_container)
714 {
715 if (not other.hasSnapshot(key))
716 {
717 return false;
718 }
719 if (not snapshot.equalsDeep(other.getSnapshot(key)))
720 {
721 return false;
722 }
723 }
724 return true;
725 }
726
727 std::string
729 {
730 return this->id().entityName;
731 }
732
733 static std::string
735 {
736 return "entity";
737 }
738 };
739
740} // namespace armarx::armem::base
std::string timestamp()
std::string entityName
Definition MemoryID.h:53
MemoryID withTimestamp(Time time) const
Definition MemoryID.cpp:433
An entity over a period of time.
Definition EntityBase.h:49
std::vector< Time > getTimestamps() const
Get all timestamps in the history.
Definition EntityBase.h:608
bool hasSnapshots() const
Indicate whether the entity has any snapshots.
Definition EntityBase.h:107
void forEachSnapshotInTimeRange(const Time &min, const Time &max, FunctionT &&func) const
Return all snapshots between, including, min and max.
Definition EntityBase.h:519
EntityBase(EntityBase &&other)=default
bool forEachInstanceIn(const MemoryID &id, InstanceFunctionT &&func)
Definition EntityBase.h:580
void forEachSnapshotInIndexRange(long first, long last, FunctionT &&func) const
Return all snapshots from first to last index.
Definition EntityBase.h:549
EntityBase & operator=(const EntityBase &other)=default
const std::string & name() const
Definition EntityBase.h:100
const EntitySnapshotT * findSnapshot(const Time &timestamp) const
Definition EntityBase.h:136
EntitySnapshotT & getSnapshot(const MemoryID &snapshotID)
Definition EntityBase.h:186
const EntitySnapshotT & getSnapshot(const MemoryID &snapshotID) const
Definition EntityBase.h:193
EntitySnapshotT & getFirstSnapshot()
Return the snapshot with the least recent timestamp.
Definition EntityBase.h:262
EntitySnapshotT & addSnapshot(const Time &timestamp)
Add a snapshot at the given time.
Definition EntityBase.h:673
bool equalsDeep(const DerivedT &other) const
Definition EntityBase.h:706
EntitySnapshotT & addSnapshot(const EntitySnapshotT &snapshot)
Copy and insert a snapshot.
Definition EntityBase.h:680
bool forEachSnapshot(SnapshotFunctionT &&func)
Definition EntityBase.h:391
EntitySnapshotT & addSnapshot(const Time &timestamp, Args... args)
Insert a snapshot in-place.
Definition EntityBase.h:696
bool hasSnapshot(const MemoryID &snapshotID) const
Indicate whether a snapshot with the given ID exists.
Definition EntityBase.h:123
const EntitySnapshotT & getSnapshot(const Time &time) const
Definition EntityBase.h:160
EntitySnapshotT * findLatestSnapshot()
Return the snapshot with the most recent timestamp.
Definition EntityBase.h:229
Time getFirstTimestamp() const
Get the oldest timestamp.
Definition EntityBase.h:219
bool forEachSnapshot(SnapshotFunctionT &&func) const
Definition EntityBase.h:401
EntityBase(const MemoryID &id)
Definition EntityBase.h:81
bool forEachInstanceIn(const MemoryID &id, InstanceFunctionT &&func) const
Definition EntityBase.h:595
bool forEachSnapshotIn(const MemoryID &id, SnapshotFunctionT &&func) const
Definition EntityBase.h:421
Time getLatestTimestamp() const
Get the latest timestamp.
Definition EntityBase.h:209
const EntitySnapshotT * findFirstSnapshotAfter(const Time &time) const
Return first snapshot after time.
Definition EntityBase.h:350
const auto * findLatestInstance(int instanceIndex=0) const
Definition EntityBase.h:363
static std::string getLevelName()
Definition EntityBase.h:734
void forEachSnapshotBeforeOrAt(const Time &time, FunctionT &&func) const
Return all snapshots before or at time.
Definition EntityBase.h:506
void append(const OtherDerivedT &other)
Definition EntityBase.h:652
const EntitySnapshotT * findFirstSnapshotAfterOrAt(const Time &time) const
Return first snapshot after or at time.
Definition EntityBase.h:331
EntitySnapshotT & getSnapshot(const Time &time)
Get a snapshot.
Definition EntityBase.h:150
typename EntitySnapshotT::EntityInstanceT EntityInstanceT
Definition EntityBase.h:57
EntitySnapshotT * findSnapshot(const MemoryID &snapshotID)
Definition EntityBase.h:171
const EntitySnapshotT * findFirstSnapshot() const
Definition EntityBase.h:251
const EntitySnapshotT * findSnapshot(const MemoryID &snapshotID) const
Definition EntityBase.h:178
EntityBase(const EntityBase &other)=default
const EntitySnapshotT * findLatestSnapshotBeforeOrAt(const Time &time) const
Return the latest snapshot before or at time.
Definition EntityBase.h:320
EntityBase & operator=(EntityBase &&other)=default
EntitySnapshotT * findFirstSnapshot()
Return the snapshot with the least recent timestamp.
Definition EntityBase.h:245
bool hasSnapshot(const Time &time) const
Indicate whether a snapshot at the given time exists.
Definition EntityBase.h:115
EntitySnapshotT * findSnapshot(const Time &timestamp)
Definition EntityBase.h:130
_EntitySnapshotT EntitySnapshotT
Definition EntityBase.h:56
void forEachSnapshotBefore(const Time &time, FunctionT &&func) const
Return all snapshots before (excluding) time.
Definition EntityBase.h:443
bool forEachSnapshotIn(const MemoryID &id, SnapshotFunctionT &&func)
Definition EntityBase.h:411
void forEachSnapshotBeforeReverse(const Time &time, FunctionT &&func) const
Iterate over all snapshots before (excluding) time in reverse order (newest first).
Definition EntityBase.h:465
std::string getKeyString() const
Definition EntityBase.h:728
EntityBase(const std::string &name, const MemoryID &parentID={})
Definition EntityBase.h:76
EntitySnapshotT & addSnapshot(EntitySnapshotT &&snapshot)
Move and insert a snapshot.
Definition EntityBase.h:687
const EntitySnapshotT & getFirstSnapshot() const
Definition EntityBase.h:269
const EntitySnapshotT * findLatestSnapshot() const
Definition EntityBase.h:235
UpdateResult update(const EntityUpdate &update)
Add the given update to this entity's history.
Definition EntityBase.h:621
const EntitySnapshotT * findLatestSnapshotBefore(const Time &time) const
Return the lastest snapshot before time.
Definition EntityBase.h:287
auto * findLatestInstance(int instanceIndex=0)
Definition EntityBase.h:356
Provides default implmentations of MemoryContainer, as well as iterators (which requires a template).
void _checkContainerName(const std::string &gottenName, const std::string &actualName, bool emptyOk=true) const
Indicates that an entity's history was queried, but is empty.
Definition ArMemError.h:163
static Duration MicroSeconds(std::int64_t microSeconds)
Constructs a duration in microseconds.
Definition Duration.cpp:24
auto & getChildByKey(const KeyT &key, ContainerT &&container, const ParentT &owner, KeyStringFn &&keyStringFn)
Retrieve a child in a container by its key.
size_t negativeIndexSemantics(long index, size_t size)
bool forEachInstanceIn(const MemoryID &id, FunctionT &&func, ParentT &parent, bool single, ChildT *child)
void checkHasTimestamp(const MemoryID &snapshotID)
Throw armem::error::InvalidMemoryID if the given ID has no timestamp.
auto * findChildByKey(const KeyT &key, ContainerT &&container)
Find a child in a container by its key.
UpdateType
The type of an update.
Definition Commit.h:17
std::string toDateTimeMilliSeconds(const Time &time, int decimals=6)
Returns timeas e.g.
Definition Time.cpp:35
armarx::core::time::DateTime Time
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
An update of an entity for a specific point in time.
Definition Commit.h:26
MemoryID entityID
The entity's ID.
Definition Commit.h:28
std::vector< EntitySnapshotT > updatedSnapshots
Definition EntityBase.h:66
armarx::armem::UpdateType entityUpdateType
Definition EntityBase.h:63
std::vector< EntitySnapshotT > removedSnapshots
Definition EntityBase.h:65