17 #ifndef GZ_SIM_COMPONENTS_SERIALIZATION_HH_
18 #define GZ_SIM_COMPONENTS_SERIALIZATION_HH_
22 #pragma warning(disable: 4251)
25 #include <google/protobuf/message_lite.h>
31 #include <gz/msgs/double_v.pb.h>
35 #include <sdf/Sensor.hh>
38 #include <gz/msgs/Utility.hh>
48 inline namespace GZ_SIM_VERSION_NAMESPACE {
58 template <
typename In,
typename Out>
61 private:
template <
typename InArg,
typename OutArg>
62 static auto Test(
int _test)
63 -> decltype(std::declval<OutArg>() =
64 gz::sim::convert<OutArg>(std::declval<const InArg &>()),
67 private:
template <
typename,
typename>
70 public:
static constexpr
bool value =
71 decltype(Test<In, Out>(
true))::value;
107 template <
typename DataType,
typename MsgType>
115 const DataType &_data)
121 msg = gz::sim::convert<MsgType>(_data);
128 msg.SerializeToOstream(&_out);
140 msg.ParseFromIstream(&_in);
144 _data = gz::sim::convert<DataType>(msg);
169 msg.SerializeToOstream(&_out);
181 msg.ParseFromIstream(&_in);
183 _vec = {msg.
data().begin(), msg.
data().end()};
196 const google::protobuf::Message &_msg)
198 _msg.SerializeToOstream(&_out);
207 google::protobuf::Message &_msg)
209 _msg.ParseFromIstream(&_in);
240 template <
typename T>
250 _out << _data.
size();
251 for (
const auto& datum : _data)
252 _out <<
" " << datum;
266 for (
size_t i = 0; i < size; ++i)