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  friend std::ostream& operator<<(std::ostream& os, const EntityUpdate& rhs);
64  };
65 
66  /**
67  * @brief Result of an `EntityUpdate`.
68  */
70  {
71  bool success = false;
72 
75 
76  std::string errorMessage;
77 
78  friend std::ostream& operator<<(std::ostream& os, const EntityUpdateResult& rhs);
79  };
80 
81  /**
82  * @brief A bundle of updates to be sent to the memory.
83  */
84  struct Commit
85  {
86  /**
87  * @brief The entity updates.
88  *
89  * May contain updates of multiple entities at different
90  * points in time.
91  */
92  std::vector<EntityUpdate> updates;
93 
94  EntityUpdate& add();
96  void add(const std::vector<EntityUpdate>& updates);
97  void append(const Commit& c);
98 
99  friend std::ostream& operator<<(std::ostream& os, const Commit& rhs);
100  };
101 
102  /**
103  * @brief Result of a `Commit`.
104  */
106  {
107  std::vector<EntityUpdateResult> results;
108 
109  bool allSuccess() const;
110  std::vector<std::string> allErrorMessages() const;
111 
112  friend std::ostream& operator<<(std::ostream& os, const CommitResult& rhs);
113  };
114 
115 
116 } // 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:84
armarx::armem::EntityUpdateResult
Result of an EntityUpdate.
Definition: Commit.h:69
armarx::armem::EntityUpdateResult::arrivedTime
Time arrivedTime
Definition: Commit.h:74
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:92
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:105
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:73
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:107
armarx::armem::UpdateType::InsertedNew
@ InsertedNew
Time.h
armarx::armem::EntityUpdateResult::errorMessage
std::string errorMessage
Definition: Commit.h:76
armarx::armem::EntityUpdate::entityID
MemoryID entityID
The entity's ID.
Definition: Commit.h:28
armarx::armem::EntityUpdateResult::success
bool success
Definition: Commit.h:71
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