MemoryViewerModel.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2025, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package RobotStateComponent::
19 * @author Samet Soenmez (uewtt at student dot kit dot edu)
20 * @date 2025t
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#include "MemoryViewerModel.h"
26
28{
33
35 MemoryViewerModel::getSingleMemoryData(const std::string& memoryName)
36 {
37 auto it = _memoryData.find(memoryName);
38 if (it == _memoryData.end())
39 {
40 return nullptr;
41 }
42 else
43 {
44 return &it->second;
45 }
46 }
47
48 std::vector<std::string> MemoryViewerModel::getEnabledMemories() const
49 {
50 std::vector<std::string> enabled;
51
52 for(const auto& [name, state] : _activeMemoryStates) {
54 enabled.push_back(name);
55 }
56 }
57 return enabled;
58 }
59
61 {
62 armem::client::query::Builder queryBuilder(_dataMode);
63 queryBuilder.coreSegments().all().providerSegments().all().entities().all().snapshots(
64 _selector);
65
66 return queryBuilder.buildQueryInput();
67 }
68
69
70 std::map<std::string, armem::gui::ActiveMemoryState> MemoryViewerModel::activeMemoryStates()
71 {
72 return _activeMemoryStates;
73 }
74
80
82 {
83 return _debugObserver;
84 }
85
87 {
88 return _initialized.load();
89 }
90
92 {
93 return _connected.load();
94 }
95
96 std::map<std::string, armem::client::Reader>& MemoryViewerModel::memoryReaders()
97 {
98 return _memoryReaders;
99 }
100
101 std::map<std::string, armem::client::Writer>& MemoryViewerModel::memoryWriters()
102 {
103 return _memoryWriters;
104 }
105
106 std::map<std::string, armem::client::Reader> MemoryViewerModel::memoryReadersCopy() const
107 {
108 return _memoryReaders;
109 }
110 std::map<std::string, armem::client::Writer> MemoryViewerModel::memoryWritersCopy() const
111 {
112 return _memoryWriters;
113 }
114
115 std::map<std::string, armem::wm::Memory>& MemoryViewerModel::memoryData()
116 {
117 std::scoped_lock l(_memoryDataMutex);
118 return _memoryData;
119 }
120
121 std::map<std::string, armem::wm::Memory> MemoryViewerModel::memoryDataCopy() const
122 {
123 std::scoped_lock l(_memoryDataMutex);
124 return _memoryData;
125 }
126
128 {
129 return _recursionDepth;
130 }
131
133 {
134 return _dataMode;
135 }
136
138 {
139 return _dropRemovedMemories;
140 }
141
143 {
144 return _dropDisabledMemories;
145 }
146
148 {
149 return _selector;
150 }
151
152 void MemoryViewerModel::setMns(std::unique_ptr<armem::client::MemoryNameSystem> mns)
153 {
154 _mns = std::move(mns);
155 }
156
158 {
159 _debugObserver = observer;
160 }
161
163 {
164 _initialized.store(val);
165 }
166
168 {
169 _connected.store(val);
170 }
171
172 void MemoryViewerModel::setMemoryReaders(std::map<std::string, armem::client::Reader> readers)
173 {
174 _memoryReaders = std::move(readers);
175 }
176
177 void MemoryViewerModel::setMemoryWriters(std::map<std::string, armem::client::Writer> writers)
178 {
179 _memoryWriters = std::move(writers);
180 }
181
182 void MemoryViewerModel::setMemoryData(std::map<std::string, armem::wm::Memory> data)
183 {
184 std::scoped_lock l(_memoryDataMutex);
185 _memoryData = std::move(data);
186 }
187
188 void MemoryViewerModel::setActiveMemoryStates(std::map<std::string, armem::gui::ActiveMemoryState> states)
189 {
190 _activeMemoryStates = std::move(states);
191 }
192
194 {
195 _recursionDepth = value;
196 }
197
202
204 {
205 _dropRemovedMemories = val;
206 }
207
209 {
210 _dropDisabledMemories = val;
211 }
212
217
218
219}
The memory name system (MNS) client.
The query::Builder class provides a fluent-style specification of hierarchical queries.
Definition Builder.h:22
CoreSegmentSelector & coreSegments()
Start specifying core segments.
Definition Builder.cpp:42
ProviderSegmentSelector & providerSegments()
Start specifying provider segments.
SnapshotSelector & snapshots()
Start specifying entity snapshots.
Definition selectors.cpp:92
EntitySelector & entities()
Start specifying entities.
ProviderSegmentSelector & all() override
std::map< std::string, armem::client::Writer > memoryWritersCopy() const
armem::client::QueryInput queryInput() const
void setMemoryWriters(std::map< std::string, armem::client::Writer > writers)
const armem::wm::Memory * getSingleMemoryData(const std::string &memoryName)
std::map< std::string, armem::gui::ActiveMemoryState > activeMemoryStates()
std::vector< std::string > getEnabledMemories() const
void setMns(std::unique_ptr< armem::client::MemoryNameSystem > mns)
client::query::SnapshotSelector selector() const
void setSelector(client::query::SnapshotSelector selector)
void setMemoryReaders(std::map< std::string, armem::client::Reader > readers)
void setMemoryData(std::map< std::string, armem::wm::Memory > data)
std::map< std::string, armem::wm::Memory > & memoryData()
std::map< std::string, armem::client::Reader > & memoryReaders()
std::map< std::string, armem::client::Reader > memoryReadersCopy() const
void setDebugObserver(const DebugObserverInterfacePrx &observer)
std::map< std::string, armem::client::Writer > & memoryWriters()
void setActiveMemoryStates(std::map< std::string, armem::gui::ActiveMemoryState >)
void setDataMode(armem::query::DataMode dataMode)
armem::client::MemoryNameSystem & mns()
std::map< std::string, armem::wm::Memory > memoryDataCopy() const
Client-side working memory.
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
A query for parts of a memory.
Definition Query.h:24