generic_service.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <ros/serialization.h>
7 #include <ros/service_traits.h>
8 
9 namespace foxglove_bridge {
10 
12  std::string type;
13  std::string md5sum;
14  std::vector<uint8_t> data;
15 
16  template <typename Stream>
17  inline void write(Stream& stream) const {
18  std::memcpy(stream.getData(), data.data(), data.size());
19  }
20 
21  template <typename Stream>
22  inline void read(Stream& stream) {
23  data.resize(stream.getLength());
24  std::memcpy(data.data(), stream.getData(), stream.getLength());
25  }
26 };
27 
28 } // namespace foxglove_bridge
29 
30 namespace ros::service_traits {
31 template <>
32 struct MD5Sum<foxglove_bridge::GenericService> {
33  static const char* value(const foxglove_bridge::GenericService& m) {
34  return m.md5sum.c_str();
35  }
36 
37  static const char* value() {
38  return "*";
39  }
40 };
41 
42 template <>
43 struct DataType<foxglove_bridge::GenericService> {
44  static const char* value(const foxglove_bridge::GenericService& m) {
45  return m.type.c_str();
46  }
47 
48  static const char* value() {
49  return "*";
50  }
51 };
52 } // namespace ros::service_traits
53 
54 namespace ros::serialization {
55 
56 template <>
57 struct Serializer<foxglove_bridge::GenericService> {
58  template <typename Stream>
59  inline static void write(Stream& stream, const foxglove_bridge::GenericService& m) {
60  m.write(stream);
61  }
62 
63  template <typename Stream>
64  inline static void read(Stream& stream, foxglove_bridge::GenericService& m) {
65  m.read(stream);
66  }
67 
68  inline static uint32_t serializedLength(const foxglove_bridge::GenericService& m) {
69  return m.data.size();
70  }
71 };
72 } // namespace ros::serialization
static const char * value(const foxglove_bridge::GenericService &m)
static uint32_t serializedLength(const foxglove_bridge::GenericService &m)
static void write(Stream &stream, const foxglove_bridge::GenericService &m)
static const char * value(const foxglove_bridge::GenericService &m)
void write(Stream &stream) const
static void read(Stream &stream, foxglove_bridge::GenericService &m)


foxglove_bridge
Author(s): Foxglove
autogenerated on Mon Jul 3 2023 02:12:22