Commit.h
Go to the documentation of this file.
1 #pragma once
2 
5 
7 
8 #include <memory>
9 #include <vector>
10 
11 
12 namespace armarx::armem
13 {
14 
15  /**
16  * @brief The type of an update
17  */
18  enum class UpdateType
19  {
22  };
23 
24  /**
25  * @brief An update of an entity for a specific point in time.
26  */
27  struct EntityUpdate
28  {
29  /// The entity's ID.
31 
32  /// The entity data.
33  std::vector<aron::data::DictPtr> instancesData;
34 
35  /**
36  * @brief Time when this entity update was created (e.g. time of image recording).
37  * This is the key of the entity's history.
38  */
40 
41 
42  // OPTIONAL
43 
44  /// An optional confidence, may be used for things like decay.
45  float confidence = 1.0;
46 
47 
48  // OPTIONAL
49 
50  /**
51  * @brief Time when this update was sent to the memory server.
52  *
53  * Set automatically when sending the commit.
54  */
56 
57  /**
58  * @brief Time when this update arrived at the memory server.
59  *
60  * Set by memory server on arrival.
61  */
63 
64 
65  friend std::ostream& operator<<(std::ostream& os, const EntityUpdate& rhs);
66  };
67 
68 
69  /**
70  * @brief Result of an `EntityUpdate`.
71  */
73  {
74  bool success = false;
75 
78 
79  std::string errorMessage;
80 
81  friend std::ostream& operator<<(std::ostream& os, const EntityUpdateResult& rhs);
82  };
83 
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 }
armarx::armem::CommitResult::allErrorMessages
std::vector< std::string > allErrorMessages() const
Definition: Commit.cpp:72
armarx::armem::EntityUpdateResult::operator<<
friend std::ostream & operator<<(std::ostream &os, const EntityUpdateResult &rhs)
Definition: Commit.cpp:23
armarx::armem::EntityUpdate::instancesData
std::vector< aron::data::DictPtr > instancesData
The entity data.
Definition: Commit.h:33
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:72
armarx::armem::EntityUpdateResult::arrivedTime
Time arrivedTime
Definition: Commit.h:77
MemoryID.h
armarx::armem::EntityUpdate::confidence
float confidence
An optional confidence, may be used for things like decay.
Definition: Commit.h:45
armarx::armem
Definition: LegacyRobotStateMemoryAdapter.cpp:31
armarx::armem::Commit::operator<<
friend std::ostream & operator<<(std::ostream &os, const Commit &rhs)
Definition: Commit.cpp:34
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::armem::Commit::append
void append(const Commit &c)
Definition: Commit.cpp:99
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:62
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::UpdateType
UpdateType
The type of an update.
Definition: Commit.h:18
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
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:67
armarx::armem::EntityUpdateResult::snapshotID
MemoryID snapshotID
Definition: Commit.h:76
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:39
armarx::armem::Commit::add
EntityUpdate & add()
Definition: Commit.cpp:81
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:79
armarx::armem::EntityUpdate::entityID
MemoryID entityID
The entity's ID.
Definition: Commit.h:30
armarx::armem::EntityUpdateResult::success
bool success
Definition: Commit.h:74
armarx::armem::CommitResult::allSuccess
bool allSuccess() const
Definition: Commit.cpp:64
armarx::core::time::DateTime::Invalid
static DateTime Invalid()
Definition: DateTime.cpp:60
armarx::armem::EntityUpdate::sentTime
Time sentTime
Time when this update was sent to the memory server.
Definition: Commit.h:55
armarx::armem::EntityUpdate::operator<<
friend std::ostream & operator<<(std::ostream &os, const EntityUpdate &rhs)
Definition: Commit.cpp:13