AWViz-ROS
Loading...
Searching...
No Matches
display_factory.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_FACTORY_HPP_
16#define AWVIZ_COMMON__DISPLAY_FACTORY_HPP_
17
20
21#include <tinyxml2.h>
22
23#include <map>
24#include <optional>
25#include <set>
26#include <string>
27
28namespace awviz_common
29{
30
34class DisplayFactory : public PluginFactory<Display>
35{
36public:
38
39 ~DisplayFactory() = default;
40
47 const std::set<std::string> & get_message_types(const std::string & lookup_name);
48
56 std::optional<std::string> get_class_lookup_name(const std::string & msg_type) const;
57
58public:
59 static constexpr const char * LIBRARY_TAG = "library";
60 static constexpr const char * CLASS_TAG = "class";
61 static constexpr const char * MESSAGE_TYPE_TAG = "message_type";
62 static constexpr const char * TYPE_ATTRIBUTE = "type";
63 static constexpr const char * NAME_ATTRIBUTE = "name";
64
65private:
71 bool has_root_node(const tinyxml2::XMLElement * element) const;
72
78 bool has_library_root(const tinyxml2::XMLElement * element) const;
79
84 void cache_classes(const tinyxml2::XMLElement * library);
85
91 std::set<std::string> parse_message_types(const tinyxml2::XMLElement * element) const;
92
98 std::string lookup_derived_class(const tinyxml2::XMLElement * element) const;
99
106 std::string lookup_class_id(
107 const tinyxml2::XMLElement * element, const std::string & derived) const;
108
109private:
110 std::map<std::string, std::set<std::string>>
111 msg_type_buffer_;
113};
114} // namespace awviz_common
115#endif // AWVIZ_COMMON__DISPLAY_FACTORY_HPP_
Factory class for Display.
Definition: display_factory.hpp:35
static constexpr const char * LIBRARY_TAG
XML tag of library.
Definition: display_factory.hpp:59
std::optional< std::string > get_class_lookup_name(const std::string &msg_type) const
Get the Class Id of the corresponding message type.
Definition: display_factory.cpp:52
const std::set< std::string > & get_message_types(const std::string &lookup_name)
Get the set of declared message types.
Definition: display_factory.cpp:42
static constexpr const char * TYPE_ATTRIBUTE
XML attribute of type.
Definition: display_factory.hpp:62
static constexpr const char * CLASS_TAG
XML tag of class.
Definition: display_factory.hpp:60
DisplayFactory()
Definition: display_factory.cpp:19
static constexpr const char * NAME_ATTRIBUTE
XML attribute of name.
Definition: display_factory.hpp:63
static constexpr const char * MESSAGE_TYPE_TAG
XML tag of message type.
Definition: display_factory.hpp:61
Abstract base class representing a plugin load-able class factory.
Definition: plugin_factory.hpp:44
Definition: display.hpp:30