From 2f88ed24f64c4a9a64569061a398064c14527a4b Mon Sep 17 00:00:00 2001 From: phesch <ulila@student.kit.edu> Date: Tue, 24 May 2022 20:48:53 +0200 Subject: [PATCH] Replace PredictionEngineSeq in Memory impl --- .../libraries/armem/core/base/CoreSegmentBase.h | 6 +++--- .../libraries/armem/core/base/MemoryBase.h | 4 ++-- .../armem/core/base/ProviderSegmentBase.h | 16 ++++++++-------- .../armem/core/base/detail/Predictive.h | 12 ++++++------ .../armem/server/MemoryToIceAdapter.cpp | 14 +++++--------- .../server/segment/SpecializedCoreSegment.cpp | 4 ++-- .../server/segment/SpecializedCoreSegment.h | 6 +++--- .../segment/SpecializedProviderSegment.cpp | 6 +++--- .../server/segment/SpecializedProviderSegment.h | 8 ++++---- 9 files changed, 36 insertions(+), 40 deletions(-) diff --git a/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h b/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h index d7dfcfea9..a0139d9f4 100644 --- a/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h +++ b/source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h @@ -70,20 +70,20 @@ namespace armarx::armem::base } explicit CoreSegmentBase(const std::string& name, aron::type::ObjectPtr aronType = nullptr, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : CoreSegmentBase(name, MemoryID(), aronType, predictionEngines) { } explicit CoreSegmentBase(const std::string& name, const MemoryID& parentID, aron::type::ObjectPtr aronType = nullptr, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : CoreSegmentBase(parentID.withCoreSegmentName(name), aronType, predictionEngines) { } explicit CoreSegmentBase(const MemoryID& id, aron::type::ObjectPtr aronType = nullptr, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : Base(id), AronTyped(aronType), detail::Predictive<_Derived>(predictionEngines) { } diff --git a/source/RobotAPI/libraries/armem/core/base/MemoryBase.h b/source/RobotAPI/libraries/armem/core/base/MemoryBase.h index dd8d93c1c..947b459af 100644 --- a/source/RobotAPI/libraries/armem/core/base/MemoryBase.h +++ b/source/RobotAPI/libraries/armem/core/base/MemoryBase.h @@ -70,12 +70,12 @@ namespace armarx::armem::base { } explicit MemoryBase(const std::string& name, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : MemoryBase(MemoryID().withMemoryName(name), predictionEngines) { } explicit MemoryBase(const MemoryID& id, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : Base(id), detail::Predictive<_Derived>(predictionEngines) { } diff --git a/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h b/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h index 88485aafd..c380ab3ef 100644 --- a/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h +++ b/source/RobotAPI/libraries/armem/core/base/ProviderSegmentBase.h @@ -3,7 +3,7 @@ #include <map> #include <string> -#include <RobotAPI/interface/armem/prediction.h> +#include <RobotAPI/libraries/armem/core/Prediction.h> #include "EntityBase.h" #include "detail/AronTyped.h" @@ -57,7 +57,7 @@ namespace armarx::armem::base private: - prediction::data::PredictionEngineSeq supportedEngines; + std::vector<PredictionEngine> supportedEngines; public: @@ -68,7 +68,7 @@ namespace armarx::armem::base explicit ProviderSegmentBase( const std::string& name, aron::type::ObjectPtr aronType = nullptr, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : ProviderSegmentBase(name, MemoryID(), aronType, predictionEngines) { } @@ -76,14 +76,14 @@ namespace armarx::armem::base const std::string& name, const MemoryID parentID, aron::type::ObjectPtr aronType = nullptr, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : ProviderSegmentBase(parentID.withProviderSegmentName(name), aronType, predictionEngines) { } explicit ProviderSegmentBase( const MemoryID id, aron::type::ObjectPtr aronType = nullptr, - const prediction::data::PredictionEngineSeq& predictionEngines = {}) : + const std::vector<PredictionEngine>& predictionEngines = {}) : Base(id), AronTyped(aronType), supportedEngines(predictionEngines) { } @@ -300,13 +300,13 @@ namespace armarx::armem::base } // PREDICTION ENGINES - prediction::data::PredictionEngineSeq& + std::vector<PredictionEngine>& predictionEngines() { return supportedEngines; } - std::map<MemoryID, prediction::data::PredictionEngineSeq> + std::map<MemoryID, std::vector<PredictionEngine>> getAllPredictionEngines() { auto engines = predictionEngines(); @@ -315,7 +315,7 @@ namespace armarx::armem::base return {}; } // Type inference fails when using initializer lists here, not sure why. - std::map<MemoryID, prediction::data::PredictionEngineSeq> engineMap; + std::map<MemoryID, std::vector<PredictionEngine>> engineMap; engineMap.emplace(this->id(), engines); return engineMap; } diff --git a/source/RobotAPI/libraries/armem/core/base/detail/Predictive.h b/source/RobotAPI/libraries/armem/core/base/detail/Predictive.h index 096ba6429..3ab0cbdd8 100644 --- a/source/RobotAPI/libraries/armem/core/base/detail/Predictive.h +++ b/source/RobotAPI/libraries/armem/core/base/detail/Predictive.h @@ -22,8 +22,8 @@ #pragma once -#include <RobotAPI/interface/armem/prediction.h> #include <RobotAPI/libraries/armem/core/MemoryID.h> +#include <RobotAPI/libraries/armem/core/Prediction.h> #include "derived.h" @@ -36,21 +36,21 @@ namespace armarx::armem::base::detail class Predictive { public: - explicit Predictive(const prediction::data::PredictionEngineSeq& engines = {}) : + explicit Predictive(const std::vector<PredictionEngine>& engines = {}) : supportedEngines(engines) { } - prediction::data::PredictionEngineSeq& + std::vector<PredictionEngine>& predictionEngines() { return supportedEngines; } - std::map<MemoryID, prediction::data::PredictionEngineSeq> + std::map<MemoryID, std::vector<PredictionEngine>> getAllPredictionEngines() { - std::map<MemoryID, prediction::data::PredictionEngineSeq> engines; + std::map<MemoryID, std::vector<PredictionEngine>> engines; auto& derivedContainer = derived<DerivedT>(this); derivedContainer.forEachChild( [&engines](auto& child) @@ -68,6 +68,6 @@ namespace armarx::armem::base::detail } protected: - prediction::data::PredictionEngineSeq supportedEngines; + std::vector<PredictionEngine> supportedEngines; }; } // namespace armarx::armem::base::detail diff --git a/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp b/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp index 12610c2ac..a10a39818 100644 --- a/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp +++ b/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp @@ -363,20 +363,16 @@ namespace armarx::armem::server prediction::data::EngineSupportMap MemoryToIceAdapter::getAvailableEngines() { prediction::data::EngineSupportMap result; - auto wmMap = workingMemory->getAllPredictionEngines(); - for (const auto& [memoryID, engines] : wmMap) - { - result.emplace(armarx::toIce<data::MemoryID>(memoryID), engines); - } + armarx::toIce(result, workingMemory->getAllPredictionEngines()); - auto ltmMap = workingMemory->getAllPredictionEngines(); + prediction::data::EngineSupportMap ltmMap; + armarx::toIce(ltmMap, workingMemory->getAllPredictionEngines()); for (const auto& [memoryID, engines] : ltmMap) { - auto dtoID = armarx::toIce<data::MemoryID>(memoryID); - auto entryIter = result.find(dtoID); + auto entryIter = result.find(memoryID); if (entryIter == result.end()) { - result.emplace(armarx::toIce<data::MemoryID>(memoryID), engines); + result.emplace(memoryID, engines); } else { diff --git a/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.cpp b/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.cpp index e33009bbb..f0b330e7b 100644 --- a/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.cpp +++ b/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.cpp @@ -15,7 +15,7 @@ namespace armarx::armem::server::segment const std::string& defaultCoreSegmentName, aron::type::ObjectPtr coreSegmentAronType, int defaultMaxHistorySize, - const prediction::data::PredictionEngineSeq& predictionEngines) : + const std::vector<PredictionEngine>& predictionEngines) : Base(iceMemory), aronType(coreSegmentAronType), predictionEngines(predictionEngines), @@ -85,7 +85,7 @@ namespace armarx::armem::server::segment void SpecializedCoreSegment::setPredictionEngines( - const prediction::data::PredictionEngineSeq& predictionEngines) + const std::vector<PredictionEngine>& predictionEngines) { this->predictionEngines = predictionEngines; } diff --git a/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.h b/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.h index 059d9c7bc..5ddca3e7d 100644 --- a/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.h +++ b/source/RobotAPI/libraries/armem/server/segment/SpecializedCoreSegment.h @@ -28,7 +28,7 @@ namespace armarx::armem::server::segment const std::string& defaultCoreSegmentName = "", aron::type::ObjectPtr coreSegmentAronType = nullptr, int defaultMaxHistorySize = -1, - const prediction::data::PredictionEngineSeq& predictionEngines = {}); + const std::vector<PredictionEngine>& predictionEngines = {}); virtual ~SpecializedCoreSegment() override; @@ -45,7 +45,7 @@ namespace armarx::armem::server::segment void setDefaultMaxHistorySize(int64_t maxHistorySize); void setAronType(aron::type::ObjectPtr aronType); void - setPredictionEngines(const prediction::data::PredictionEngineSeq& predictionEngines); + setPredictionEngines(const std::vector<PredictionEngine>& predictionEngines); wm::CoreSegment& getCoreSegment(); const wm::CoreSegment& getCoreSegment() const; @@ -54,7 +54,7 @@ namespace armarx::armem::server::segment public: aron::type::ObjectPtr aronType; - prediction::data::PredictionEngineSeq predictionEngines; + std::vector<PredictionEngine> predictionEngines; struct Properties { diff --git a/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.cpp b/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.cpp index 541f5ce07..5d254afda 100644 --- a/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.cpp +++ b/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.cpp @@ -16,8 +16,8 @@ namespace armarx::armem::server::segment aron::type::ObjectPtr providerSegmentAronType, aron::type::ObjectPtr coreSegmentAronType, int defaultMaxHistorySize, - const prediction::data::PredictionEngineSeq& providerSegmentPredictionEngines, - const prediction::data::PredictionEngineSeq& coreSegmentPredictionEngines) : + const std::vector<PredictionEngine>& providerSegmentPredictionEngines, + const std::vector<PredictionEngine>& coreSegmentPredictionEngines) : Base(iceMemory), aronType(providerSegmentAronType), predictionEngines(providerSegmentPredictionEngines), @@ -95,7 +95,7 @@ namespace armarx::armem::server::segment void SpecializedProviderSegment::setPredictionEngines( - const prediction::data::PredictionEngineSeq& predictionEngines) + const std::vector<PredictionEngine>& predictionEngines) { this->predictionEngines = predictionEngines; } diff --git a/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.h b/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.h index f8ffa13c0..3cb50c52f 100644 --- a/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.h +++ b/source/RobotAPI/libraries/armem/server/segment/SpecializedProviderSegment.h @@ -30,8 +30,8 @@ namespace armarx::armem::server::segment aron::type::ObjectPtr providerSegmentAronType = nullptr, aron::type::ObjectPtr coreSegmentAronType = nullptr, int defaultMaxHistorySize = -1, - const prediction::data::PredictionEngineSeq& providerSegmentPredictionEngines = {}, - const prediction::data::PredictionEngineSeq& coreSegmentPredictionEngines = {}); + const std::vector<PredictionEngine>& providerSegmentPredictionEngines = {}, + const std::vector<PredictionEngine>& coreSegmentPredictionEngines = {}); virtual ~SpecializedProviderSegment() override; @@ -42,7 +42,7 @@ namespace armarx::armem::server::segment void setDefaultMaxHistorySize(int64_t maxHistorySize); void setAronType(aron::type::ObjectPtr aronType); void - setPredictionEngines(const prediction::data::PredictionEngineSeq& predictionEngines); + setPredictionEngines(const std::vector<PredictionEngine>& predictionEngines); wm::ProviderSegment& getProviderSegment(); const wm::ProviderSegment& getProviderSegment() const; @@ -51,7 +51,7 @@ namespace armarx::armem::server::segment public: aron::type::ObjectPtr aronType; - prediction::data::PredictionEngineSeq predictionEngines; + std::vector<PredictionEngine> predictionEngines; SpecializedCoreSegment coreSegment; struct Properties -- GitLab