Gazebo Sim

API Reference

8.10.0
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 
31 namespace gz
32 {
33 namespace sim
34 {
35 // Inline bracket to help doxygen filtering.
36 inline namespace GZ_SIM_VERSION_NAMESPACE {
37 namespace serializers
38 {
40 {
41  public:
42  static std::ostream &Serialize(std::ostream &_out, const std::string &_desc)
43  {
44  msgs::StringMsg msg;
45  msg.set_data(_desc);
46  msg.SerializeToOstream(&_out);
47  return _out;
48  }
49 
50  public:
52  {
53  msgs::StringMsg msg;
54  msg.ParsePartialFromIstream(&_in);
55  _desc = msg.data();
56  return _in;
57  }
58 };
59 } // namespace serializers
60 namespace components
61 {
66 using SemanticDescription = Component<std::string, class SemanticDescriptionTag,
67  serializers::StringSerializer>;
68 GZ_SIM_REGISTER_COMPONENT("gz_sim_components.SemanticDescription",
69  SemanticDescription)
70 } // namespace components
71 } // namespace GZ_SIM_VERSION_NAMESPACE
72 } // namespace sim
73 } // namespace gz
74 #endif