26 #error CODEC_VERSION must be set
29 #ifndef CODEC_VERSION_NAMESPACE
30 #error CODEC_VERSION_NAMESPACE must be set
33 #ifndef DCCL_DEFAULT_FIELD_CODEC_HEADER_H
34 #define DCCL_DEFAULT_FIELD_CODEC_HEADER_H
48 "Must use specialization of DefaultFieldCodecLoader");
53 static_assert(
sizeof(
TimeCodecLoader) == 0,
"Must use specialization of TimeCodecLoader");
58 static_assert(
sizeof(
StaticCodecLoader) == 0,
"Must use specialization of StaticCodecLoader");
64 "Must use specialization of PresenceCodecLoader");
70 "Must use specialization of VarBytesCodecLoader");
75 static_assert(
sizeof(
HashCodecLoader) == 0,
"Must use specialization of HashCodecLoader");
92 using namespace CODEC_VERSION_NAMESPACE;
93 using google::protobuf::FieldDescriptor;
95 std::string name = ::dccl::Codec::default_codec_name(CODEC_VERSION);
96 manager.
add<DefaultBoolCodec>(name);
97 manager.
add<DefaultStringCodec, FieldDescriptor::TYPE_STRING>(name);
98 manager.
add<DefaultBytesCodec, FieldDescriptor::TYPE_BYTES>(name);
99 manager.
add<DefaultEnumCodec>(name);
100 manager.
add<DefaultMessageCodec, FieldDescriptor::TYPE_MESSAGE>(name);
102 add<true, double, float, int32, int64, uint32, uint64>(manager);
106 template <
bool enable,
typename T,
typename... Types>
109 using namespace CODEC_VERSION_NAMESPACE;
110 std::string name = ::dccl::Codec::default_codec_name(CODEC_VERSION);
111 manager.
add<DefaultNumericFieldCodec<T>>(name);
113 add<enable, Types...>(manager);
124 const std::string& name =
"dccl.time" + std::to_string(CODEC_VERSION))
126 add<true, double, int64, uint64>(manager, name);
129 template <
bool enable,
typename T,
typename... Types>
132 using namespace CODEC_VERSION_NAMESPACE;
133 manager.
add<TimeCodec<T>>(name);
134 add<enable, Types...>(manager, name);
144 const std::string& name =
"dccl.static" + std::to_string(CODEC_VERSION))
146 add<true, std::string, double, float, int32, int64, uint32, uint64>(manager, name);
149 template <
bool enable,
typename T,
typename... Types>
152 using namespace CODEC_VERSION_NAMESPACE;
153 manager.
add<StaticCodec<T>>(name);
154 add<enable, Types...>(manager, name);
162 #if CODEC_VERSION >= 3
167 using namespace CODEC_VERSION_NAMESPACE;
168 using google::protobuf::FieldDescriptor;
170 manager.
add<PresenceBitCodec<DefaultBoolCodec>>(name_);
171 manager.
add<PresenceBitCodec<DefaultStringCodec>, FieldDescriptor::TYPE_STRING>(name_);
172 manager.
add<PresenceBitCodec<DefaultBytesCodec>, FieldDescriptor::TYPE_BYTES>(name_);
173 manager.
add<PresenceBitCodec<DefaultEnumCodec>>(name_);
176 manager.
add<DefaultMessageCodec, FieldDescriptor::TYPE_MESSAGE>(name_);
177 add<true, double, float, int32, int64, uint32, uint64>(manager);
180 template <
bool enable,
typename T,
typename... Types>
183 using namespace CODEC_VERSION_NAMESPACE;
184 std::string name = ::dccl::Codec::default_codec_name(CODEC_VERSION);
185 manager.
add<PresenceBitCodec<DefaultNumericFieldCodec<T>>>(name_);
186 add<enable, Types...>(manager);
189 template <
bool enable>
static void add(FieldCodecManagerLocal& manager) {}
192 static const std::string name_;
195 const std::string PresenceCodecLoader<CODEC_VERSION>::name_{
"dccl.presence" +
196 std::to_string(CODEC_VERSION)};
198 template <>
struct VarBytesCodecLoader<CODEC_VERSION>
200 static void add(FieldCodecManagerLocal& manager)
202 using namespace CODEC_VERSION_NAMESPACE;
203 manager.add<VarBytesCodec>(
"dccl.var_bytes" + std::to_string(CODEC_VERSION));
209 #if CODEC_VERSION >= 4
210 template <>
struct HashCodecLoader<CODEC_VERSION>
212 static void add(FieldCodecManagerLocal& manager, std::set<int> versions = {CODEC_VERSION})
214 using namespace CODEC_VERSION_NAMESPACE;
216 for (
int v : versions) manager.add<HashCodec>(
"dccl.hash" + std::to_string(v));
226 #undef CODEC_VERSION_NAMESPACE