AWViz-ROS
Loading...
Searching...
No Matches
topic_scanner.hpp
Go to the documentation of this file.
1// Copyright 2024 Kotaro Uetake.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef AWVIZ_COMMON__TOPIC_SCANNER_HPP_
16#define AWVIZ_COMMON__TOPIC_SCANNER_HPP_
17
18#include <rclcpp/rclcpp.hpp>
19
20#include <map>
21#include <string>
22#include <utility>
23#include <vector>
24
25namespace awviz_common
26{
34{
35public:
36 using TopicMap = std::map<std::string, std::vector<std::string>>;
37
41 ITopicScanner() = default;
42
43 virtual ~ITopicScanner() = default;
44
49 virtual TopicMap scan() const = 0;
50};
51
55class TopicScanner final : public ITopicScanner
56{
57public:
58 explicit TopicScanner(rclcpp::Node::SharedPtr node) : node_(std::move(node)) {}
59
60 TopicMap scan() const override { return node_->get_topic_names_and_types(); }
61
62private:
63 rclcpp::Node::SharedPtr node_;
64};
65} // namespace awviz_common
66
67#endif // AWVIZ_COMMON__TOPIC_SCANNER_HPP_
Simple topic scanning interface for ROS nodes.
Definition: topic_scanner.hpp:34
virtual ~ITopicScanner()=default
std::map< std::string, std::vector< std::string > > TopicMap
Definition: topic_scanner.hpp:36
virtual TopicMap scan() const =0
Scan current topics and return their names and types.
ITopicScanner()=default
Construct a new topic scanner interface.
Concrete topic scanner using rclcpp node discovery.
Definition: topic_scanner.hpp:56
TopicScanner(rclcpp::Node::SharedPtr node)
Definition: topic_scanner.hpp:58
TopicMap scan() const override
Scan current topics and return their names and types.
Definition: topic_scanner.hpp:60
Definition: display.hpp:32