Gazebo Sim

API Reference

9.5.0
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 auto result = msg.SerializeToOstream(&_out);
52 (void)result;
53 return _out;
54 }
55
56 public:
59 {
60 msgs::StringMsg_V msg;
61 if(!msg.ParsePartialFromIstream(&_in))
62 {
63 return _in;
64 }
65 _tags.clear();
66 for (const auto &item : msg.data())
67 {
68 _tags.push_back(item);
69 }
70 return _in;
71 }
72};
73} // namespace serializers
74//
75namespace components
76{
77
82using SemanticTags = Component<std::vector<std::string>, class SemanticTagsTag,
83 serializers::SemanticTagsSerializer>;
84GZ_SIM_REGISTER_COMPONENT("gz_sim_components.SemanticTags", SemanticTags)
85} // namespace components
86} // namespace GZ_SIM_VERSION_NAMESPACE
87} // namespace sim
88} // namespace gz
89#endif