From 3d05dba754fcf5ccaad00c62b26d7e42b4380f17 Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Wed, 28 Apr 2021 11:54:39 +0200
Subject: [PATCH] Fix names in server::ComponentPlugin

---
 .../server/ExampleMemory/ExampleMemory.cpp     | 10 +++++-----
 .../GeneralPurposeMemory.cpp                   |  2 +-
 .../armem/server/ObjectMemory/ObjectMemory.cpp | 12 +++++++-----
 .../RobotSensorMemory/RobotSensorMemory.cpp    |  6 +++---
 .../armem/server/SkillsMemory/SkillsMemory.cpp |  2 +-
 .../libraries/armem/server/ComponentPlugin.cpp | 18 +++++++++---------
 .../libraries/armem/server/ComponentPlugin.h   | 10 +++++-----
 .../armem/server/MemoryToIceAdapter.cpp        |  3 ++-
 8 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp
index a3c7f7bc8..8bd030bb8 100644
--- a/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp
+++ b/source/RobotAPI/components/armem/server/ExampleMemory/ExampleMemory.cpp
@@ -60,16 +60,16 @@ namespace armarx
 
     void ExampleMemory::onInitComponent()
     {
-        workingmemory.name() = p.memoryName;
+        workingMemory.name() = p.memoryName;
 
         // Usually, the memory server will specify a number of core segments with a specific aron type.
-        workingmemory.addCoreSegment("ExampleData", armem::example::ExampleData::toInitialAronType());
+        workingMemory.addCoreSegment("ExampleData", armem::example::ExampleData::toInitialAronType());
 
         // For illustration purposes, we add more segments (without types).
         bool trim = true;
         p.core.defaultCoreSegments = simox::alg::split(p.core._defaultSegmentsStr, ",", trim);
         p.core._defaultSegmentsStr.clear();
-        workingmemory.addCoreSegments(p.core.defaultCoreSegments);
+        workingMemory.addCoreSegments(p.core.defaultCoreSegments);
     }
 
     void ExampleMemory::onConnectComponent()
@@ -121,8 +121,8 @@ namespace armarx
         using namespace armarx::RemoteGui::Client;
 
         {
-            std::scoped_lock lock(workingmemoryMutex);
-            tab.memoryGroup = armem::server::MemoryRemoteGui().makeGroupBox(workingmemory);
+            std::scoped_lock lock(workingMemoryMutex);
+            tab.memoryGroup = armem::server::MemoryRemoteGui().makeGroupBox(workingMemory);
         }
 
         VBoxLayout root = {tab.memoryGroup, VSpacer()};
diff --git a/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.cpp b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.cpp
index 8247ab6f9..3b17f4fc8 100644
--- a/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.cpp
+++ b/source/RobotAPI/components/armem/server/GeneralPurposeMemory/GeneralPurposeMemory.cpp
@@ -50,7 +50,7 @@ namespace armarx
 
     void GeneralPurposeMemory::onInitComponent()
     {
-        workingmemory.name() = memoryName;
+        workingMemory.name() = memoryName;
     }
 
 
diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp
index 256cd79ee..18ccb6875 100644
--- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp
+++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp
@@ -46,8 +46,8 @@ namespace armarx::armem::server::obj
 
         const std::string prefix = "mem.";
 
-        memory.name() = defaultMemoryName;
-        defs->optional(memory.name(), prefix + "MemoryName", "Name of this memory server.");
+        workingMemory.name() = defaultMemoryName;
+        defs->optional(workingMemory.name(), prefix + "MemoryName", "Name of this memory server.");
 
         classSegment.defineProperties(defs, prefix + "cls.");
         instance::SegmentAdapter::defineProperties(defs, prefix + "inst.");
@@ -57,8 +57,10 @@ namespace armarx::armem::server::obj
 
     ObjectMemory::ObjectMemory() :
         server::ComponentPluginUser(),
-        instance::SegmentAdapter(server::ComponentPluginUser::iceMemory, server::ComponentPluginUser::memoryMutex),
-        classSegment(server::ComponentPluginUser::iceMemory, server::ComponentPluginUser::memoryMutex)
+        instance::SegmentAdapter(server::ComponentPluginUser::iceMemory,
+                                 server::ComponentPluginUser::workingMemoryMutex),
+        classSegment(server::ComponentPluginUser::iceMemory,
+                     server::ComponentPluginUser::workingMemoryMutex)
     {
     }
 
@@ -69,7 +71,7 @@ namespace armarx::armem::server::obj
 
     void ObjectMemory::onInitComponent()
     {
-        memory.name() = defaultMemoryName;
+        workingMemory.name() = defaultMemoryName;
 
         instance::SegmentAdapter::init();
 
diff --git a/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.cpp b/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.cpp
index 2293364c6..a719b42bf 100644
--- a/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.cpp
+++ b/source/RobotAPI/components/armem/server/RobotSensorMemory/RobotSensorMemory.cpp
@@ -71,7 +71,7 @@ namespace armarx
         robotStateComponentMemoryBatchSize = std::max((unsigned int) 1, robotStateComponentMemoryBatchSize);
         robotStateComponentPollFrequency = std::clamp(robotStateComponentPollFrequency, 1, ROBOT_STATE_COMPONENT_MAXIMUM_FREQUENCY);
 
-        workingmemory.name() = workingMemoryName;
+        workingMemory.name() = workingMemoryName;
     }
 
 
@@ -114,7 +114,7 @@ namespace armarx
     void RobotSensorMemory::setupRobotUnitSegment()
     {
         ARMARX_INFO << "Adding core segment " << robotUnitCoreSegmentName;
-        workingmemory.addCoreSegments({robotUnitCoreSegmentName});
+        workingMemory.addCoreSegments({robotUnitCoreSegmentName});
 
         ARMARX_INFO << "Adding provider segment " << robotUnitCoreSegmentName << "/" << robotUnitProviderSegmentName;
         armem::data::AddSegmentInput input;
@@ -379,7 +379,7 @@ namespace armarx
     void RobotSensorMemory::setupRobotStateComponentSegment()
     {
         ARMARX_INFO << "Adding core segment " << robotStateComponentCoreSegmentName;
-        workingmemory.addCoreSegments({robotStateComponentCoreSegmentName});
+        workingMemory.addCoreSegments({robotStateComponentCoreSegmentName});
 
         ARMARX_INFO << "Adding provider segment " << robotStateComponentCoreSegmentName << "/" << robotStateComponentProviderSegmentName;
         armem::data::AddSegmentInput input;
diff --git a/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp
index 4efdcbff7..295e2c6ae 100644
--- a/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp
+++ b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp
@@ -50,7 +50,7 @@ namespace armarx
 
     void SkillsMemory::onInitComponent()
     {
-        workingmemory.name() = memoryName;
+        workingMemory.name() = memoryName;
     }
 
 
diff --git a/source/RobotAPI/libraries/armem/server/ComponentPlugin.cpp b/source/RobotAPI/libraries/armem/server/ComponentPlugin.cpp
index c5aff2156..536c72f49 100644
--- a/source/RobotAPI/libraries/armem/server/ComponentPlugin.cpp
+++ b/source/RobotAPI/libraries/armem/server/ComponentPlugin.cpp
@@ -41,7 +41,7 @@ namespace armarx::armem::server::plugins
         settings.user = longTermMemoryDatabaseUser;
         settings.password = longTermMemoryDatabasePassword;
 
-        parent.longtermmemory.reload(settings);
+        parent.longtermMemory.reload(settings);
     }
 
 
@@ -58,7 +58,7 @@ namespace armarx::armem::server::plugins
     data::RegisterMemoryResult ComponentPlugin::registerMemory(ComponentPluginUser& parent)
     {
         data::RegisterMemoryInput input;
-        input.name = parent.workingmemory.name();
+        input.name = parent.workingMemory.name();
         input.proxy = MemoryInterfacePrx::checkedCast(parent.getProxy());
         ARMARX_CHECK_NOT_NULL(input.proxy);
         data::RegisterMemoryResult result = parent.memoryNameSystem->registerMemory(input);
@@ -81,7 +81,7 @@ namespace armarx::armem::server::plugins
         try
         {
             data::RemoveMemoryInput input;
-            input.name = parent.workingmemory.name();
+            input.name = parent.workingMemory.name();
             result = parent.memoryNameSystem->removeMemory(input);
             if (result.success)
             {
@@ -122,7 +122,7 @@ namespace armarx::armem::server
 
     data::AddSegmentsResult ComponentPluginUser::addSegments(const data::AddSegmentsInput& input, bool addCoreSegments)
     {
-        std::scoped_lock lock(workingmemoryMutex);
+        std::scoped_lock lock(workingMemoryMutex);
         data::AddSegmentsResult result = iceMemory.addSegments(input, addCoreSegments);
         return result;
     }
@@ -130,7 +130,7 @@ namespace armarx::armem::server
 
     data::CommitResult ComponentPluginUser::commit(const data::Commit& commitIce, const Ice::Current&)
     {
-        std::scoped_lock lock(workingmemoryMutex);
+        std::scoped_lock lock(workingMemoryMutex);
         return iceMemory.commit(commitIce);
     }
 
@@ -138,15 +138,15 @@ namespace armarx::armem::server
     // READING
     armem::query::data::Result ComponentPluginUser::query(const armem::query::data::Input& input, const Ice::Current&)
     {
-        std::scoped_lock lock(workingmemoryMutex);
+        std::scoped_lock lock(workingMemoryMutex);
         return iceMemory.query(input);
     }
 
     // LTM LOADING
     data::StoreResult ComponentPluginUser::store(const data::StoreInput& input, const Ice::Current&)
     {
-        std::scoped_lock lock(workingmemoryMutex);
-        std::scoped_lock lock2(longtermmemoryMutex);
+        std::scoped_lock lock(workingMemoryMutex);
+        std::scoped_lock lock2(longtermMemoryMutex);
         return iceMemory.store(input);
     }
 
@@ -154,7 +154,7 @@ namespace armarx::armem::server
     // LTM STORING
     armem::query::data::Result ComponentPluginUser::load(const armem::query::data::Input& input, const Ice::Current&)
     {
-        std::scoped_lock lock(longtermmemoryMutex);
+        std::scoped_lock lock(longtermMemoryMutex);
         return iceMemory.load(input);
     }
 
diff --git a/source/RobotAPI/libraries/armem/server/ComponentPlugin.h b/source/RobotAPI/libraries/armem/server/ComponentPlugin.h
index c051995c4..fc2154f59 100644
--- a/source/RobotAPI/libraries/armem/server/ComponentPlugin.h
+++ b/source/RobotAPI/libraries/armem/server/ComponentPlugin.h
@@ -96,11 +96,11 @@ namespace armarx::armem::server
 
     public:
         /// The actual memory.
-        wm::Memory workingmemory;
-        std::mutex workingmemoryMutex;
+        wm::Memory workingMemory;
+        std::mutex workingMemoryMutex;
 
-        ltm::Memory longtermmemory;
-        std::mutex longtermmemoryMutex;
+        ltm::Memory longtermMemory;
+        std::mutex longtermMemoryMutex;
 
         /// property defaults
         std::string memoryListenerDefaultName = "MemoryUpdates";
@@ -109,7 +109,7 @@ namespace armarx::armem::server
         std::string longTermMemoryDatabasePasswordDefault = "";
 
         /// Helps connecting `memory` to ice. Used to handle Ice callbacks.
-        MemoryToIceAdapter iceMemory { &workingmemory, &longtermmemory};
+        MemoryToIceAdapter iceMemory { &workingMemory, &longtermMemory};
 
 
     private:
diff --git a/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp b/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp
index 259c0ca97..6895cf4e5 100644
--- a/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp
+++ b/source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp
@@ -12,7 +12,8 @@
 namespace armarx::armem::server
 {
 
-    MemoryToIceAdapter::MemoryToIceAdapter(wm::Memory* workingmemory, ltm::Memory* longtermmemory) : workingMemory(workingmemory), longtermMemory(longtermmemory)
+    MemoryToIceAdapter::MemoryToIceAdapter(wm::Memory* workingMemory, ltm::Memory* longtermMemory) :
+        workingMemory(workingMemory), longtermMemory(longtermMemory)
     {
     }
 
-- 
GitLab