node_utils.cpp
Go to the documentation of this file.
1 // Test utils for nodes
2 // Author: Max Schwarz <max.schwarz@ais.uni-bonn.de>
3 
4 #include "node_utils.h"
5 
6 #include <sstream>
7 
8 #include <catch_ros/catch.hpp>
9 
10 std::string printMapping(const std::map<std::string, std::string>& mapping)
11 {
12  std::stringstream ss;
13  ss << "{ ";
14  for(auto& pair : mapping)
15  {
16  ss << "'" << pair.first << "':='" << pair.second << "', ";
17  }
18  ss << "}";
19 
20  return ss.str();
21 }
22 
23 rosmon::launch::Node::Ptr getNode(const std::vector<rosmon::launch::Node::Ptr>& nodes, const std::string& name, const std::string& namespaceString)
24 {
26 
27  INFO("Looking for node '" << name << "' in namespace '" << namespaceString << "'");
28 
29  for(auto& node : nodes)
30  {
31  if(node->namespaceString() != namespaceString)
32  continue;
33 
34  if(node->name() == name)
35  {
36  REQUIRE(!ret);
37  ret = node;
38  }
39  }
40 
41  REQUIRE(ret);
42  return ret;
43 }
std::shared_ptr< Node > Ptr
Definition: node.h:23
rosmon::launch::Node::Ptr getNode(const std::vector< rosmon::launch::Node::Ptr > &nodes, const std::string &name, const std::string &namespaceString)
Definition: node_utils.cpp:23
std::string printMapping(const std::map< std::string, std::string > &mapping)
Definition: node_utils.cpp:10


rosmon_core
Author(s): Max Schwarz
autogenerated on Wed Jul 10 2019 03:10:12