Gazebo Sim

API Reference

10.0.0~pre1
SemanticDescription.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_DESCRIPTION_HH_
18#define GZ_SIM_COMPONENTS_SEMANTIC_DESCRIPTION_HH_
19
20#include <gz/msgs/stringmsg.pb.h>
21
22#include <istream>
23#include <ostream>
24#include <string>
25
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:
43 static std::ostream &Serialize(std::ostream &_out, const std::string &_desc)
44 {
45 msgs::StringMsg msg;
46 msg.set_data(_desc);
47 msg.SerializeToOstream(&_out);
48 return _out;
49 }
50
51 public:
53 {
54 msgs::StringMsg msg;
55 msg.ParsePartialFromIstream(&_in);
56 _desc = msg.data();
57 return _in;
58 }
59};
60} // namespace serializers
61namespace components
62{
67using SemanticDescription = Component<std::string, class SemanticDescriptionTag,
68 serializers::StringSerializer>;
69GZ_SIM_REGISTER_COMPONENT("gz_sim_components.SemanticDescription",
70 SemanticDescription)
71} // namespace components
72} // namespace GZ_SIM_VERSION_NAMESPACE
73} // namespace sim
74} // namespace gz
75#endif