AWViz-ROS
Loading...
Searching...
No Matches
display_spawner.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__DISPLAY_SPAWNER_HPP_
16#define AWVIZ_COMMON__DISPLAY_SPAWNER_HPP_
17
20
21#include <memory>
22#include <optional>
23#include <string>
24#include <unordered_map>
25
26namespace awviz_common
27{
28
33{
34public:
35 virtual ~IDisplaySpawner() = default;
36
43 virtual std::shared_ptr<Display> spawn(
44 const std::string & topic, const std::string & topic_type) = 0;
45
51 virtual std::optional<std::string> resolve_lookup_name(const std::string & topic_type) const = 0;
52};
53
57class DisplaySpawner final : public IDisplaySpawner
58{
59public:
61 rclcpp::Node::SharedPtr node, std::shared_ptr<rerun::RecordingStream> stream,
62 std::shared_ptr<std::unordered_map<std::string, std::string>> entity_roots);
63
64 std::shared_ptr<Display> spawn(
65 const std::string & topic, const std::string & topic_type) override;
66
67 std::optional<std::string> resolve_lookup_name(const std::string & topic_type) const override;
68
69private:
70 rclcpp::Node::SharedPtr node_;
71 std::shared_ptr<rerun::RecordingStream> stream_;
72 std::shared_ptr<std::unordered_map<std::string, std::string>> entity_roots_;
73 DisplayFactory factory_;
74};
75} // namespace awviz_common
76
77#endif // AWVIZ_COMMON__DISPLAY_SPAWNER_HPP_
Factory class for Display.
Definition: display_factory.hpp:35
Concrete spawner that uses DisplayFactory and standard topic properties.
Definition: display_spawner.hpp:58
std::optional< std::string > resolve_lookup_name(const std::string &topic_type) const override
Resolve a plugin lookup name for the given message type.
Definition: display_spawner.cpp:50
std::shared_ptr< Display > spawn(const std::string &topic, const std::string &topic_type) override
Spawn a display instance for the given topic and message type.
Definition: display_spawner.cpp:31
Interface for creating display instances from topic metadata.
Definition: display_spawner.hpp:33
virtual ~IDisplaySpawner()=default
virtual std::optional< std::string > resolve_lookup_name(const std::string &topic_type) const =0
Resolve a plugin lookup name for the given message type.
virtual std::shared_ptr< Display > spawn(const std::string &topic, const std::string &topic_type)=0
Spawn a display instance for the given topic and message type.
Definition: display.hpp:32