Commit.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
9 
10 namespace armarx::armem
11 {
12 
13  /**
14  * @brief The type of an update
15  */
16  enum class UpdateType
17  {
20  };
21 
22  /**
23  * @brief An update of an entity for a specific point in time.
24  */
25  struct EntityUpdate
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 
99  EntityUpdate& add();
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
armarx::armem::CommitResult::allErrorMessages
std::vector< std::string > allErrorMessages() const
Definition: Commit.cpp:73
armarx::armem::EntityUpdateResult::operator<<
friend std::ostream & operator<<(std::ostream &os, const EntityUpdateResult &rhs)
Definition: Commit.cpp:22
armarx::armem::EntityUpdate::instancesData
std::vector< aron::data::DictPtr > instancesData
The entity data.
Definition: Commit.h:31
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
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::EntityUpdate::confidence
float confidence
An optional confidence, may be used for things like decay.
Definition: Commit.h:43
armarx::armem
Definition: LegacyRobotStateMemoryAdapter.cpp:32
armarx::armem::Commit::operator<<
friend std::ostream & operator<<(std::ostream &os, const Commit &rhs)
Definition: Commit.cpp:32
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::armem::Commit::append
void append(const Commit &c)
Definition: Commit.cpp:101
armarx::armem::CommitResult::operator<<
friend std::ostream & operator<<(std::ostream &os, const CommitResult &rhs)
Definition: Commit.cpp:48
armarx::armem::UpdateType::UpdatedExisting
@ UpdatedExisting
armarx::armem::Commit::updates
std::vector< EntityUpdate > updates
The entity updates.
Definition: Commit.h:97
armarx::armem::EntityUpdate::arrivedTime
Time arrivedTime
Time when this update arrived at the memory server.
Definition: Commit.h:60
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::UpdateType
UpdateType
The type of an update.
Definition: Commit.h:16
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
forward_declarations.h
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::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::EntityUpdate::referencedTime
Time referencedTime
Time when this entity update was created (e.g.
Definition: Commit.h:37
armarx::armem::Commit::add
EntityUpdate & add()
Definition: Commit.cpp:80
armarx::armem::CommitResult::results
std::vector< EntityUpdateResult > results
Definition: Commit.h:112
armarx::armem::UpdateType::InsertedNew
@ InsertedNew
Time.h
armarx::armem::EntityUpdateResult::errorMessage
std::string errorMessage
Definition: Commit.h:81
armarx::armem::EntityUpdate::origin
std::string origin
Used to define the source of the entity (e.g.
Definition: Commit.h:65
armarx::armem::EntityUpdate::entityID
MemoryID entityID
The entity's ID.
Definition: Commit.h:28
armarx::armem::EntityUpdateResult::success
bool success
Definition: Commit.h:76
armarx::armem::CommitResult::allSuccess
bool allSuccess() const
Definition: Commit.cpp:64
armarx::core::time::DateTime::Invalid
static DateTime Invalid()
Definition: DateTime.cpp:57
armarx::armem::EntityUpdate::sentTime
Time sentTime
Time when this update was sent to the memory server.
Definition: Commit.h:53
armarx::armem::EntityUpdate::operator<<
friend std::ostream & operator<<(std::ostream &os, const EntityUpdate &rhs)
Definition: Commit.cpp:13