Gazebo Sim

API Reference

10.0.0~pre1
SemanticTags.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#ifndef GZ_SIM_COMPONENTS_SEMANTIC_TAGS_HH_
18#define GZ_SIM_COMPONENTS_SEMANTIC_TAGS_HH_
19
20#include <gz/msgs/stringmsg_v.pb.h>
21
22#include <istream>
23#include <ostream>
24#include <string>
25#include <vector>
26
29#include "gz/sim/config.hh"
30
31namespace gz
32{
33namespace sim
34{
35// Inline bracket to help doxygen filtering.
36inline namespace GZ_SIM_VERSION_NAMESPACE
37{
38namespace serializers
39{
41{
42 public:
44 const std::vector<std::string> &_tags)
45 {
46 msgs::StringMsg_V msg;
47 for (const auto &tag : _tags)
48 {
49 msg.add_data(tag);
50 }
51 msg.SerializeToOstream(&_out);
52 return _out;
53 }
54
55 public:
58 {
59 msgs::StringMsg_V msg;
60 msg.ParsePartialFromIstream(&_in);
61 _tags.clear();
62 for (const auto &item : msg.data())
63 {
64 _tags.push_back(item);
65 }
66 return _in;
67 }
68};
69} // namespace serializers
70//
71namespace components
72{
73
78using SemanticTags = Component<std::vector<std::string>, class SemanticTagsTag,
79 serializers::SemanticTagsSerializer>;
80GZ_SIM_REGISTER_COMPONENT("gz_sim_components.SemanticTags", SemanticTags)
81} // namespace components
82} // namespace GZ_SIM_VERSION_NAMESPACE
83} // namespace sim
84} // namespace gz
85#endif