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  INFO("Node list:");
29 
30  std::stringstream ss;
31  for(auto& node : nodes)
32  ss << " - '" << node->name() << "' (ns '" << node->namespaceString() << "')\n";
33  INFO(ss.str());
34 
35  for(auto& node : nodes)
36  {
37  if(node->namespaceString() != namespaceString)
38  continue;
39 
40  if(node->name() == name)
41  {
42  REQUIRE(!ret);
43  ret = node;
44  }
45  }
46 
47  REQUIRE(ret);
48  return ret;
49 }
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 Sat Jan 9 2021 03:35:43