Commit.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
9
10namespace armarx::armem
11{
12
13 /**
14 * @brief The type of an update
15 */
21
22 /**
23 * @brief An update of an entity for a specific point in time.
24 */
26 {
27 /// The entity's ID.
29
30 /// The entity data.
31 std::vector<aron::data::DictPtr> instancesData;
32
33 /**
34 * @brief Time when this entity update was created (e.g. time of image recording).
35 * This is the key of the entity's history.
36 */
38
39
40 // OPTIONAL
41
42 /// An optional confidence, may be used for things like decay.
43 float confidence = 1.0;
44
45
46 // OPTIONAL
47
48 /**
49 * @brief Time when this update was sent to the memory server.
50 *
51 * Set automatically when sending the commit.
52 */
54
55 /**
56 * @brief Time when this update arrived at the memory server.
57 *
58 * Set by memory server on arrival.
59 */
61
62 /**
63 * Used to define the source of the entity (e.g. LTM identifier)
64 */
65 std::string origin = "undefined1";
66
67
68 friend std::ostream& operator<<(std::ostream& os, const EntityUpdate& rhs);
69 };
70
71 /**
72 * @brief Result of an `EntityUpdate`.
73 */
75 {
76 bool success = false;
77
80
81 std::string errorMessage;
82
83 friend std::ostream& operator<<(std::ostream& os, const EntityUpdateResult& rhs);
84 };
85
86 /**
87 * @brief A bundle of updates to be sent to the memory.
88 */
89 struct Commit
90 {
91 /**
92 * @brief The entity updates.
93 *
94 * May contain updates of multiple entities at different
95 * points in time.
96 */
97 std::vector<EntityUpdate> updates;
98
100 EntityUpdate& add(const EntityUpdate& update);
101 void add(const std::vector<EntityUpdate>& updates);
102 void append(const Commit& c);
103
104 friend std::ostream& operator<<(std::ostream& os, const Commit& rhs);
105 };
106
107 /**
108 * @brief Result of a `Commit`.
109 */
111 {
112 std::vector<EntityUpdateResult> results;
113
114 bool allSuccess() const;
115 std::vector<std::string> allErrorMessages() const;
116
117 friend std::ostream& operator<<(std::ostream& os, const CommitResult& rhs);
118 };
119
120
121} // namespace armarx::armem
constexpr T c
static DateTime Invalid()
Definition DateTime.cpp:57
UpdateType
The type of an update.
Definition Commit.h:17
armarx::core::time::DateTime Time
Result of a Commit.
Definition Commit.h:111
friend std::ostream & operator<<(std::ostream &os, const CommitResult &rhs)
Definition Commit.cpp:48
std::vector< std::string > allErrorMessages() const
Definition Commit.cpp:73
std::vector< EntityUpdateResult > results
Definition Commit.h:112
A bundle of updates to be sent to the memory.
Definition Commit.h:90
EntityUpdate & add()
Definition Commit.cpp:80
void append(const Commit &c)
Definition Commit.cpp:101
friend std::ostream & operator<<(std::ostream &os, const Commit &rhs)
Definition Commit.cpp:32
std::vector< EntityUpdate > updates
The entity updates.
Definition Commit.h:97
Result of an EntityUpdate.
Definition Commit.h:75
friend std::ostream & operator<<(std::ostream &os, const EntityUpdateResult &rhs)
Definition Commit.cpp:22
An update of an entity for a specific point in time.
Definition Commit.h:26
float confidence
An optional confidence, may be used for things like decay.
Definition Commit.h:43
MemoryID entityID
The entity's ID.
Definition Commit.h:28
Time arrivedTime
Time when this update arrived at the memory server.
Definition Commit.h:60
friend std::ostream & operator<<(std::ostream &os, const EntityUpdate &rhs)
Definition Commit.cpp:13
Time referencedTime
Time when this entity update was created (e.g.
Definition Commit.h:37
std::string origin
Used to define the source of the entity (e.g.
Definition Commit.h:65
std::vector< aron::data::DictPtr > instancesData
The entity data.
Definition Commit.h:31
Time sentTime
Time when this update was sent to the memory server.
Definition Commit.h:53