24 #ifndef GOBY_MIDDLEWARE_MARSHALLING_DCCL_H
25 #define GOBY_MIDDLEWARE_MARSHALLING_DCCL_H
37 class InterVehicleSubscription;
43 template <
typename DataType>
51 std::lock_guard<std::mutex>
lock(dccl_mutex_);
52 check_load<DataType>();
53 std::vector<char> bytes(codec().size(
msg), 0);
54 codec().encode(bytes.data(), bytes.size(),
msg);
65 static std::string
type_name(
const DataType& d = DataType())
67 return DataType::descriptor()->full_name();
73 template <
typename CharIterator>
74 static std::shared_ptr<DataType>
parse(CharIterator bytes_begin, CharIterator bytes_end,
75 CharIterator& actual_end,
78 std::lock_guard<std::mutex>
lock(dccl_mutex_);
79 check_load<DataType>();
80 auto msg = std::make_shared<DataType>();
81 actual_end = codec().decode(bytes_begin, bytes_end,
msg.get());
96 std::lock_guard<std::mutex>
lock(dccl_mutex_);
97 check_load<DataType>();
98 return codec().template id<DataType>();
115 std::lock_guard<std::mutex>
lock(dccl_mutex_);
116 check_load(
msg.GetDescriptor());
117 std::vector<char> bytes(codec().size(
msg), 0);
118 codec().encode(bytes.data(), bytes.size(),
msg);
133 static std::string
type_name(
const google::protobuf::Descriptor* desc)
135 return desc->full_name();
145 template <
typename CharIterator>
146 static std::shared_ptr<google::protobuf::Message>
147 parse(CharIterator bytes_begin, CharIterator bytes_end, CharIterator& actual_end,
148 const std::string&
type,
bool user_pool_first =
false)
150 std::lock_guard<std::mutex>
lock(dccl_mutex_);
152 auto msg = dccl::DynamicProtobufManager::new_protobuf_message<
153 std::shared_ptr<google::protobuf::Message>>(
type, user_pool_first);
155 check_load(
msg->GetDescriptor());
156 actual_end = codec().decode(bytes_begin, bytes_end,
msg.get());
161 static unsigned id(
const google::protobuf::Descriptor* desc)
163 std::lock_guard<std::mutex>
lock(dccl_mutex_);
165 return codec().id(desc);