From fb4a3bfa4bfbfafeb1311e7fd0c6cdb5dbc8617d Mon Sep 17 00:00:00 2001 From: "fabian.peller-konrad@kit.edu" <fabian.peller-konrad@kit.edu> Date: Wed, 21 Apr 2021 12:13:11 +0200 Subject: [PATCH] fixes build issues with new memory --- .../ExampleMemoryClient.cpp | 20 +++--- .../RobotAPI/libraries/armem/client/Query.h | 2 +- .../RobotAPI/libraries/armem/client/Reader.h | 2 +- .../RobotAPI/libraries/armem/client/Writer.h | 2 +- .../armem/client/query/selectors.cpp | 2 +- .../libraries/armem/core/base/CoreSegment.h | 57 ++++++----------- .../libraries/armem/core/base/Entity.h | 45 +++++++------ .../armem/core/base/EntitySnapshot.h | 62 +++++++----------- .../libraries/armem/core/base/Memory.h | 58 ++++++----------- .../armem/core/base/ProviderSegment.h | 61 ++++++------------ .../armem/core/base/detail/MemoryContainer.h | 2 +- .../armem/core/ice_conversions_templates.h | 8 +-- .../armem/core/longtermMemory/CoreSegment.cpp | 8 +-- .../armem/core/longtermMemory/CoreSegment.h | 4 +- .../armem/core/longtermMemory/Entity.cpp | 4 +- .../core/longtermMemory/EntityInstance.cpp | 12 ++++ .../core/longtermMemory/EntityInstance.h | 5 +- .../core/longtermMemory/EntitySnapshot.cpp | 8 --- .../armem/core/longtermMemory/Memory.cpp | 4 +- .../armem/core/longtermMemory/Memory.h | 4 +- .../core/longtermMemory/ProviderSegment.cpp | 9 +-- .../armem/core/workingMemory/CoreSegment.cpp | 18 +++++- .../armem/core/workingMemory/CoreSegment.h | 9 ++- .../armem/core/workingMemory/Entity.cpp | 18 +++++- .../armem/core/workingMemory/Entity.h | 5 +- .../core/workingMemory/EntityInstance.cpp | 15 ++++- .../armem/core/workingMemory/EntityInstance.h | 5 +- .../core/workingMemory/EntitySnapshot.cpp | 20 ++++-- .../armem/core/workingMemory/EntitySnapshot.h | 5 +- .../armem/core/workingMemory/Memory.cpp | 18 +++++- .../armem/core/workingMemory/Memory.h | 9 ++- .../core/workingMemory/ProviderSegment.cpp | 18 +++++- .../core/workingMemory/ProviderSegment.h | 5 +- .../workingMemory/detail/MemoryContainer.h | 13 +++- .../core/workingMemory/ice_conversions.cpp | 52 ++++++++------- .../core/workingMemory/ice_conversions.h | 5 +- .../armem/server/MemoryRemoteGui.cpp | 38 +++++------ .../armem/server/MemoryToIceAdapter.cpp | 2 +- .../server/query_proc/BaseQueryProcessor.cpp | 2 +- .../query_proc/CoreSegmentQueryProcessor.cpp | 6 +- .../query_proc/EntityQueryProcessor.cpp | 12 ++-- .../query_proc/MemoryQueryProcessor.cpp | 6 +- .../ProviderSegmentQueryProcessor.cpp | 6 +- .../armem/test/ArMemIceConversionsTest.cpp | 21 ++++-- .../libraries/armem/test/ArMemLTMTest.cpp | 6 +- .../libraries/armem/test/ArMemMemoryTest.cpp | 64 +++++++++---------- .../armem/test/ArMemQueryBuilderTest.cpp | 2 +- .../libraries/armem/test/ArMemQueryTest.cpp | 28 ++++---- source/RobotAPI/libraries/armem/util/util.h | 12 ++-- .../libraries/armem_gui/memory/TreeWidget.cpp | 10 +-- .../TransformReader.cpp | 22 +++---- .../armem_robot_mapping/MappingDataReader.cpp | 4 +- 52 files changed, 444 insertions(+), 391 deletions(-) diff --git a/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp b/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp index 39e68a5ca..a8d5f925e 100644 --- a/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp +++ b/source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp @@ -30,7 +30,7 @@ #include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> #include <RobotAPI/libraries/armem/client/query/Builder.h> #include <RobotAPI/libraries/armem/client/query/query_fns.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> #include <RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.aron.generated.h> @@ -223,17 +223,17 @@ namespace armarx { armem::workingmemory::Memory& memory = qResult.memory; - ARMARX_CHECK_EQUAL(memory.coreSegments.size(), 1); - armem::workingmemory::CoreSegment& coreSeg = memory.coreSegments.begin()->second; + ARMARX_CHECK_EQUAL(memory.coreSegments().size(), 1); + armem::workingmemory::CoreSegment& coreSeg = memory.coreSegments().begin()->second; - ARMARX_CHECK_EQUAL(coreSeg.providerSegments.size(), 1); - armem::workingmemory::ProviderSegment& provSeg = coreSeg.providerSegments.begin()->second; + ARMARX_CHECK_EQUAL(coreSeg.providerSegments().size(), 1); + armem::workingmemory::ProviderSegment& provSeg = coreSeg.providerSegments().begin()->second; - ARMARX_CHECK_EQUAL(provSeg.entities.size(), 1); - armem::workingmemory::Entity& entity = provSeg.entities.begin()->second; + ARMARX_CHECK_EQUAL(provSeg.entities().size(), 1); + armem::workingmemory::Entity& entity = provSeg.entities().begin()->second; - ARMARX_CHECK_GREATER_EQUAL(entity.history.size(), 1); - armem::workingmemory::EntitySnapshot& snapshot = entity.history.begin()->second; + ARMARX_CHECK_GREATER_EQUAL(entity.history().size(), 1); + armem::workingmemory::EntitySnapshot& snapshot = entity.history().begin()->second; ARMARX_INFO << "Result: " << "\n- memory: \t" << memory.name() @@ -265,7 +265,7 @@ namespace armarx void ExampleMemoryClient::queryExactSnapshot(const armem::MemoryID& snapshotID) { ARMARX_IMPORTANT - << "Querying exact smapshot: " + << "Querying exact snapshot: " << "\n- snapshotID: \t'" << snapshotID << "'" ; diff --git a/source/RobotAPI/libraries/armem/client/Query.h b/source/RobotAPI/libraries/armem/client/Query.h index 842fdf55c..5c0fb0f2b 100644 --- a/source/RobotAPI/libraries/armem/client/Query.h +++ b/source/RobotAPI/libraries/armem/client/Query.h @@ -3,7 +3,7 @@ // RobotAPI #include <RobotAPI/interface/armem/query.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> #include <RobotAPI/libraries/armem/core/SuccessHeader.h> #include <RobotAPI/libraries/armem/core/DataMode.h> #include <RobotAPI/libraries/armem/core/workingMemory/Memory.h> diff --git a/source/RobotAPI/libraries/armem/client/Reader.h b/source/RobotAPI/libraries/armem/client/Reader.h index 8fd5277e6..8164cc7f7 100644 --- a/source/RobotAPI/libraries/armem/client/Reader.h +++ b/source/RobotAPI/libraries/armem/client/Reader.h @@ -9,7 +9,7 @@ // RobotAPI #include <RobotAPI/interface/armem/server/ReadingMemoryInterface.h> #include <RobotAPI/interface/armem/client/MemoryListenerInterface.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> #include <RobotAPI/libraries/armem/core/workingMemory/Memory.h> #include <RobotAPI/libraries/armem/core/longtermMemory/Memory.h> diff --git a/source/RobotAPI/libraries/armem/client/Writer.h b/source/RobotAPI/libraries/armem/client/Writer.h index f4c0754a1..7a7160fcb 100644 --- a/source/RobotAPI/libraries/armem/client/Writer.h +++ b/source/RobotAPI/libraries/armem/client/Writer.h @@ -2,7 +2,7 @@ #include <RobotAPI/interface/armem/server/WritingMemoryInterface.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> namespace armarx::armem::client diff --git a/source/RobotAPI/libraries/armem/client/query/selectors.cpp b/source/RobotAPI/libraries/armem/client/query/selectors.cpp index 13d4e14c8..838357071 100644 --- a/source/RobotAPI/libraries/armem/client/query/selectors.cpp +++ b/source/RobotAPI/libraries/armem/client/query/selectors.cpp @@ -1,6 +1,6 @@ #include "selectors.h" -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> namespace dq = ::armarx::armem::query::data; diff --git a/source/RobotAPI/libraries/armem/core/base/CoreSegment.h b/source/RobotAPI/libraries/armem/core/base/CoreSegment.h index 75f604a82..64223917a 100644 --- a/source/RobotAPI/libraries/armem/core/base/CoreSegment.h +++ b/source/RobotAPI/libraries/armem/core/base/CoreSegment.h @@ -63,9 +63,21 @@ namespace armarx::armem return const_cast<std::string&>(const_cast<const CoreSegmentBase*>(this)->name()); } + + using Base::container; + inline const std::map<std::string, ProviderSegmentT>& providerSegments() const + { + return container; + } + inline std::map<std::string, ProviderSegmentT>& providerSegments() + { + return const_cast<std::map<std::string, ProviderSegmentT>&>(const_cast<const CoreSegmentBase*>(this)->providerSegments()); + } + + bool hasProviderSegment(const std::string& name) const { - return providerSegments.count(name) > 0; + return container.count(name) > 0; } ProviderSegmentT& getProviderSegment(const std::string& name) @@ -75,8 +87,8 @@ namespace armarx::armem const ProviderSegmentT& getProviderSegment(const std::string& name) const { - auto it = this->providerSegments.find(name); - if (it != providerSegments.end()) + auto it = this->container.find(name); + if (it != container.end()) { return it->second; } @@ -97,8 +109,8 @@ namespace armarx::armem { _checkContainerName(update.entityID.coreSegmentName, this->name()); - auto it = this->providerSegments.find(update.entityID.providerSegmentName); - if (it != providerSegments.end()) + auto it = this->container.find(update.entityID.providerSegmentName); + if (it != container.end()) { return it->second.update(update); } @@ -135,7 +147,7 @@ namespace armarx::armem providerSegment.getLevelName(), providerSegment.name(), getLevelName(), this->getKeyString()); } - auto it = providerSegments.emplace(providerSegment.name(), std::move(providerSegment)).first; + auto it = container.emplace(providerSegment.name(), std::move(providerSegment)).first; it->second.id.setCoreSegmentID(id); it->second.setMaxHistorySize(maxHistorySize); return it->second; @@ -150,7 +162,7 @@ namespace armarx::armem void setMaxHistorySize(long maxSize) override { MaxHistorySize::setMaxHistorySize(maxSize); - for (auto& [name, seg] : providerSegments) + for (auto& [name, seg] : container) { seg.setMaxHistorySize(maxSize); } @@ -164,7 +176,7 @@ namespace armarx::armem { return false; } - for (const auto& [key, provider] : providerSegments) + for (const auto& [key, provider] : container) { if (not other.hasProviderSegment(key)) { @@ -188,36 +200,7 @@ namespace armarx::armem return this->name(); } - virtual Derived copy() const override - { - Derived d; - this->_copySelf(d); - return d; - } - - virtual Derived copyEmpty() const override - { - Derived d; - this->_copySelfEmpty(d); - return d; - } - - protected: - virtual void _copySelf(Derived& other) const override - { - Base::_copySelf(other); - providerSegments = other.providerSegments; - } - - virtual void _copySelfEmpty(Derived& other) const override - { - Base::_copySelfEmpty(other); - providerSegments = other.providerSegments; - } - public: - /// The provider segments. - std::map<std::string, ProviderSegmentT>& providerSegments = Base::container; }; diff --git a/source/RobotAPI/libraries/armem/core/base/Entity.h b/source/RobotAPI/libraries/armem/core/base/Entity.h index 70bda50c0..05cd45008 100644 --- a/source/RobotAPI/libraries/armem/core/base/Entity.h +++ b/source/RobotAPI/libraries/armem/core/base/Entity.h @@ -78,7 +78,7 @@ namespace armarx::armem { return false; } - for (const auto& [key, snapshot] : history) + for (const auto& [key, snapshot] : container) { if (not other.hasSnapshot(key)) { @@ -94,22 +94,33 @@ namespace armarx::armem using Base::id; - const std::string& name() const + inline const std::string& name() const { return id.entityName; } - std::string& name() + inline std::string& name() { return const_cast<std::string&>(const_cast<const EntityBase*>(this)->name()); } + using Base::container; + inline const std::map<Time, _EntitySnapshotT>& history() const + { + return container; + } + inline std::map<Time, _EntitySnapshotT>& history() + { + return const_cast<std::map<Time, _EntitySnapshotT>&>(const_cast<const EntityBase*>(this)->history()); + } + + /** * @brief Indicates whether a history entry for the given time exists. */ bool hasSnapshot(Time time) const { - return history.count(time) > 0; + return container.count(time) > 0; } /** @@ -126,7 +137,7 @@ namespace armarx::armem */ std::vector<Time> getTimestamps() const { - return simox::alg::get_keys(history); + return simox::alg::get_keys(container); } @@ -145,8 +156,8 @@ namespace armarx::armem const EntitySnapshotT& getSnapshot(Time time) const { - auto it = history.find(time); - if (it != history.end()) + auto it = container.find(time); + if (it != container.end()) { return it->second; } @@ -196,8 +207,8 @@ namespace armarx::armem EntitySnapshotT* snapshot; - auto it = history.find(update.timeCreated); - if (it == history.end()) + auto it = container.find(update.timeCreated); + if (it == container.end()) { // Insert into history. snapshot = &addSnapshot(update.timeCreated); @@ -225,7 +236,7 @@ namespace armarx::armem EntitySnapshotT& addSnapshot(EntitySnapshotT&& snapshot) { - auto it = history.emplace(snapshot.time(), std::move(snapshot)).first; + auto it = container.emplace(snapshot.time(), std::move(snapshot)).first; it->second.id.setEntityID(id); return it->second; } @@ -274,13 +285,11 @@ namespace armarx::armem virtual void _copySelf(Derived& other) const override { Base::_copySelf(other); - history = other.history; } virtual void _copySelfEmpty(Derived& other) const override { Base::_copySelfEmpty(other); - history = other.history; } private: @@ -289,11 +298,11 @@ namespace armarx::armem { if (maxHistorySize >= 0) { - while (history.size() > size_t(maxHistorySize)) + while (container.size() > size_t(maxHistorySize)) { - history.erase(history.begin()); + container.erase(container.begin()); } - ARMARX_CHECK_LESS_EQUAL(history.size(), maxHistorySize); + ARMARX_CHECK_LESS_EQUAL(container.size(), maxHistorySize); } } @@ -312,16 +321,14 @@ namespace armarx::armem */ const typename std::map<Time, EntitySnapshotT>::value_type& getLatestItem() const { - if (history.empty()) + if (container.empty()) { throw armem::error::EntityHistoryEmpty(name(), "when getting the latest snapshot."); } - return *history.rbegin(); + return *container.rbegin(); } public: - std::map<Time, EntitySnapshotT>& history = Base::container; - /** * @brief Maximum size of `history` * diff --git a/source/RobotAPI/libraries/armem/core/base/EntitySnapshot.h b/source/RobotAPI/libraries/armem/core/base/EntitySnapshot.h index 7ad3680cd..e4b527b6e 100644 --- a/source/RobotAPI/libraries/armem/core/base/EntitySnapshot.h +++ b/source/RobotAPI/libraries/armem/core/base/EntitySnapshot.h @@ -35,7 +35,7 @@ namespace armarx::armem EntitySnapshotBase(const MemoryID& id) : Base(id) {} - /// Copy the instances from `other` to this. + /// Copy the container from `other` to this. EntitySnapshotBase(const EntitySnapshotBase& other) : Base(other) { // *this = other; @@ -56,7 +56,7 @@ namespace armarx::armem return false; } int i = 0; - for (const auto& instance : instances) + for (const auto& instance : container) { if (not instance.equalsDeep(other.getInstance(i))) { @@ -78,6 +78,18 @@ namespace armarx::armem return id.timestamp; } + + using Base::container; + inline const std::vector<_EntityInstanceT>& instances() const + { + return container; + } + inline std::vector<_EntityInstanceT>& instances() + { + return const_cast<std::vector<_EntityInstanceT>&>(const_cast<const EntitySnapshotBase*>(this)->instances()); + } + + void update(const EntityUpdate& update, std::optional<MemoryID> parentID = std::nullopt) { if (parentID) @@ -86,10 +98,10 @@ namespace armarx::armem } time() = update.timeCreated; - instances.clear(); + container.clear(); for (int i = 0; i < int(update.instancesData.size()); ++i) { - EntityInstanceT& data = instances.emplace_back(i, id); + EntityInstanceT& data = container.emplace_back(i, id); data.update(update, i); } } @@ -98,7 +110,7 @@ namespace armarx::armem bool hasInstance(int index) const { size_t si = size_t(index); - return index >= 0 && si < instances.size(); + return index >= 0 && si < container.size(); } /** @@ -117,7 +129,7 @@ namespace armarx::armem if (hasInstance(index)) { size_t si = size_t(index); - return instances[si]; + return container[si]; } else { @@ -151,7 +163,7 @@ namespace armarx::armem * @brief Add a single instance with data. * @param instance The instance. * @return The stored instance. - * @throw `armem::error::InvalidArgument` If the given index is invalid. Must be equal to instances.size() or -1 (meaning push_back) + * @throw `armem::error::InvalidArgument` If the given index is invalid. Must be equal to container.size() or -1 (meaning push_back) */ EntityInstanceT& addInstance(const EntityInstanceT& instance) { @@ -160,19 +172,19 @@ namespace armarx::armem EntityInstanceT& addInstance(EntityInstanceT&& instance) { - if (instance.index() > 0 && (size_t) instance.index() < instances.size()) + if (instance.index() > 0 && (size_t) instance.index() < container.size()) { throw error::InvalidArgument(std::to_string(instance.index()), "EntitySnapshot::addInstance", "Cannot add an EntityInstance because its index already exists."); } - if (instance.index() > 0 && (size_t) instance.index() > instances.size()) + if (instance.index() > 0 && (size_t) instance.index() > container.size()) { throw error::InvalidArgument(std::to_string(instance.index()), "EntitySnapshot::addInstance", "Cannot add an EntityInstance because its index is too big."); } - int new_index = instances.size(); - auto& it = instances.emplace_back(std::move(instance)); + int new_index = container.size(); + auto& it = container.emplace_back(std::move(instance)); it.index() = new_index; return it; } @@ -187,35 +199,7 @@ namespace armarx::armem return "entity snapshot"; } - virtual Derived copy() const override - { - Derived d; - this->_copySelf(d); - return d; - } - - virtual Derived copyEmpty() const override - { - Derived d; - this->_copySelfEmpty(d); - return d; - } - - protected: - virtual void _copySelf(Derived& other) const override - { - Base::_copySelf(other); - instances = other.instances; - } - - virtual void _copySelfEmpty(Derived& other) const override - { - Base::_copySelfEmpty(other); - instances = other.instances; - } - public: - std::vector<_EntityInstanceT>& instances = Base::container; }; } diff --git a/source/RobotAPI/libraries/armem/core/base/Memory.h b/source/RobotAPI/libraries/armem/core/base/Memory.h index 717927b97..cf1a18020 100644 --- a/source/RobotAPI/libraries/armem/core/base/Memory.h +++ b/source/RobotAPI/libraries/armem/core/base/Memory.h @@ -14,7 +14,7 @@ namespace armarx::armem */ template <class _CoreSegmentT, class _EntityT, class _EntitySnapshotT, class _EntityInstanceT, class Derived> class MemoryBase : - virtual public detail::EntityContainerBase<_CoreSegmentT, _EntityT, _EntitySnapshotT, _EntityInstanceT, Derived> + virtual public detail::EntityContainerBase<_CoreSegmentT, _EntityT, _EntitySnapshotT, _EntityInstanceT, Derived> { using Base = detail::EntityContainerBase<_CoreSegmentT, _EntityT, _EntitySnapshotT, _EntityInstanceT, Derived>; @@ -58,9 +58,21 @@ namespace armarx::armem return const_cast<std::string&>(const_cast<const MemoryBase*>(this)->name()); } + + using Base::container; + inline const std::map<std::string, CoreSegmentT>& coreSegments() const + { + return container; + } + inline std::map<std::string, CoreSegmentT>& coreSegments() + { + return const_cast<std::map<std::string, CoreSegmentT>&>(const_cast<const MemoryBase*>(this)->coreSegments()); + } + + bool hasCoreSegment(const std::string& name) const { - return coreSegments.count(name) > 0; + return container.count(name) > 0; } CoreSegmentT& getCoreSegment(const std::string& name) @@ -70,8 +82,8 @@ namespace armarx::armem const CoreSegmentT& getCoreSegment(const std::string& name) const { - auto it = this->coreSegments.find(name); - if (it != coreSegments.end()) + auto it = this->container.find(name); + if (it != container.end()) { return it->second; } @@ -106,12 +118,12 @@ namespace armarx::armem /// Move and insert a core segment. CoreSegmentT& addCoreSegment(CoreSegmentT&& coreSegment) { - if (coreSegments.count(coreSegment.name()) > 0) + if (container.count(coreSegment.name()) > 0) { throw armem::error::ContainerEntryAlreadyExists(coreSegment.getLevelName(), coreSegment.name(), this->getLevelName(), this->name()); } - auto it = coreSegments.emplace(coreSegment.name(), std::move(coreSegment)).first; + auto it = container.emplace(coreSegment.name(), std::move(coreSegment)).first; it->second.id.setMemoryID(id); return it->second; } @@ -142,8 +154,8 @@ namespace armarx::armem { _checkContainerName(update.entityID.memoryName, this->name()); - auto it = this->coreSegments.find(update.entityID.coreSegmentName); - if (it != coreSegments.end()) + auto it = this->container.find(update.entityID.coreSegmentName); + if (it != container.end()) { return it->second.update(update); } @@ -161,7 +173,7 @@ namespace armarx::armem { return false; } - for (const auto& [key, core] : coreSegments) + for (const auto& [key, core] : container) { if (not other.hasCoreSegment(key)) { @@ -185,34 +197,6 @@ namespace armarx::armem return this->name(); } - virtual Derived copy() const override - { - Derived d; - this->_copySelf(d); - return d; - } - - virtual Derived copyEmpty() const override - { - Derived d; - this->_copySelfEmpty(d); - return d; - } - - protected: - virtual void _copySelf(Derived& other) const override - { - Base::_copySelf(other); - coreSegments = other.coreSegments; - } - - virtual void _copySelfEmpty(Derived& other) const override - { - Base::_copySelfEmpty(other); - coreSegments = other.coreSegments; - } - public: - std::map<std::string, CoreSegmentT>& coreSegments = Base::container; }; } diff --git a/source/RobotAPI/libraries/armem/core/base/ProviderSegment.h b/source/RobotAPI/libraries/armem/core/base/ProviderSegment.h index 26f22688d..1ef59929b 100644 --- a/source/RobotAPI/libraries/armem/core/base/ProviderSegment.h +++ b/source/RobotAPI/libraries/armem/core/base/ProviderSegment.h @@ -63,9 +63,20 @@ namespace armarx::armem } + using Base::container; + inline const std::map<std::string, EntityT>& entities() const + { + return container; + } + inline std::map<std::string, EntityT>& entities() + { + return const_cast<std::map<std::string, EntityT>&>(const_cast<const ProviderSegmentBase*>(this)->entities()); + } + + bool hasEntity(const std::string& name) const { - return entities.count(name) > 0; + return container.count(name) > 0; } using Base::_checkContainerName; @@ -82,8 +93,8 @@ namespace armarx::armem const EntityT& getEntity(const std::string& name) const { - auto it = this->entities.find(name); - if (it != entities.end()) + auto it = this->container.find(name); + if (it != container.end()) { return it->second; } @@ -103,8 +114,8 @@ namespace armarx::armem _checkContainerName(update.entityID.providerSegmentName, this->name()); EntityT* entity; - auto it = this->entities.find(update.entityID.providerSegmentName); - if (it == entities.end()) + auto it = this->container.find(update.entityID.providerSegmentName); + if (it == container.end()) { // Add entity entry. entity = &addEntity(update.entityID.entityName); @@ -131,21 +142,21 @@ namespace armarx::armem /// Move and insert an entity. EntityT& addEntity(EntityT&& entity) { - auto it = entities.emplace(entity.name(), std::move(entity)).first; + auto it = container.emplace(entity.name(), std::move(entity)).first; it->second.id.setProviderSegmentID(id); return it->second; } /** - * @brief Sets the maximum history size of entities in this segment. - * This affects all current entities as well as new ones. + * @brief Sets the maximum history size of container in this segment. + * This affects all current container as well as new ones. * @see Entity::setMaxHistorySize() */ void setMaxHistorySize(long maxSize) override { MaxHistorySize::setMaxHistorySize(maxSize); - for (auto& [name, entity] : entities) + for (auto& [name, entity] : container) { entity.setMaxHistorySize(maxSize); } @@ -160,7 +171,7 @@ namespace armarx::armem { return false; } - for (const auto& [key, value] : entities) + for (const auto& [key, value] : container) { if (not other.hasEntity(key)) { @@ -185,37 +196,7 @@ namespace armarx::armem return this->name(); } - virtual Derived copy() const override - { - Derived d; - this->_copySelf(d); - return d; - } - - virtual Derived copyEmpty() const override - { - Derived d; - this->_copySelfEmpty(d); - return d; - } - - protected: - virtual void _copySelf(Derived& other) const override - { - Base::_copySelf(other); - entities = other.entities; - } - - virtual void _copySelfEmpty(Derived& other) const override - { - Base::_copySelfEmpty(other); - entities = other.entities; - } - - public: - /// The entities. - std::map<std::string, EntityT>& entities = Base::container; }; diff --git a/source/RobotAPI/libraries/armem/core/base/detail/MemoryContainer.h b/source/RobotAPI/libraries/armem/core/base/detail/MemoryContainer.h index bb53d6556..c8454892d 100644 --- a/source/RobotAPI/libraries/armem/core/base/detail/MemoryContainer.h +++ b/source/RobotAPI/libraries/armem/core/base/detail/MemoryContainer.h @@ -16,7 +16,7 @@ namespace armarx::armem::detail */ template <class _ContainerT, class Derived> class MemoryContainerBase : - virtual public armarx::armem::detail::MemoryItem + virtual public armarx::armem::detail::MemoryItem { using Base = armarx::armem::detail::MemoryItem; diff --git a/source/RobotAPI/libraries/armem/core/ice_conversions_templates.h b/source/RobotAPI/libraries/armem/core/ice_conversions_templates.h index 1cc826f45..dc5c3fff5 100644 --- a/source/RobotAPI/libraries/armem/core/ice_conversions_templates.h +++ b/source/RobotAPI/libraries/armem/core/ice_conversions_templates.h @@ -28,14 +28,14 @@ namespace armarx::armem IceT toIce(const CppT& cpp) { IceT ice = {}; - //toIce(ice, cpp); + toIce(ice, cpp); return ice; } template <class CppT, class IceT> CppT fromIce(const IceT& ice) { CppT cpp; - //fromIce(ice, cpp); + fromIce(ice, cpp); return cpp; } @@ -63,14 +63,14 @@ namespace armarx::armem void toIce(::IceInternal::Handle<IceT>& ice, const CppT& cpp) { ice = new IceT(); - //toIce(*ice, cpp); + toIce(*ice, cpp); } template <class IceT, class CppT> void fromIce(const ::IceInternal::Handle<IceT>& ice, CppT& cpp) { if (ice) { - //fromIce(*ice, cpp); + fromIce(*ice, cpp); } } diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.cpp b/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.cpp index 76d86ba9f..3d42bbbe5 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.cpp @@ -13,12 +13,14 @@ namespace armarx::armem::longtermmemory } CoreSegment::CoreSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr aronType) : - CoreSegment(name, MemoryID(), aronType) + armarx::armem::detail::MemoryItem(MemoryID().withCoreSegmentName(name)), + armarx::armem::detail::TypedEntityContainerBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>(MemoryID().withCoreSegmentName(name), aronType) { } CoreSegment::CoreSegment(const std::string& name, const MemoryID& parentID, aron::typenavigator::ObjectNavigatorPtr aronType) : - CoreSegment(parentID.getMemoryID().withCoreSegmentName(name), aronType) + armarx::armem::detail::MemoryItem(MemoryID().withCoreSegmentName(name)), + armarx::armem::detail::TypedEntityContainerBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>(parentID.withCoreSegmentName(name), aronType) { } @@ -33,13 +35,11 @@ namespace armarx::armem::longtermmemory MemoryContainerBase<std::map<std::string, ProviderSegment>, CoreSegment>(other), armarx::armem::detail::TypedEntityContainerBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>(other) { - // *this = other; } CoreSegment& CoreSegment::operator=(const CoreSegment& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } } diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.h b/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.h index d41c7288f..c2bc57f8f 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.h +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/CoreSegment.h @@ -13,8 +13,8 @@ namespace armarx::armem::longtermmemory * @brief Data of a core segment containing multiple provider segments. */ class CoreSegment : - virtual public CoreSegmentBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>, - virtual public detail::TypedEntityContainer<ProviderSegment, CoreSegment> + virtual public CoreSegmentBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>, + virtual public detail::TypedEntityContainer<ProviderSegment, CoreSegment> { public: CoreSegment(); diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/Entity.cpp b/source/RobotAPI/libraries/armem/core/longtermMemory/Entity.cpp index 2ed158416..09ea28d25 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/Entity.cpp +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/Entity.cpp @@ -8,7 +8,7 @@ namespace armarx::armem::longtermmemory } Entity::Entity(const std::string& name, const MemoryID& parentID) : - Entity(parentID.withEntityName(name)) + armarx::armem::detail::MemoryItem(parentID.withEntityName(name)) { } @@ -21,13 +21,11 @@ namespace armarx::armem::longtermmemory armarx::armem::detail::MemoryItem(other), armarx::armem::detail::MemoryContainerBase<std::map<Time, EntitySnapshot>, Entity>(other) { - // *this = other; } Entity& Entity::operator=(const Entity& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } } diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.cpp b/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.cpp index 6b2a6898f..e1800f72a 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.cpp +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.cpp @@ -18,6 +18,12 @@ namespace armarx::armem::longtermmemory { } + EntityInstance::EntityInstance(const EntityInstance& other) : + MemoryItem(other.id), + _metadata(other._metadata) + { + } + EntityInstance::EntityInstance(int index, const MemoryID& parentID) : EntityInstance(parentID.withInstanceIndex(index)) { @@ -28,6 +34,12 @@ namespace armarx::armem::longtermmemory { } + EntityInstance& EntityInstance::operator=(const EntityInstance& other) + { + other._copySelf(*this); + return *this; + } + bool EntityInstance::equalsDeep(const EntityInstance& other) const { diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.h b/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.h index 764d941ed..4884b43fb 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.h +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/EntityInstance.h @@ -32,14 +32,17 @@ namespace armarx::armem::longtermmemory * @brief Data of a single entity instance. */ class EntityInstance : - virtual public EntityInstanceBase<EntityInstance> + virtual public EntityInstanceBase<EntityInstance> { public: EntityInstance(); + EntityInstance(const EntityInstance&); EntityInstance(int index, const MemoryID& parentID = {}); EntityInstance(const MemoryID& id); + EntityInstance& operator=(const EntityInstance& other); + EntityInstanceMetadata& metadata() { return _metadata; diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/EntitySnapshot.cpp b/source/RobotAPI/libraries/armem/core/longtermMemory/EntitySnapshot.cpp index f82a54ca7..11b2045e5 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/EntitySnapshot.cpp +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/EntitySnapshot.cpp @@ -27,19 +27,11 @@ namespace armarx::armem::longtermmemory armarx::armem::detail::MemoryItem(other), armarx::armem::detail::MemoryContainerBase<std::vector<EntityInstance>, EntitySnapshot>(other) { - // *this = other; } EntitySnapshot& EntitySnapshot::operator=(const EntitySnapshot& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } - - /*EntitySnapshot EntitySnapshot::copy(bool withData) const - { - //auto cast = dynamic_cast<const Derived*>(this); - return Base2::copy(withData); - }*/ } diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.cpp b/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.cpp index 9ad01dec5..ee58ef2ab 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.cpp +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.cpp @@ -14,7 +14,7 @@ namespace armarx::armem::longtermmemory } Memory::Memory(const std::string& name) : - Memory(MemoryID().withMemoryName(name)) + armarx::armem::detail::MemoryItem(MemoryID().withMemoryName(name)) { } @@ -33,7 +33,7 @@ namespace armarx::armem::longtermmemory Memory& Memory::operator=(const Memory& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } + } diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.h b/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.h index dae9522a6..5dc1262cf 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.h +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/Memory.h @@ -12,8 +12,8 @@ namespace armarx::armem::longtermmemory * @brief Data of a memory consisting of multiple core segments. */ class Memory : - virtual public MemoryBase<CoreSegment, Entity, EntitySnapshot, EntityInstance, Memory>, - virtual public detail::EntityContainer<CoreSegment, Memory> + virtual public MemoryBase<CoreSegment, Entity, EntitySnapshot, EntityInstance, Memory>, + virtual public detail::EntityContainer<CoreSegment, Memory> { public: Memory(); diff --git a/source/RobotAPI/libraries/armem/core/longtermMemory/ProviderSegment.cpp b/source/RobotAPI/libraries/armem/core/longtermMemory/ProviderSegment.cpp index b53148e18..dac106c1e 100644 --- a/source/RobotAPI/libraries/armem/core/longtermMemory/ProviderSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/longtermMemory/ProviderSegment.cpp @@ -13,12 +13,14 @@ namespace armarx::armem::longtermmemory } ProviderSegment::ProviderSegment(const std::string& name, aron::typenavigator::ObjectNavigatorPtr aronType) : - ProviderSegment(name, MemoryID(), aronType) + armarx::armem::detail::MemoryItem(MemoryID().withProviderSegmentName(name)), + armarx::armem::detail::TypedEntityContainerBase<Entity, Entity, EntitySnapshot, EntityInstance, ProviderSegment>(MemoryID().withProviderSegmentName(name), aronType) { } ProviderSegment::ProviderSegment(const std::string& name, const MemoryID parentID, aron::typenavigator::ObjectNavigatorPtr aronType) : - ProviderSegment(parentID.withProviderSegmentName(name), aronType) + armarx::armem::detail::MemoryItem(parentID.withProviderSegmentName(name)), + armarx::armem::detail::TypedEntityContainerBase<Entity, Entity, EntitySnapshot, EntityInstance, ProviderSegment>(parentID.withProviderSegmentName(name), aronType) { } @@ -33,13 +35,12 @@ namespace armarx::armem::longtermmemory MemoryContainerBase<std::map<std::string, Entity>, ProviderSegment>(other), armarx::armem::detail::TypedEntityContainerBase<Entity, Entity, EntitySnapshot, EntityInstance, ProviderSegment>(other) { - // *this = other; } ProviderSegment& ProviderSegment::operator=(const ProviderSegment& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } + } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.cpp b/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.cpp index 9310d7963..e91e5fa4c 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.cpp @@ -35,13 +35,27 @@ namespace armarx::armem::workingmemory MemoryContainerBase<std::map<std::string, ProviderSegment>, CoreSegment>(other), armarx::armem::detail::TypedEntityContainerBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>(other) { - // *this = other; } CoreSegment& CoreSegment::operator=(const CoreSegment& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } + + CoreSegment CoreSegment::copyWithoutData() const + { + CoreSegment m; + _copySelfWithoutData(m); + return m; + } + + void CoreSegment::_copySelfWithoutData(CoreSegment& o) const + { + detail::TypedEntityContainer<ProviderSegment, CoreSegment>::_copySelfWithoutData(o); + for (const auto& [k, s] : o.container) + { + o.addProviderSegment(s.copyWithoutData()); + } + } } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.h b/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.h index 1da46fbf3..e1fe33469 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/CoreSegment.h @@ -13,8 +13,8 @@ namespace armarx::armem::workingmemory * @brief Data of a core segment containing multiple provider segments. */ class CoreSegment : - virtual public CoreSegmentBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>, - virtual public detail::TypedEntityContainer<ProviderSegment, CoreSegment> + virtual public CoreSegmentBase<ProviderSegment, Entity, EntitySnapshot, EntityInstance, CoreSegment>, + virtual public detail::TypedEntityContainer<ProviderSegment, CoreSegment> { public: CoreSegment(); @@ -25,7 +25,10 @@ namespace armarx::armem::workingmemory CoreSegment(const CoreSegment& other); CoreSegment& operator=(const CoreSegment& other); - //CoreSegment copyWithoutData() const override; + CoreSegment copyWithoutData() const override; + + protected: + virtual void _copySelfWithoutData(CoreSegment& o) const override; }; } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/Entity.cpp b/source/RobotAPI/libraries/armem/core/workingMemory/Entity.cpp index 8308070cf..4880da0ea 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/Entity.cpp +++ b/source/RobotAPI/libraries/armem/core/workingMemory/Entity.cpp @@ -21,13 +21,27 @@ namespace armarx::armem::workingmemory armarx::armem::detail::MemoryItem(other), armarx::armem::detail::MemoryContainerBase<std::map<Time, EntitySnapshot>, Entity>(other) { - // *this = other; } Entity& Entity::operator=(const Entity& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } + + Entity Entity::copyWithoutData() const + { + Entity m; + _copySelfWithoutData(m); + return m; + } + + void Entity::_copySelfWithoutData(Entity& o) const + { + detail::MemoryContainer<std::map<Time, EntitySnapshot>, Entity>::_copySelfWithoutData(o); + for (const auto& [k, s] : o.container) + { + o.addSnapshot(s.copyWithoutData()); + } + } } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/Entity.h b/source/RobotAPI/libraries/armem/core/workingMemory/Entity.h index 571f02fbd..3484406ae 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/Entity.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/Entity.h @@ -42,7 +42,10 @@ namespace armarx::armem::workingmemory /// Copy the history from `other` to this. Entity& operator=(const Entity& other); - //Entity copyWithoutData() const override; + Entity copyWithoutData() const override; + + protected: + virtual void _copySelfWithoutData(Entity& o) const override; }; } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.cpp b/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.cpp index 624b8ee9a..cffa83499 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.cpp +++ b/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.cpp @@ -18,6 +18,13 @@ namespace armarx::armem::workingmemory { } + EntityInstance::EntityInstance(const EntityInstance& other) : + MemoryItem(other.id), + _metadata(other._metadata), + _data(other._data) + { + } + EntityInstance::EntityInstance(int index, const MemoryID& parentID) : EntityInstance(parentID.withInstanceIndex(index)) { @@ -28,10 +35,16 @@ namespace armarx::armem::workingmemory { } + EntityInstance& EntityInstance::operator=(const EntityInstance& other) + { + other._copySelf(*this); + return *this; + } + bool EntityInstance::equalsDeep(const EntityInstance& other) const { - return _metadata == other.metadata() && _data->equalsDeep(other.data()); + return id == other.id && _metadata == other.metadata() && _data->equalsDeep(other.data()); } void EntityInstance::update(const EntityUpdate& update, int index) diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.h b/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.h index 45a1c3e76..38709d42f 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/EntityInstance.h @@ -32,14 +32,17 @@ namespace armarx::armem::workingmemory * @brief Data of a single entity instance. */ class EntityInstance : - virtual public EntityInstanceBase<EntityInstance> + virtual public EntityInstanceBase<EntityInstance> { public: EntityInstance(); + EntityInstance(const EntityInstance&); EntityInstance(int index, const MemoryID& parentID = {}); EntityInstance(const MemoryID& id); + EntityInstance& operator=(const EntityInstance& other); + EntityInstanceMetadata& metadata() { return _metadata; diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.cpp b/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.cpp index ad4bc9ef6..be3f08204 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.cpp +++ b/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.cpp @@ -27,19 +27,27 @@ namespace armarx::armem::workingmemory armarx::armem::detail::MemoryItem(other), armarx::armem::detail::MemoryContainerBase<std::vector<EntityInstance>, EntitySnapshot>(other) { - // *this = other; } EntitySnapshot& EntitySnapshot::operator=(const EntitySnapshot& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } - /*EntitySnapshot EntitySnapshot::copy(bool withData) const + EntitySnapshot EntitySnapshot::copyWithoutData() const { - //auto cast = dynamic_cast<const Derived*>(this); - return Base2::copy(withData); - }*/ + EntitySnapshot m; + _copySelfWithoutData(m); + return m; + } + + void EntitySnapshot::_copySelfWithoutData(EntitySnapshot& o) const + { + detail::MemoryContainer<std::vector<EntityInstance>, EntitySnapshot>::_copySelfWithoutData(o); + for (const auto& s : o.container) + { + o.addInstance(s.copyWithoutData()); + } + } } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.h b/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.h index b5671aaaf..95af4a5e8 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/EntitySnapshot.h @@ -28,6 +28,9 @@ namespace armarx::armem::workingmemory /// Copy the instances from `other` to this. EntitySnapshot& operator=(const EntitySnapshot& other); - //EntitySnapshot copyWithoutData() const override; + EntitySnapshot copyWithoutData() const override; + + protected: + virtual void _copySelfWithoutData(EntitySnapshot& o) const override; }; } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/Memory.cpp b/source/RobotAPI/libraries/armem/core/workingMemory/Memory.cpp index 250649091..31e380522 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/Memory.cpp +++ b/source/RobotAPI/libraries/armem/core/workingMemory/Memory.cpp @@ -16,7 +16,6 @@ namespace armarx::armem::workingmemory Memory::Memory(const std::string& name) : armarx::armem::detail::MemoryItem(MemoryID().withMemoryName(name)) { - std::cout << "Memory: My name is: " << this->name() << std::endl; } Memory::Memory(const MemoryID& id) : @@ -34,7 +33,22 @@ namespace armarx::armem::workingmemory Memory& Memory::operator=(const Memory& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } + + Memory Memory::copyWithoutData() const + { + Memory m; + _copySelfWithoutData(m); + return m; + } + + void Memory::_copySelfWithoutData(Memory& o) const + { + detail::EntityContainer<CoreSegment, Memory>::_copySelfWithoutData(o); + for (const auto& [k, s] : o.container) + { + o.addCoreSegment(s.copyWithoutData()); + } + } } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/Memory.h b/source/RobotAPI/libraries/armem/core/workingMemory/Memory.h index 18e748cbb..1b29e3afd 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/Memory.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/Memory.h @@ -12,8 +12,8 @@ namespace armarx::armem::workingmemory * @brief Data of a memory consisting of multiple core segments. */ class Memory : - virtual public MemoryBase<CoreSegment, Entity, EntitySnapshot, EntityInstance, Memory>, - virtual public detail::EntityContainer<CoreSegment, Memory> + virtual public MemoryBase<CoreSegment, Entity, EntitySnapshot, EntityInstance, Memory>, + virtual public detail::EntityContainer<CoreSegment, Memory> { public: Memory(); @@ -23,6 +23,9 @@ namespace armarx::armem::workingmemory Memory(const Memory& other); Memory& operator=(const Memory& other); - //CoreSegment copyWithoutData() const override; + Memory copyWithoutData() const override; + + protected: + virtual void _copySelfWithoutData(Memory& o) const override; }; } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.cpp b/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.cpp index 2e43d2ceb..832e9c6c9 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.cpp +++ b/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.cpp @@ -35,14 +35,28 @@ namespace armarx::armem::workingmemory MemoryContainerBase<std::map<std::string, Entity>, ProviderSegment>(other), armarx::armem::detail::TypedEntityContainerBase<Entity, Entity, EntitySnapshot, EntityInstance, ProviderSegment>(other) { - // *this = other; } ProviderSegment& ProviderSegment::operator=(const ProviderSegment& other) { other._copySelf(*this); - //other._copyElements(*this, true); return *this; } + ProviderSegment ProviderSegment::copyWithoutData() const + { + ProviderSegment m; + _copySelfWithoutData(m); + return m; + } + + void ProviderSegment::_copySelfWithoutData(ProviderSegment& o) const + { + detail::TypedEntityContainer<Entity, ProviderSegment>::_copySelfWithoutData(o); + for (const auto& [k, s] : o.container) + { + o.addEntity(s.copyWithoutData()); + } + } + } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.h b/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.h index 482e189be..d80f53172 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/ProviderSegment.h @@ -25,7 +25,10 @@ namespace armarx::armem::workingmemory ProviderSegment(const ProviderSegment& other); ProviderSegment& operator=(const ProviderSegment& other); - //ProviderSegment copyWithoutData() const override; + ProviderSegment copyWithoutData() const override; + + protected: + virtual void _copySelfWithoutData(ProviderSegment& o) const override; }; } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/detail/MemoryContainer.h b/source/RobotAPI/libraries/armem/core/workingMemory/detail/MemoryContainer.h index 06d98823e..c3633b651 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/detail/MemoryContainer.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/detail/MemoryContainer.h @@ -16,7 +16,7 @@ namespace armarx::armem::workingmemory::detail */ template <class _ContainerT, class Derived> class MemoryContainer : - virtual public armarx::armem::detail::MemoryContainerBase<_ContainerT, Derived> + virtual public armarx::armem::detail::MemoryContainerBase<_ContainerT, Derived> { public: MemoryContainer& operator=(const MemoryContainer& other) @@ -28,8 +28,15 @@ namespace armarx::armem::workingmemory::detail // Copying virtual Derived copyWithoutData() const { - //auto cast = dynamic_cast<const Derived*>(this); - return armarx::armem::detail::MemoryContainerBase<_ContainerT, Derived>::copy(); + Derived t; + _copySelfWithoutData(t); + return t; + } + + protected: + virtual void _copySelfWithoutData(Derived& o) const + { + armarx::armem::detail::MemoryContainerBase<_ContainerT, Derived>::_copySelfEmpty(o); } }; } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.cpp b/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.cpp index 03c0e1f84..f218de383 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.cpp +++ b/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.cpp @@ -1,17 +1,15 @@ #include "ice_conversions.h" -using namespace armarx::armem::workingmemory; - -namespace armarx +namespace armarx::armem { - void armem::toIce(data::EntityInstanceMetadata& ice, const EntityInstanceMetadata& metadata) + void toIce(data::EntityInstanceMetadata& ice, const workingmemory::EntityInstanceMetadata& metadata) { ice.confidence = metadata.confidence; toIce(ice.timeArrivedMicroSeconds, metadata.timeArrived); toIce(ice.timeCreatedMicroSeconds, metadata.timeCreated); toIce(ice.timeSentMicroSeconds, metadata.timeSent); } - void armem::fromIce(const data::EntityInstanceMetadata& ice, EntityInstanceMetadata& metadata) + void fromIce(const data::EntityInstanceMetadata& ice, workingmemory::EntityInstanceMetadata& metadata) { metadata.confidence = ice.confidence; fromIce(ice.timeArrivedMicroSeconds, metadata.timeArrived); @@ -19,7 +17,7 @@ namespace armarx fromIce(ice.timeSentMicroSeconds, metadata.timeSent); } - void armem::toIce(data::EntityInstance& ice, const EntityInstance& data) + void toIce(data::EntityInstance& ice, const workingmemory::EntityInstance& data) { detail::toIceItem(ice, data); @@ -29,7 +27,7 @@ namespace armarx } toIce(ice.metadata, data.metadata()); } - void armem::fromIce(const data::EntityInstance& ice, EntityInstance& data) + void fromIce(const data::EntityInstance& ice, workingmemory::EntityInstance& data) { detail::fromIceItem(ice, data); @@ -41,34 +39,34 @@ namespace armarx } - void armem::toIce(data::EntitySnapshot& ice, const EntitySnapshot& snapshot) + void toIce(data::EntitySnapshot& ice, const workingmemory::EntitySnapshot& snapshot) { detail::toIceItem(ice, snapshot); - toIce(ice.instances, snapshot.instances); + toIce(ice.instances, snapshot.container); } - void armem::fromIce(const data::EntitySnapshot& ice, EntitySnapshot& snapshot) + void fromIce(const data::EntitySnapshot& ice, workingmemory::EntitySnapshot& snapshot) { detail::fromIceItem(ice, snapshot); - fromIce(ice.instances, snapshot.instances); + fromIce(ice.instances, snapshot.container); } - void armem::toIce(data::Entity& ice, const Entity& entity) + void toIce(data::Entity& ice, const workingmemory::Entity& entity) { detail::toIceItem(ice, entity); - toIce(ice.history, entity.history); + toIce(ice.history, entity.container); } - void armem::fromIce(const data::Entity& ice, Entity& entity) + void fromIce(const data::Entity& ice, workingmemory::Entity& entity) { detail::fromIceItem(ice, entity); - fromIce(ice.history, entity.history); + fromIce(ice.history, entity.container); } - void armem::toIce(data::ProviderSegment& ice, const ProviderSegment& providerSegment) + void toIce(data::ProviderSegment& ice, const workingmemory::ProviderSegment& providerSegment) { detail::toIceItem(ice, providerSegment); @@ -76,9 +74,9 @@ namespace armarx { ice.aronType = providerSegment.aronType->getResult(); } - toIce(ice.entities, providerSegment.entities); + toIce(ice.entities, providerSegment.container); } - void armem::fromIce(const data::ProviderSegment& ice, ProviderSegment& providerSegment) + void fromIce(const data::ProviderSegment& ice, workingmemory::ProviderSegment& providerSegment) { detail::fromIceItem(ice, providerSegment); @@ -86,10 +84,10 @@ namespace armarx { providerSegment.aronType = aron::typenavigator::ObjectNavigator::DynamicCastAndCheck(aron::typenavigator::Navigator::FromAronType(ice.aronType)); } - fromIce(ice.entities, providerSegment.entities); + fromIce(ice.entities, providerSegment.container); } - void armem::toIce(data::CoreSegment& ice, const CoreSegment& coreSegment) + void toIce(data::CoreSegment& ice, const workingmemory::CoreSegment& coreSegment) { detail::toIceItem(ice, coreSegment); @@ -97,9 +95,9 @@ namespace armarx { ice.aronType = coreSegment.aronType->getResult(); } - toIce(ice.providerSegments, coreSegment.providerSegments); + toIce(ice.providerSegments, coreSegment.container); } - void armem::fromIce(const data::CoreSegment& ice, CoreSegment& coreSegment) + void fromIce(const data::CoreSegment& ice, workingmemory::CoreSegment& coreSegment) { detail::fromIceItem(ice, coreSegment); @@ -107,20 +105,20 @@ namespace armarx { coreSegment.aronType = aron::typenavigator::ObjectNavigator::DynamicCastAndCheck(aron::typenavigator::Navigator::FromAronType(ice.aronType)); } - fromIce(ice.providerSegments, coreSegment.providerSegments); + fromIce(ice.providerSegments, coreSegment.container); } - void armem::toIce(data::Memory& ice, const Memory& memory) + void toIce(data::Memory& ice, const workingmemory::Memory& memory) { detail::toIceItem(ice, memory); - toIce(ice.coreSegments, memory.coreSegments); + toIce(ice.coreSegments, memory.container); } - void armem::fromIce(const data::Memory& ice, Memory& memory) + void fromIce(const data::Memory& ice, workingmemory::Memory& memory) { detail::fromIceItem(ice, memory); - fromIce(ice.coreSegments, memory.coreSegments); + fromIce(ice.coreSegments, memory.container); } } diff --git a/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h b/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h index e5996b001..a48fe734b 100644 --- a/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h +++ b/source/RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h @@ -3,8 +3,6 @@ #include <RobotAPI/interface/armem/commit.h> #include <RobotAPI/interface/armem/memory.h> -#include "../ice_conversions.h" - #include "Memory.h" @@ -33,3 +31,6 @@ namespace armarx::armem void toIce(data::Memory& ice, const workingmemory::Memory& memory); void fromIce(const data::Memory& ice, workingmemory::Memory& memory); } + +// Must be included after the prototypes. Otherwise the compiler cannot find the correct methods in ice_coversion_templates.h +#include "../ice_conversions.h" diff --git a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp index b6a1ffc5d..870bba1c5 100644 --- a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp +++ b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp @@ -16,13 +16,13 @@ namespace armarx::armem::server MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const workingmemory::Memory& memory) const { GroupBox group; - group.setLabel(makeGroupLabel("Memory", memory.name(), memory.coreSegments.size())); + group.setLabel(makeGroupLabel("Memory", memory.name(), memory.coreSegments().size())); - if (memory.coreSegments.empty()) + if (memory.coreSegments().empty()) { group.addChild(Label(makeNoItemsMessage("core segments"))); } - for (const auto& [name, coreSegment] : memory.coreSegments) + for (const auto& [name, coreSegment] : memory.coreSegments()) { group.addChild(makeGroupBox(coreSegment)); } @@ -35,13 +35,13 @@ namespace armarx::armem::server MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const workingmemory::CoreSegment& coreSegment) const { GroupBox group; - group.setLabel(makeGroupLabel("Core Segment", coreSegment.name(), coreSegment.providerSegments.size())); + group.setLabel(makeGroupLabel("Core Segment", coreSegment.name(), coreSegment.providerSegments().size())); - if (coreSegment.providerSegments.empty()) + if (coreSegment.providerSegments().empty()) { group.addChild(Label(makeNoItemsMessage("provider segments"))); } - for (const auto& [name, providerSegment] : coreSegment.providerSegments) + for (const auto& [name, providerSegment] : coreSegment.providerSegments()) { group.addChild(makeGroupBox(providerSegment)); } @@ -54,13 +54,13 @@ namespace armarx::armem::server MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const workingmemory::ProviderSegment& providerSegment) const { GroupBox group; - group.setLabel(makeGroupLabel("Provider Segment", providerSegment.name(), providerSegment.entities.size())); + group.setLabel(makeGroupLabel("Provider Segment", providerSegment.name(), providerSegment.entities().size())); - if (providerSegment.entities.empty()) + if (providerSegment.entities().empty()) { group.addChild(Label(makeNoItemsMessage("entities"))); } - for (const auto& [name, entity] : providerSegment.entities) + for (const auto& [name, entity] : providerSegment.entities()) { group.addChild(makeGroupBox(entity)); } @@ -73,15 +73,15 @@ namespace armarx::armem::server MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const workingmemory::Entity& entity) const { GroupBox group; - group.setLabel(makeGroupLabel("Entity", entity.name(), entity.history.size())); + group.setLabel(makeGroupLabel("Entity", entity.name(), entity.history().size())); - if (entity.history.empty()) + if (entity.history().empty()) { group.addChild(Label(makeNoItemsMessage("snapshots"))); } - if (int(entity.history.size()) <= maxHistorySize) + if (int(entity.history().size()) <= maxHistorySize) { - for (const auto& [time, snapshot] : entity.history) + for (const auto& [time, snapshot] : entity.history()) { group.addChild(makeGroupBox(snapshot)); } @@ -89,8 +89,8 @@ namespace armarx::armem::server else { int margin = 2; - auto it = entity.history.begin(); - auto rit = entity.history.end(); + auto it = entity.history().begin(); + auto rit = entity.history().end(); --rit; for (int i = 0; i < margin; ++i, ++it) { @@ -98,7 +98,7 @@ namespace armarx::armem::server --rit; } group.addChild(Label("...")); - for (; rit != entity.history.end(); ++rit) + for (; rit != entity.history().end(); ++rit) { group.addChild(makeGroupBox(rit->second)); } @@ -114,13 +114,13 @@ namespace armarx::armem::server { GroupBox group; group.setLabel(makeGroupLabel("t", armem::toDateTimeMilliSeconds(snapshot.time()), - snapshot.instances.size(), " = ", "")); + snapshot.instances().size(), " = ", "")); - if (snapshot.instances.empty()) + if (snapshot.instances().empty()) { group.addChild(Label(makeNoItemsMessage("instances"))); } - for (const workingmemory::EntityInstance& instance : snapshot.instances) + for (const workingmemory::EntityInstance& instance : snapshot.instances()) { group.addChild(makeGroupBox(instance)); } diff --git a/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp b/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp index 955fb203f..d1ed7fc92 100644 --- a/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp +++ b/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp @@ -3,7 +3,7 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include "../error.h" -#include "../core/ice_conversions.h" +#include "../core/workingMemory/ice_conversions.h" #include "query_proc/MemoryQueryProcessor.h" //#include "../core/io/diskWriter/NlohmannJSON/NlohmannJSONDiskWriter.h" diff --git a/source/RobotAPI/libraries/armem/server/query_proc/BaseQueryProcessor.cpp b/source/RobotAPI/libraries/armem/server/query_proc/BaseQueryProcessor.cpp index c9f25c5d2..5bb5942e8 100644 --- a/source/RobotAPI/libraries/armem/server/query_proc/BaseQueryProcessor.cpp +++ b/source/RobotAPI/libraries/armem/server/query_proc/BaseQueryProcessor.cpp @@ -4,7 +4,7 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <RobotAPI/libraries/armem/core/error.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> namespace armarx::armem::query_proc diff --git a/source/RobotAPI/libraries/armem/server/query_proc/CoreSegmentQueryProcessor.cpp b/source/RobotAPI/libraries/armem/server/query_proc/CoreSegmentQueryProcessor.cpp index 77c0cadab..cce5b13cc 100644 --- a/source/RobotAPI/libraries/armem/server/query_proc/CoreSegmentQueryProcessor.cpp +++ b/source/RobotAPI/libraries/armem/server/query_proc/CoreSegmentQueryProcessor.cpp @@ -5,7 +5,7 @@ #include <ArmarXCore/core/logging/Logging.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> #include <RobotAPI/libraries/armem/core/error.h> @@ -36,7 +36,7 @@ namespace armarx::armem::query_proc void CoreSegmentQueryProcessor::process(workingmemory::CoreSegment& result, const armem::query::data::core::All& query, const workingmemory::CoreSegment& coreSegment) const { - for (const auto& [name, providerSegment] : coreSegment.providerSegments) + for (const auto& [name, providerSegment] : coreSegment.providerSegments()) { result.addProviderSegment(providerSegmentProcessor.process(query.providerSegmentQueries, providerSegment)); } @@ -60,7 +60,7 @@ namespace armarx::armem::query_proc const armem::query::data::core::Regex& query, const workingmemory::CoreSegment& coreSegment) const { std::regex regex(query.providerSegmentNameRegex); - for (const auto& [name, providerSegment] : coreSegment.providerSegments) + for (const auto& [name, providerSegment] : coreSegment.providerSegments()) { if (std::regex_search(providerSegment.name(), regex)) { diff --git a/source/RobotAPI/libraries/armem/server/query_proc/EntityQueryProcessor.cpp b/source/RobotAPI/libraries/armem/server/query_proc/EntityQueryProcessor.cpp index 48d40fb05..d840425d3 100644 --- a/source/RobotAPI/libraries/armem/server/query_proc/EntityQueryProcessor.cpp +++ b/source/RobotAPI/libraries/armem/server/query_proc/EntityQueryProcessor.cpp @@ -4,7 +4,7 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <RobotAPI/libraries/armem/core/error.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> namespace armarx::armem::query_proc @@ -79,8 +79,8 @@ namespace armarx::armem::query_proc return; } - size_t first = negativeIndexSemantics(query.first, entity.history.size()); - size_t last = negativeIndexSemantics(query.last, entity.history.size()); + size_t first = negativeIndexSemantics(query.first, entity.history().size()); + size_t last = negativeIndexSemantics(query.last, entity.history().size()); if (first <= last) { @@ -111,11 +111,11 @@ namespace armarx::armem::query_proc (void) query; // Returns an iterator pointing to the first element that is not less than (i.e. greater or equal to) key. - auto begin = min.toMicroSeconds() > 0 ? entity.history.lower_bound(min) : entity.history.begin(); + auto begin = min.toMicroSeconds() > 0 ? entity.history().lower_bound(min) : entity.history().begin(); // Returns an iterator pointing to the first element that is *greater than* key. - auto end = max.toMicroSeconds() > 0 ? entity.history.upper_bound(max) : entity.history.end(); + auto end = max.toMicroSeconds() > 0 ? entity.history().upper_bound(max) : entity.history().end(); - for (auto it = begin; it != end && it != entity.history.end(); ++it) + for (auto it = begin; it != end && it != entity.history().end(); ++it) { addResultSnapshot(result, it); } diff --git a/source/RobotAPI/libraries/armem/server/query_proc/MemoryQueryProcessor.cpp b/source/RobotAPI/libraries/armem/server/query_proc/MemoryQueryProcessor.cpp index c239b6c8b..1982845a0 100644 --- a/source/RobotAPI/libraries/armem/server/query_proc/MemoryQueryProcessor.cpp +++ b/source/RobotAPI/libraries/armem/server/query_proc/MemoryQueryProcessor.cpp @@ -6,7 +6,7 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <RobotAPI/libraries/armem/core/error.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> namespace armarx::armem::query_proc @@ -54,7 +54,7 @@ namespace armarx::armem::query_proc void MemoryQueryProcessor::process(workingmemory::Memory& result, const armem::query::data::memory::All& query, const workingmemory::Memory& memory) const { - for (const auto& [name, coreSegment] : memory.coreSegments) + for (const auto& [name, coreSegment] : memory.coreSegments()) { result.addCoreSegment(coreSegmentProcessor.process(query.coreSegmentQueries, coreSegment)); } @@ -76,7 +76,7 @@ namespace armarx::armem::query_proc void MemoryQueryProcessor::process(workingmemory::Memory& result, const armem::query::data::memory::Regex& query, const workingmemory::Memory& memory) const { std::regex regex(query.coreSegmentNameRegex); - for (const auto& [name, coreSegment] : memory.coreSegments) + for (const auto& [name, coreSegment] : memory.coreSegments()) { if (std::regex_search(coreSegment.name(), regex)) { diff --git a/source/RobotAPI/libraries/armem/server/query_proc/ProviderSegmentQueryProcessor.cpp b/source/RobotAPI/libraries/armem/server/query_proc/ProviderSegmentQueryProcessor.cpp index 8a07b2116..d6bc87a69 100644 --- a/source/RobotAPI/libraries/armem/server/query_proc/ProviderSegmentQueryProcessor.cpp +++ b/source/RobotAPI/libraries/armem/server/query_proc/ProviderSegmentQueryProcessor.cpp @@ -6,7 +6,7 @@ #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <RobotAPI/libraries/armem/core/error.h> -#include <RobotAPI/libraries/armem/core/ice_conversions.h> +#include <RobotAPI/libraries/armem/core/workingMemory/ice_conversions.h> namespace armarx::armem::query_proc @@ -36,7 +36,7 @@ namespace armarx::armem::query_proc void ProviderSegmentQueryProcessor::process(workingmemory::ProviderSegment& result, const armem::query::data::provider::All& query, const workingmemory::ProviderSegment& providerSegment) const { - for (const auto& [name, entity] : providerSegment.entities) + for (const auto& [name, entity] : providerSegment.entities()) { result.addEntity(entityProcessor.process(query.entityQueries, entity)); } @@ -60,7 +60,7 @@ namespace armarx::armem::query_proc const armem::query::data::provider::Regex& query, const workingmemory::ProviderSegment& providerSegment) const { std::regex regex(query.entityNameRegex); - for (const auto& [name, entity] : providerSegment.entities) + for (const auto& [name, entity] : providerSegment.entities()) { if (std::regex_search(entity.name(), regex)) { diff --git a/source/RobotAPI/libraries/armem/test/ArMemIceConversionsTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemIceConversionsTest.cpp index e139931d8..171e40614 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemIceConversionsTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemIceConversionsTest.cpp @@ -25,7 +25,10 @@ #define ARMARX_BOOST_TEST #include <RobotAPI/Test.h> +#include "../core/ice_conversions_templates.h" #include "../core/ice_conversions.h" +#include "../core/workingMemory/ice_conversions.h" + #include <iostream> #include <SimoxUtility/algorithm/get_map_keys_values.h> @@ -37,11 +40,11 @@ namespace aron = armarx::aron; BOOST_AUTO_TEST_CASE(test_entity) { - armem::Entity entity("entity"); + armem::workingmemory::Entity entity("entity"); std::vector<armem::Time> expectedTimestamps; - armem::EntitySnapshot snapshot; + armem::workingmemory::EntitySnapshot snapshot; snapshot.time() = armem::Time::milliSeconds(100); expectedTimestamps.push_back(snapshot.time()); entity.addSnapshot(snapshot); @@ -53,13 +56,19 @@ BOOST_AUTO_TEST_CASE(test_entity) armem::data::EntityPtr ice; armem::toIce(ice, entity); - armem::Entity entityOut; + BOOST_CHECK_EQUAL(ice->id.memoryName, entity.id.memoryName); + BOOST_CHECK_EQUAL(ice->id.coreSegmentName, entity.id.coreSegmentName); + BOOST_CHECK_EQUAL(ice->id.providerSegmentName, entity.id.providerSegmentName); + BOOST_CHECK_EQUAL(ice->id.entityName, entity.id.entityName); + + BOOST_CHECK_EQUAL(ice->history.size(), entity.history().size()); + + armem::workingmemory::Entity entityOut; armem::fromIce(ice, entityOut); - BOOST_CHECK_EQUAL(entityOut.history.size(), entity.history.size()); + BOOST_CHECK_EQUAL(entityOut.history().size(), entity.history().size()); std::vector<armem::Time> timestamps = entityOut.getTimestamps(); - BOOST_CHECK_EQUAL_COLLECTIONS(timestamps.begin(), timestamps.end(), - expectedTimestamps.begin(), expectedTimestamps.end()); + BOOST_CHECK_EQUAL_COLLECTIONS(timestamps.begin(), timestamps.end(), expectedTimestamps.begin(), expectedTimestamps.end()); } diff --git a/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp index 1cc71d15c..1370c0649 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemLTMTest.cpp @@ -102,8 +102,8 @@ namespace ArMemLTMTest BOOST_CHECK_EQUAL(providerSegment.name(), "TestProvider"); BOOST_CHECK(coreSegment.hasProviderSegment(providerSegment.name())); - coreSegment.aronType() = t1; - providerSegment.aronType() = t2; + //coreSegment.aronType() = t1; + //providerSegment.aronType() = t2; aron::typenavigator::ObjectNavigatorPtr t = t2 != nullptr ? t2 : t1; @@ -122,7 +122,7 @@ namespace ArMemLTMTest update.instancesData = q; update.timeCreated = armem::Time::now(); BOOST_CHECK_NO_THROW(providerSegment.update(update)); - BOOST_CHECK_EQUAL(providerSegment.entities.size(), 1); + BOOST_CHECK_EQUAL(providerSegment.entities().size(), 1); } BOOST_CHECK(providerSegment.hasEntity("TestEntity")); diff --git a/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp index 3d9588118..11bb8af09 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp @@ -119,17 +119,17 @@ BOOST_AUTO_TEST_CASE(test_segment_setup) update.timeCreated = armem::Time::milliSeconds(1000); BOOST_CHECK_NO_THROW(providerSegment.update(update)); - BOOST_CHECK_EQUAL(providerSegment.entities.size(), 1); + BOOST_CHECK_EQUAL(providerSegment.entities().size(), 1); BOOST_CHECK(providerSegment.hasEntity("image")); BOOST_CHECK(!providerSegment.hasEntity("other_image")); armem::workingmemory::Entity& entity = providerSegment.getEntity("image"); BOOST_CHECK_EQUAL(entity.name(), "image"); - BOOST_CHECK_EQUAL(entity.history.size(), 1); - BOOST_CHECK_EQUAL(entity.history.count(update.timeCreated), 1); + BOOST_CHECK_EQUAL(entity.history().size(), 1); + BOOST_CHECK_EQUAL(entity.history().count(update.timeCreated), 1); - armem::workingmemory::EntitySnapshot& entitySnapshot = entity.history.at(update.timeCreated); - BOOST_CHECK_EQUAL(entitySnapshot.instances.size(), update.instancesData.size()); + armem::workingmemory::EntitySnapshot& entitySnapshot = entity.history().at(update.timeCreated); + BOOST_CHECK_EQUAL(entitySnapshot.instances().size(), update.instancesData.size()); // Another update (on memory). @@ -137,16 +137,16 @@ BOOST_AUTO_TEST_CASE(test_segment_setup) update.instancesData = { std::make_shared<aron::datanavigator::DictNavigator>() }; update.timeCreated = armem::Time::milliSeconds(2000); memory.update(update); - BOOST_CHECK_EQUAL(entity.history.size(), 2); - BOOST_CHECK_EQUAL(entity.history.count(update.timeCreated), 1); - BOOST_CHECK_EQUAL(entity.history.at(update.timeCreated).instances.size(), update.instancesData.size()); + BOOST_CHECK_EQUAL(entity.history().size(), 2); + BOOST_CHECK_EQUAL(entity.history().count(update.timeCreated), 1); + BOOST_CHECK_EQUAL(entity.history().at(update.timeCreated).instances().size(), update.instancesData.size()); // A third update (on entity). update.instancesData = { std::make_shared<aron::datanavigator::DictNavigator>() }; update.timeCreated = armem::Time::milliSeconds(3000); entity.update(update); - BOOST_CHECK_EQUAL(entity.history.size(), 3); + BOOST_CHECK_EQUAL(entity.history().size(), 3); } @@ -166,32 +166,32 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_entity) entity.update(update); update.timeCreated = armem::Time::milliSeconds(3000); entity.update(update); - BOOST_CHECK_EQUAL(entity.history.size(), 3); + BOOST_CHECK_EQUAL(entity.history().size(), 3); // Now with maximum history size. entity.setMaxHistorySize(2); - BOOST_CHECK_EQUAL(entity.history.size(), 2); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(1000)), 0); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(2000)), 1); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(3000)), 1); + BOOST_CHECK_EQUAL(entity.history().size(), 2); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(1000)), 0); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(2000)), 1); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(3000)), 1); update.timeCreated = armem::Time::milliSeconds(4000); entity.update(update); - BOOST_CHECK_EQUAL(entity.history.size(), 2); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(2000)), 0); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(3000)), 1); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(4000)), 1); + BOOST_CHECK_EQUAL(entity.history().size(), 2); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(2000)), 0); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(3000)), 1); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(4000)), 1); // Disable maximum history size. entity.setMaxHistorySize(-1); update.timeCreated = armem::Time::milliSeconds(5000); entity.update(update); - BOOST_CHECK_EQUAL(entity.history.size(), 3); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(3000)), 1); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(4000)), 1); - BOOST_CHECK_EQUAL(entity.history.count(armem::Time::milliSeconds(5000)), 1); + BOOST_CHECK_EQUAL(entity.history().size(), 3); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(3000)), 1); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(4000)), 1); + BOOST_CHECK_EQUAL(entity.history().count(armem::Time::milliSeconds(5000)), 1); } @@ -220,22 +220,22 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment) update.timeCreated = armem::Time::milliSeconds(4000); providerSegment.update(update); - BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history.size(), 3); - BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history.size(), 4); + BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history().size(), 3); + BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history().size(), 4); // Employ maximum history size. providerSegment.setMaxHistorySize(3); - BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history.size(), 3); - BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history.size(), 3); + BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history().size(), 3); + BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history().size(), 3); providerSegment.setMaxHistorySize(2); - BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history.size(), 2); - BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history.size(), 2); + BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history().size(), 2); + BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history().size(), 2); providerSegment.setMaxHistorySize(3); - BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history.size(), 2); - BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history.size(), 2); + BOOST_CHECK_EQUAL(providerSegment.getEntity("A").history().size(), 2); + BOOST_CHECK_EQUAL(providerSegment.getEntity("B").history().size(), 2); // Add new entity. providerSegment.setMaxHistorySize(2); @@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment) // Check correctly inherited history size. BOOST_CHECK_EQUAL(providerSegment.getEntity("C").maxHistorySize, 2); // Check actual history size. - BOOST_CHECK_EQUAL(providerSegment.getEntity("C").history.size(), 2); + BOOST_CHECK_EQUAL(providerSegment.getEntity("C").history().size(), 2); // Remove maximum. providerSegment.setMaxHistorySize(-1); @@ -262,6 +262,6 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment) update.entityID.entityName = name; update.timeCreated = armem::Time::milliSeconds(5000); providerSegment.update(update); - BOOST_CHECK_EQUAL(providerSegment.getEntity(name).history.size(), 3); + BOOST_CHECK_EQUAL(providerSegment.getEntity(name).history().size(), 3); } } diff --git a/source/RobotAPI/libraries/armem/test/ArMemQueryBuilderTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemQueryBuilderTest.cpp index 5b9a09f09..c9dea813f 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemQueryBuilderTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemQueryBuilderTest.cpp @@ -27,7 +27,7 @@ #include <RobotAPI/Test.h> #include "../client/query/Builder.h" #include "../client/query/query_fns.h" -#include "../core/ice_conversions.h" +#include "../core/workingMemory/ice_conversions.h" #include <iostream> diff --git a/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp index 5c51491af..51227ab81 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp @@ -123,8 +123,8 @@ BOOST_AUTO_TEST_CASE(test_entity_Single_latest) { BOOST_CHECK_EQUAL(result.name(), entity.name()); BOOST_CHECK_EQUAL(result.size(), 1); - BOOST_CHECK_EQUAL(result.history.begin()->second.time(), entity.getLatestSnapshot().time()); - BOOST_CHECK_NE(&result.history.begin()->second, &entity.history.rbegin()->second); + BOOST_CHECK_EQUAL(result.history().begin()->second.time(), entity.getLatestSnapshot().time()); + BOOST_CHECK_NE(&result.history().begin()->second, &entity.history().rbegin()->second); } } @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(test_entity_Single_existing) { BOOST_CHECK_EQUAL(result.name(), entity.name()); BOOST_CHECK_EQUAL(result.size(), 1); - BOOST_CHECK_EQUAL(result.history.begin()->second.time(), armem::Time::microSeconds(3000)); + BOOST_CHECK_EQUAL(result.history().begin()->second.time(), armem::Time::microSeconds(3000)); } } @@ -165,8 +165,8 @@ BOOST_AUTO_TEST_CASE(test_entity_All) { BOOST_CHECK_EQUAL(result.name(), entity.name()); BOOST_CHECK_EQUAL(result.size(), entity.size()); - auto jt = entity.history.begin(); - for (auto it = result.history.begin(); it != result.history.end(); ++it, ++jt) + auto jt = entity.history().begin(); + for (auto it = result.history().begin(); it != result.history().end(); ++it, ++jt) { BOOST_CHECK_EQUAL(it->first, jt->first); BOOST_CHECK_EQUAL(it->second.time(), jt->second.time()); @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(test_entity_TimeRange_slice) BOOST_CHECK_EQUAL(result.size(), 2); - std::vector<armem::Time> times = simox::alg::get_keys(result.history); + std::vector<armem::Time> times = simox::alg::get_keys(result.history()); std::vector<armem::Time> expected { armem::Time::microSeconds(2000), armem::Time::microSeconds(3000) @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(test_entity_TimeRange_exact) BOOST_CHECK_EQUAL(result.size(), 3); - std::vector<armem::Time> times = simox::alg::get_keys(result.history); + std::vector<armem::Time> times = simox::alg::get_keys(result.history()); std::vector<armem::Time> expected { armem::Time::microSeconds(2000), armem::Time::microSeconds(3000), armem::Time::microSeconds(4000) @@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(test_entity_TimeRange_all) BOOST_CHECK_EQUAL(result.size(), entity.size()); - std::vector<armem::Time> times = simox::alg::get_keys(result.history); - std::vector<armem::Time> expected = simox::alg::get_keys(entity.history); + std::vector<armem::Time> times = simox::alg::get_keys(result.history()); + std::vector<armem::Time> expected = simox::alg::get_keys(entity.history()); BOOST_CHECK_EQUAL_COLLECTIONS(times.begin(), times.end(), expected.begin(), expected.end()); } } @@ -263,7 +263,7 @@ BOOST_AUTO_TEST_CASE(test_entity_TimeRange_from_start) BOOST_CHECK_EQUAL(result.size(), 2); - std::vector<armem::Time> times = simox::alg::get_keys(result.history); + std::vector<armem::Time> times = simox::alg::get_keys(result.history()); std::vector<armem::Time> expected { armem::Time::microSeconds(1000), armem::Time::microSeconds(2000) @@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(test_entity_TimeRange_to_end) BOOST_CHECK_EQUAL(result.size(), 3); - std::vector<armem::Time> times = simox::alg::get_keys(result.history); + std::vector<armem::Time> times = simox::alg::get_keys(result.history()); std::vector<armem::Time> expected { armem::Time::microSeconds(3000), armem::Time::microSeconds(4000), armem::Time::microSeconds(5000) @@ -338,8 +338,8 @@ BOOST_AUTO_TEST_CASE(test_entity_IndexRange_all_default) BOOST_CHECK_EQUAL(result.size(), entity.size()); - std::vector<armem::Time> times = simox::alg::get_keys(result.history); - std::vector<armem::Time> expected = simox::alg::get_keys(entity.history); + std::vector<armem::Time> times = simox::alg::get_keys(result.history()); + std::vector<armem::Time> expected = simox::alg::get_keys(entity.history()); BOOST_CHECK_EQUAL_COLLECTIONS(times.begin(), times.end(), expected.begin(), expected.end()); } @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(test_entity_IndexRange_slice) BOOST_CHECK_EQUAL(result.size(), 3); - std::vector<armem::Time> times = simox::alg::get_keys(result.history); + std::vector<armem::Time> times = simox::alg::get_keys(result.history()); std::vector<armem::Time> expected { armem::Time::microSeconds(2000), armem::Time::microSeconds(3000), armem::Time::microSeconds(4000) diff --git a/source/RobotAPI/libraries/armem/util/util.h b/source/RobotAPI/libraries/armem/util/util.h index e295131c2..675ac16e4 100644 --- a/source/RobotAPI/libraries/armem/util/util.h +++ b/source/RobotAPI/libraries/armem/util/util.h @@ -77,9 +77,9 @@ namespace armarx::armem // loop over all entities and their snapshots for (const auto &[s, entity] : entities) { - for (const auto &[ss, entitySnapshot] : entity.history) + for (const auto &[ss, entitySnapshot] : entity.history()) { - for (const auto& entityInstance : entitySnapshot.instances) + for (const auto& entityInstance : entitySnapshot.instances()) { const auto o = tryCast<AronClass>(entityInstance); @@ -129,16 +129,16 @@ namespace armarx::armem // loop over all entities and their snapshots for (const auto &[s, entity] : entities) { - if (entity.history.empty()) + if (entity.history().empty()) { ARMARX_WARNING << "Empty history for " << s; } - ARMARX_INFO << "History size: " << entity.history.size(); + ARMARX_INFO << "History size: " << entity.history().size(); - for (const auto &[ss, entitySnapshot] : entity.history) + for (const auto &[ss, entitySnapshot] : entity.history()) { - for (const auto& entityInstance : entitySnapshot.instances) + for (const auto& entityInstance : entitySnapshot.instances()) { const auto o = tryCast<AronClass>(entityInstance); diff --git a/source/RobotAPI/libraries/armem_gui/memory/TreeWidget.cpp b/source/RobotAPI/libraries/armem_gui/memory/TreeWidget.cpp index 1da781d09..cb3dc4671 100644 --- a/source/RobotAPI/libraries/armem_gui/memory/TreeWidget.cpp +++ b/source/RobotAPI/libraries/armem_gui/memory/TreeWidget.cpp @@ -225,27 +225,27 @@ namespace armarx::armem::gui::memory void TreeWidget::updateChildren(const armem::workingmemory::Memory& memory, QTreeWidgetItem* memoryItem) { - workingmemoryCoreSegmentBuilder.updateTree(memoryItem, memory.coreSegments); + workingmemoryCoreSegmentBuilder.updateTree(memoryItem, memory.coreSegments()); } void TreeWidget::updateChildren(const armem::workingmemory::CoreSegment& coreSeg, QTreeWidgetItem* coreSegItem) { - workingmemoryProvSegmentBuilder.updateTree(coreSegItem, coreSeg.providerSegments); + workingmemoryProvSegmentBuilder.updateTree(coreSegItem, coreSeg.providerSegments()); } void TreeWidget::updateChildren(const armem::workingmemory::ProviderSegment& provSeg, QTreeWidgetItem* provSegItem) { - workingmemoryEntityBuilder.updateTree(provSegItem, provSeg.entities); + workingmemoryEntityBuilder.updateTree(provSegItem, provSeg.entities()); } void TreeWidget::updateChildren(const armem::workingmemory::Entity& entity, QTreeWidgetItem* entityItem) { - workingmemorySnapshotBuilder.updateTree(entityItem, entity.history); + workingmemorySnapshotBuilder.updateTree(entityItem, entity.history()); } void TreeWidget::updateChildren(const armem::workingmemory::EntitySnapshot& snapshot, QTreeWidgetItem* snapshotItem) { - workingmemoryInstanceBuilder.updateTree(snapshotItem, snapshot.instances); + workingmemoryInstanceBuilder.updateTree(snapshotItem, snapshot.instances()); } void TreeWidget::updateChildren(const armem::workingmemory::EntityInstance& data, QTreeWidgetItem* dataItem) diff --git a/source/RobotAPI/libraries/armem_robot_localization/TransformReader.cpp b/source/RobotAPI/libraries/armem_robot_localization/TransformReader.cpp index 12d56558e..89f85100f 100644 --- a/source/RobotAPI/libraries/armem_robot_localization/TransformReader.cpp +++ b/source/RobotAPI/libraries/armem_robot_localization/TransformReader.cpp @@ -128,7 +128,7 @@ namespace armarx::armem // } - std::vector<std::string> TransformReader::buildTransformChain(const armem::Memory& memory, + std::vector<std::string> TransformReader::buildTransformChain(const armem::workingmemory::Memory& memory, const TransformQuery& query) const { ARMARX_DEBUG << "Building transform chain"; @@ -202,7 +202,7 @@ namespace armarx::armem return chain; } - inline Transform convertEntityToTransform(const armem::EntityInstance& item) + inline Transform convertEntityToTransform(const armem::workingmemory::EntityInstance& item) { aron::Transform aronTransform; aronTransform.fromAron(item.data()); @@ -271,14 +271,14 @@ namespace armarx::armem return simox::math::interpolatePose(posePreIt->transform, poseNextIt->transform, t); } - Eigen::Affine3f TransformReader::obtainTransform(const std::string& entityName, const armem::ProviderSegment& agentProviderSegment, const int64_t timestamp) const + Eigen::Affine3f TransformReader::obtainTransform(const std::string& entityName, const armem::workingmemory::ProviderSegment& agentProviderSegment, const int64_t timestamp) const { ARMARX_DEBUG << "getEntity:" + entityName; const auto& entity = agentProviderSegment.getEntity(entityName); - ARMARX_DEBUG << "History (size: " << entity.history.size() << ")" - << simox::alg::get_keys(entity.history); + ARMARX_DEBUG << "History (size: " << entity.history().size() << ")" + << simox::alg::get_keys(entity.history()); // if (entity.history.empty()) // { @@ -289,9 +289,9 @@ namespace armarx::armem std::vector<Transform> transforms; - transforms.reserve(entity.history.size()); + transforms.reserve(entity.history().size()); - const auto entitySnapshots = simox::alg::get_values(entity.history); + const auto entitySnapshots = simox::alg::get_values(entity.history()); std::transform(entitySnapshots.begin(), entitySnapshots.end(), std::back_inserter(transforms), @@ -329,13 +329,13 @@ namespace armarx::armem } std::vector<Eigen::Affine3f> - TransformReader::obtainTransforms(const armem::Memory& memory, + TransformReader::obtainTransforms(const armem::workingmemory::Memory& memory, const std::vector<std::string>& tfChain, const std::string& agent, const std::int64_t& timestamp) const { - ARMARX_DEBUG << "Core segments" << simox::alg::get_keys(memory.coreSegments); + ARMARX_DEBUG << "Core segments" << simox::alg::get_keys(memory.coreSegments()); const auto& agentProviderSegment = memory.getCoreSegment(properties.localizationMemoryName).getProviderSegment(agent); @@ -343,9 +343,9 @@ namespace armarx::armem ARMARX_DEBUG << "Provider segments" << simox::alg::get_keys( memory.getCoreSegment(properties.localizationMemoryName) - .providerSegments); + .providerSegments()); - ARMARX_DEBUG << "Entities: " << simox::alg::get_keys(agentProviderSegment.entities); + ARMARX_DEBUG << "Entities: " << simox::alg::get_keys(agentProviderSegment.entities()); try { diff --git a/source/RobotAPI/libraries/armem_robot_mapping/MappingDataReader.cpp b/source/RobotAPI/libraries/armem_robot_mapping/MappingDataReader.cpp index 6f57909c6..f5577f9ab 100644 --- a/source/RobotAPI/libraries/armem_robot_mapping/MappingDataReader.cpp +++ b/source/RobotAPI/libraries/armem_robot_mapping/MappingDataReader.cpp @@ -8,8 +8,6 @@ #include <ArmarXCore/core/logging/Logging.h> -#include <RobotAPI/libraries/armem/core/EntityInstance.h> -#include <RobotAPI/libraries/armem/core/EntitySnapshot.h> #include <RobotAPI/libraries/armem/util/util.h> #include <RobotAPI/libraries/armem_robot_mapping/aron/LaserScan.aron.generated.h> #include <RobotAPI/libraries/armem_robot_mapping/aron_conversions.h> @@ -120,7 +118,7 @@ namespace armarx::armem const auto& entities = qResult.memory.getCoreSegment(properties.mappingMemoryName) .getProviderSegment(query.agent) - .entities; + .entities(); auto laserScans = transformAllOfType<aron::LaserScanStamped>( entities, -- GitLab