14 #ifndef odc_core_CodecFactory_H
15 #define odc_core_CodecFactory_H
24 #include "eckit/memory/NonCopyable.h"
35 class CodecBuilderBase;
37 template <
typename ByteOrder>
class DataStream;
54 template <
typename ByteOrder>
57 template <
typename ByteOrder>
62 mutable std::mutex
m_;
63 std::map<std::string, std::reference_wrapper<CodecBuilderBase>>
builders_;
89 template <
template <
typename>
class CODEC>
93 static_assert(CODEC<SameByteOrder>::codec_name() == CODEC<OtherByteOrder>::codec_name(),
"Invalid name");
104 return std::unique_ptr<Codec>(
new CODEC<SameByteOrder>(
type));
107 return std::unique_ptr<Codec>(
new CODEC<OtherByteOrder>(
type));
116 template <
template <
typename ByteOrder,
typename ValueType>
class CODEC_T>
128 return std::unique_ptr<Codec>(
new CODEC_T<SameByteOrder, int64_t>(
type));
130 return std::unique_ptr<Codec>(
new CODEC_T<SameByteOrder, double>(
type));
135 return std::unique_ptr<Codec>(
new CODEC_T<OtherByteOrder, int64_t>(
type));
137 return std::unique_ptr<Codec>(
new CODEC_T<OtherByteOrder, double>(
type));
144 template <
typename ByteOrder>
146 std::lock_guard<std::mutex> lock(
m_);
150 return it->second.get().make(ByteOrder(),
type);
153 template <
typename ByteOrder>
156 std::string codecName;
159 auto c = build<ByteOrder>(codecName,
type);
static ODBAPISettings & instance()
virtual std::unique_ptr< Codec > make(const OtherByteOrder &, api::ColumnType) const =0
CodecBuilderBase(const std::string &name)
virtual std::unique_ptr< Codec > make(const SameByteOrder &, api::ColumnType) const =0
std::unique_ptr< Codec > make(const SameByteOrder &, api::ColumnType type) const override
std::unique_ptr< Codec > make(const OtherByteOrder &, api::ColumnType type) const override
void deregister(const std::string &name, CodecBuilderBase &builder)
std::unique_ptr< Codec > build(const std::string &name, api::ColumnType type) const
std::map< std::string, std::reference_wrapper< CodecBuilderBase > > builders_
static CodecFactory & instance()
void enregister(const std::string &name, CodecBuilderBase &builder)
std::unique_ptr< Codec > load(DataStream< ByteOrder > &ds, api::ColumnType type) const
std::unique_ptr< Codec > make(const SameByteOrder &, api::ColumnType type) const override
std::unique_ptr< Codec > make(const OtherByteOrder &, api::ColumnType type) const override