From 0327cab695a624cb43ef1d482efc6ffbefb5a1d0 Mon Sep 17 00:00:00 2001
From: Christoph Pohl <christoph.pohl@kit.edu>
Date: Wed, 29 Nov 2023 11:09:45 +0100
Subject: [PATCH] Add warnings and ice deprecations notices for loadLibFromPath
 and Package

In context of https://git.h2t.iar.kit.edu/sw/armarx-integration/robots/armar7/documentation/-/issues/85
---
 .../RobotUnitModuleControllerManagement.cpp         | 13 +++++++++++--
 .../units/RobotUnit/RobotUnitInterface.ice          |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp
index 6f0001391..e53bb97ef 100644
--- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp
+++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleControllerManagement.cpp
@@ -95,8 +95,11 @@ namespace armarx::RobotUnitModule
             std::stringstream ss;
             ss << "Requested controller class '" << className
                << "' unknown! Known classes:" << NJointControllerRegistry::getKeys()
-               << " (If this class exists in a different lib then load it via "
-                  "loadLibFromPath(path) or loadLibFromPackage(package, lib))";
+               << " (If this class exists in a different lib then load it in the property "
+                  "definitions of the RT-unit. DO NOT load it via "
+                  "loadLibFromPath(path) or loadLibFromPackage(package, lib)) (see "
+                  "https://git.h2t.iar.kit.edu/sw/armarx-integration/robots/armar7/documentation/-/"
+                  "issues/85)";
             ARMARX_ERROR << ss.str();
             throw InvalidArgumentException{ss.str()};
         }
@@ -303,6 +306,9 @@ namespace armarx::RobotUnitModule
     ControllerManagement::loadLibFromPath(const std::string& path, const Ice::Current&)
     {
         throwIfInControlThread(BOOST_CURRENT_FUNCTION);
+        ARMARX_WARNING << "Do not use this function as it has implications on the RT thread (see "
+                        "https://git.h2t.iar.kit.edu/sw/armarx-integration/robots/armar7/"
+                        "documentation/-/issues/85)";
         const bool result = getArmarXManager()->loadLibFromPath(path);
         ARMARX_INFO << "loadLibFromPath('" << path << "') -> " << result;
         return result;
@@ -314,6 +320,9 @@ namespace armarx::RobotUnitModule
                                              const Ice::Current&)
     {
         throwIfInControlThread(BOOST_CURRENT_FUNCTION);
+        ARMARX_WARNING << "Do not use this function as it has implications on the RT thread (see "
+                        "https://git.h2t.iar.kit.edu/sw/armarx-integration/robots/armar7/"
+                        "documentation/-/issues/85)";
         const bool result = getArmarXManager()->loadLibFromPackage(package, lib);
         ARMARX_INFO << "loadLibFromPackage('" << package << "', '" << lib << "') -> " << result;
         return result;
diff --git a/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice b/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice
index f59b43019..32bfba607 100644
--- a/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice
+++ b/source/RobotAPI/interface/units/RobotUnit/RobotUnitInterface.ice
@@ -284,7 +284,9 @@ module armarx
             void deactivateAndDeleteNJointControllers(Ice::StringSeq controllerInstanceNames)throws InvalidArgumentException, LogicError;
 
             //loading libs
+            ["deprecate:loadLibFromPath(string path) has dangerous implications on the RT thread. Use the scenario config instead to load additional libraries. See https://git.h2t.iar.kit.edu/sw/armarx-integration/robots/armar7/documentation/-/issues/85"]
             bool loadLibFromPath(string path);
+            ["deprecate:loadLibFromPackage(string package, string libname) has dangerous implications on the RT thread. Use the scenario config instead to load additional libraries. See https://git.h2t.iar.kit.edu/sw/armarx-integration/robots/armar7/documentation/-/issues/85"]
             bool loadLibFromPackage(string package, string libname);
         };
         interface RobotUnitSelfCollisionCheckerInterface
-- 
GitLab