24#ifndef GOBY_MIDDLEWARE_MARSHALLING_DETAIL_DCCL_SERIALIZER_PARSER_H
25#define GOBY_MIDDLEWARE_MARSHALLING_DETAIL_DCCL_SERIALIZER_PARSER_H
32#include <unordered_map>
36#include <dccl/codec.h>
37#include <dccl/dynamic_protobuf_manager.h>
56class SerializerProtobufMetadata;
65 static std::unique_ptr<dccl::Codec> codec_;
66 static std::vector<void*> loaded_libs_;
92 const google::protobuf::Descriptor* desc_;
95 static std::unordered_map<const google::protobuf::Descriptor*, std::unique_ptr<LoaderBase>>
102 const auto* desc = DataType::descriptor();
108 static void check_load(
const google::protobuf::Descriptor* desc)
112 std::make_pair(desc, std::unique_ptr<LoaderBase>(
new LoaderDynamic(desc))));
119 auto new_codec = std::make_unique<dccl::Codec>();
120 for (
void* handle : loaded_libs_) new_codec->load_library(handle);
121 codec_ = std::move(new_codec);
128 std::unique_ptr<dccl::Codec>
codec(new_codec);
129 for (
void* handle : loaded_libs_)
codec->load_library(handle);
132 codec_ = std::move(
codec);
142 template <
typename CharIterator>
static unsigned id(CharIterator begin, CharIterator end)
145 return codec().id(begin, end);
148 static unsigned id(
const std::string& full_name)
151 auto* desc = dccl::DynamicProtobufManager::find_descriptor(full_name);
154 return codec().id(desc);
186 const std::set<dccl::int32>& do_not_encrypt_ids = std::set<dccl::int32>())
188 codec().set_crypto_passphrase(passphrase, do_not_encrypt_ids);
detail namespace with internal helper functions
The global namespace for the Goby project.
util::FlexOstream glog
Access the Goby logger through this object.
virtual ~LoaderBase()=default
~LoaderDynamic() override
LoaderDynamic(const google::protobuf::Descriptor *desc)
Wraps a dccl::Codec in a thread-safe way to make it usable by SerializerParserHelper.
static dccl::Codec & codec()
static std::mutex dccl_mutex_
static unsigned id(const std::string &full_name)
static constexpr int INVALID_DCCL_ID
static void set_crypto_passphrase(const std::string &passphrase, const std::set< dccl::int32 > &do_not_encrypt_ids=std::set< dccl::int32 >())
static void load_library(void *dl_handle)
Load DCCL field codecs ("plugins") and compiled Protobuf messages from an already opened shared libra...
static void check_load(const google::protobuf::Descriptor *desc)
static dccl::Codec & set_codec(dccl::Codec *new_codec)
static std::set< std::string > loaded_proto_files_
DCCLSerializerParserHelperBase()=default
static void setup_dlog()
Enable dlog output to glog using same verbosity settings as glog.
static void load_library(const std::string &library)
Load DCCL field codecs ("plugins") and compiled Protobuf messages from one or more shared libraries.
static void load_metadata(const goby::middleware::protobuf::SerializerProtobufMetadata &meta)
static std::unordered_map< const google::protobuf::Descriptor *, std::unique_ptr< LoaderBase > > loader_map_
static goby::middleware::intervehicle::protobuf::DCCLForwardedData unpack(const std::string &bytes)
virtual ~DCCLSerializerParserHelperBase()=default
static unsigned id(CharIterator begin, CharIterator end)