From 6f7f1ea7d123b48c8b2ed11326e449841a747af6 Mon Sep 17 00:00:00 2001 From: Rainer Kartmann <rainer.kartmann@kit.edu> Date: Wed, 4 Sep 2019 12:56:34 +0200 Subject: [PATCH] Add VisuID::withName() --- .../core/visualization/DebugDrawerTopic.cpp | 5 +++++ .../libraries/core/visualization/DebugDrawerTopic.h | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp index ad714afa3..24db3fe0f 100644 --- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp +++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp @@ -23,6 +23,11 @@ namespace armarx layer(layer), name(name) {} + DebugDrawerTopic::VisuID DebugDrawerTopic::VisuID::withName(const std::string& newName) const + { + return VisuID(this->layer, newName); + } + std::ostream& operator<<(std::ostream& os, const DebugDrawerTopic::VisuID& rhs) { os << "Visu '" << rhs.name << "' on layer '" << rhs.layer << "'"; diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h index eba4ec519..2dd3b8f37 100644 --- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h +++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h @@ -162,6 +162,8 @@ namespace armarx */ struct VisuID { + public: + /// Empty constructor. VisuID(); @@ -175,11 +177,17 @@ namespace armarx VisuID(const Source& name) : VisuID(std::string(name)) {} - std::string layer = ""; ///< The layer name (empty by default). - std::string name = ""; ///< The visu name (empty by default). + + /// Get a `VisuID` with the given name and same layer as `*this. + VisuID withName(const std::string& name) const; /// Streams a short human-readable description of `rhs` to `os`. friend std::ostream& operator<<(std::ostream& os, const VisuID& rhs); + + public: + + std::string layer = ""; ///< The layer name (empty by default). + std::string name = ""; ///< The visu name (empty by default). }; -- GitLab