Writer.h
Go to the documentation of this file.
1#pragma once
2
3#include <RobotAPI/interface/armem/server/WritingMemoryInterface.h>
5
7{
8
9 /**
10 * @brief Helps a memory client sending data to a memory.
11 *
12 * You can check whether the writer is ready using the bool operator:
13 * @code
14 * client::Writer writer(writingMemoryProxy);
15 * ...
16 * if (writer)
17 * {
18 * writer.commit(...);
19 * }
20 * @endcode
21 */
22 class Writer
23 {
24 public:
25 /**
26 * @brief Construct a memory writer.
27 * @param memory The memory proxy.
28 */
29 Writer(const Writer&) = default;
30 Writer(server::WritingMemoryInterfacePrx memory = nullptr);
31
32
33 data::AddSegmentResult addSegment(const std::string& coreSegmentName,
34 const std::string& providerSegmentName,
35 bool clearWhenExists = false) const;
36 data::AddSegmentResult addSegment(const MemoryID& providerSegmentID,
37 bool clearWhenExists = false) const;
38 data::AddSegmentResult addSegment(const std::pair<std::string, std::string>& names,
39 bool clearWhenExists = false) const;
40 data::AddSegmentResult addSegment(const data::AddSegmentInput& input) const;
41 data::AddSegmentsResult addSegments(const data::AddSegmentsInput& input) const;
42
43
44 /**
45 * @brief Writes a `Commit` to the memory.
46 */
47 CommitResult commit(const Commit& commit) const;
48 /// Commit a single entity update.
49 EntityUpdateResult commit(const EntityUpdate& update) const;
50
51 /**
52 * Commit a single entity update.
53 * @param origin Identifier of the instances source (e.g. LTM identifier)
54 */
55 EntityUpdateResult commit(const MemoryID& entityID,
56 const std::vector<aron::data::DictPtr>& instancesData,
57 Time referencedTime,
58 const std::string& origin) const;
59
60 // with bare-ice types
61 data::CommitResult commit(const data::Commit& commit) const;
62
63 /**
64 * @brief Clears the servers working memory (uses the WM-Clear feature)
65 */
66 void clearWorkingMemory();
67
68
69 void setWritingMemory(server::WritingMemoryInterfacePrx memory);
70
71 operator bool() const
72 {
73 return bool(memory);
74 }
75
76 private:
77 /// Sets `timeSent` on all entity updates and performs the commit,
78 data::CommitResult _commit(data::Commit& commit) const;
79
80
81 public:
82 server::WritingMemoryInterfacePrx memory;
83 };
84
85} // namespace armarx::armem::client
86
88{
89 std::ostream& operator<<(std::ostream& os, const AddSegmentInput& rhs);
90 std::ostream& operator<<(std::ostream& os, const AddSegmentsInput& rhs);
91 std::ostream& operator<<(std::ostream& os, const AddSegmentResult& rhs);
92 std::ostream& operator<<(std::ostream& os, const AddSegmentsResult& rhs);
93} // namespace armarx::armem::data
void clearWorkingMemory()
Clears the servers working memory (uses the WM-Clear feature)
Definition Writer.cpp:115
server::WritingMemoryInterfacePrx memory
Definition Writer.h:82
void setWritingMemory(server::WritingMemoryInterfacePrx memory)
Definition Writer.cpp:121
data::AddSegmentResult addSegment(const std::string &coreSegmentName, const std::string &providerSegmentName, bool clearWhenExists=false) const
Definition Writer.cpp:25
Writer(const Writer &)=default
Construct a memory writer.
CommitResult commit(const Commit &commit) const
Writes a Commit to the memory.
Definition Writer.cpp:68
data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input) const
Definition Writer.cpp:59
This file is part of ArmarX.
std::ostream & operator<<(std::ostream &os, const AddSegmentInput &rhs)
Definition Writer.cpp:180
armarx::core::time::DateTime Time
Result of a Commit.
Definition Commit.h:111
A bundle of updates to be sent to the memory.
Definition Commit.h:90
Result of an EntityUpdate.
Definition Commit.h:75
An update of an entity for a specific point in time.
Definition Commit.h:26