24#ifndef GOBY_MIDDLEWARE_MARSHALLING_DCCL_H
25#define GOBY_MIDDLEWARE_MARSHALLING_DCCL_H
37class InterVehicleSubscription;
43template <
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);
const Descriptor * GetDescriptor() const
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg
Enumeration and helper functions for marshalling scheme identification.
static unsigned id()
Returns the DCCL ID.
static unsigned id(const google::protobuf::Message &d)
static std::shared_ptr< DataType > parse(CharIterator bytes_begin, CharIterator bytes_end, CharIterator &actual_end, const std::string &type=type_name())
Parse one DCCL message.
static std::string type_name(const DataType &d=DataType())
Full protobuf Message name (identical to Protobuf specialization)
static std::vector< char > serialize(const DataType &msg)
Serialize message using DCCL encoding.
static unsigned id(const google::protobuf::Descriptor *desc)
Returns the DCCL ID given a Protobuf Descriptor.
static std::string type_name(const google::protobuf::Descriptor *desc)
Full protobuf name from descriptor, including package (if one is defined).
static unsigned id(const google::protobuf::Message &d)
Returns the DCCL ID given an instantiated message.
static std::shared_ptr< google::protobuf::Message > parse(CharIterator bytes_begin, CharIterator bytes_end, CharIterator &actual_end, const std::string &type, bool user_pool_first=false)
Parse DCCL/Protobuf message (using DCCL decoding) given the Protobuf type name and assuming the messa...
static std::vector< char > serialize(const google::protobuf::Message &msg)
Serialize DCCL/Protobuf message (using DCCL encoding)
static std::string type_name(const google::protobuf::Message &d)
Full protobuf name from message instantiation, including package (if one is defined).
Class for parsing and serializing a given marshalling scheme. Must be specialized for a particular sc...
static std::string type_name()
The marshalling scheme specific string name for this type.
Wraps a dccl::Codec in a thread-safe way to make it usable by SerializerParserHelper.