MemorySubscriber.cpp
Go to the documentation of this file.
1#include "MemorySubscriber.h"
2
3#include <string>
4#include <vector>
5
8
12
14
16{
17
18 MemorySubscriber::MemorySubscriber(const std::string& providerSegmentName,
20 providerSegmentName(providerSegmentName), memoryNameSystem(mns)
21 {
22 memoryReader = memoryNameSystem.getReader(
24
25 const armem::MemoryID subscriptionID =
29 .withProviderSegmentName(providerSegmentName);
30
31 ARMARX_INFO << "Subscribing to gaze target status updates under "
32 << QUOTED(subscriptionID.str()) << ".";
33
34 subscriptionHandle =
35 memoryNameSystem.subscribe(subscriptionID, this, &MemorySubscriber::onEntityUpdate);
36 }
37
39
40 void
41 MemorySubscriber::onEntityUpdate(const std::vector<armem::MemoryID>& snapshotIDs)
42 {
43 const armem::client::QueryResult result = memoryReader.queryMemoryIDs(snapshotIDs);
44
45 if (not result.success)
46 {
48 << "Failed to look up gaze target status updates: "
49 << result.errorMessage;
50 return;
51 }
52
53 handleMemory(result.memory);
54 }
55
56} // namespace armarx::view_selection::client
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition Logging.cpp:75
#define QUOTED(x)
MemoryID withProviderSegmentName(const std::string &name) const
Definition MemoryID.cpp:417
MemoryID withCoreSegmentName(const std::string &name) const
Definition MemoryID.cpp:409
MemoryID withMemoryName(const std::string &name) const
Definition MemoryID.cpp:401
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Definition MemoryID.cpp:102
The memory name system (MNS) client.
QueryResult queryMemoryIDs(const std::vector< MemoryID > &ids, armem::query::DataMode dataMode=armem::query::DataMode::WithData) const
Query a specific set of memory IDs.
Definition Reader.cpp:374
void handleMemory(const armem::wm::Memory &memory)
Dispatches every GazeTargetStatus instance found, oldest first.
MemorySubscriber(const std::string &providerSegmentName, armem::client::MemoryNameSystem &mns)
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:179
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:191
const std::string GazeTargetStatusCoreSegmentName
Lifecycle of the requests in GazeTarget.
Definition constants.h:35
Result of a QueryInput.
Definition Query.h:51
wm::Memory memory
The slice of the memory that matched the query.
Definition Query.h:58