From 0ac7864f76856a131f786439c4b85edff62df0a8 Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Tue, 20 Aug 2019 09:42:47 +0200
Subject: [PATCH] Add option to pass topic name

---
 .../core/visualization/DebugDrawerTopic.cpp    |  8 ++++----
 .../core/visualization/DebugDrawerTopic.h      | 18 ++++++++++++++----
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp
index 535731a1e..9103deeb6 100644
--- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp
+++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp
@@ -50,14 +50,14 @@ namespace armarx
         return topic;
     }
 
-    void DebugDrawerTopic::offeringTopic(ManagedIceObject& component) const
+    void DebugDrawerTopic::offeringTopic(ManagedIceObject& component, const std::string& topicNameOverride) const
     {
-        component.offeringTopic(TOPIC_NAME);
+        component.offeringTopic(topicNameOverride.empty() ? TOPIC_NAME : topicNameOverride);
     }
 
-    void DebugDrawerTopic::getTopic(ManagedIceObject& component)
+    void DebugDrawerTopic::getTopic(ManagedIceObject& component, const std::string& topicNameOverride)
     {
-        setTopic(component.getTopic<DebugDrawerInterfacePrx>(TOPIC_NAME));
+        setTopic(component.getTopic<DebugDrawerInterfacePrx>(topicNameOverride.empty() ? TOPIC_NAME : topicNameOverride));
     }
 
     const std::string& DebugDrawerTopic::getLayer() const
diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h
index 80ffd7686..0397cf28b 100644
--- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h
+++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h
@@ -218,10 +218,20 @@ namespace armarx
         /// Get the topic.
         DebugDrawerInterfacePrx getTopic() const;
 
-        /// Call offeringTopic([topicName]) on the given component.
-        void offeringTopic(ManagedIceObject& component) const;
-        /// Get the topic by calling getTopic([topicName]) on the given component.
-        void getTopic(ManagedIceObject& component);
+        /**
+         * @brief Call offeringTopic([topicName]) on the given component.
+         * @param component The component (`*this` when called from a component).
+         * @param topicNameOverride Optional override for the topic name. If left empty (default),
+         *      uses the standard topic name (see `TOPIC_NAME`).
+         */
+        void offeringTopic(ManagedIceObject& component, const std::string& topicNameOverride = "") const;
+        /**
+         * @brief Get the topic by calling getTopic([topicName]) on the given component.
+         * @param component The component (`*this` when called from a component).
+         * @param topicNameOverride Optional override for the topic name. If left empty (default),
+         *      uses the standard topic name (see `TOPIC_NAME`).
+         */
+        void getTopic(ManagedIceObject& component, const std::string& topicNameOverride = "");
 
         /// Get the default layer (used if no layer is passed to a method).
         const std::string& getLayer() const;
-- 
GitLab