1#ifndef LIBPRESSIO_COMPRESSOR_IMPL_H
2#define LIBPRESSIO_COMPRESSOR_IMPL_H
9#include <std_compat/span.h>
32 metrics_plugin((plugin.metrics_plugin)?plugin.metrics_plugin->
clone(): nullptr)
40 pressio_configurable::operator=(plugin);
41 metrics_plugin = plugin.metrics_plugin->
clone();
50 metrics_plugin(std::move(plugin.metrics_plugin))
58 pressio_configurable::operator=(plugin);
59 metrics_plugin = std::move(plugin.metrics_plugin);
136 template <
class InputRandomAccessIterator,
137 class InputRandomAccessIteratorEnd,
138 class OutputRandomAccessIterator,
139 class OutputRandomAccessIteratorEnd
141 int compress_many(InputRandomAccessIterator in_begin, InputRandomAccessIteratorEnd in_end,
142 OutputRandomAccessIterator out_begin, OutputRandomAccessIteratorEnd out_end) {
144 compat::span<const pressio_data* const> inputs(in_begin, in_end);
145 compat::span<pressio_data*> outputs(out_begin, out_end);
154 if(metrics_plugin->
end_compress_many(inputs, outputs, ret) != 0 && metrics_errors_fatal) {
168 template <
class InputRandomAccessIterator,
169 class InputRandomAccessIteratorEnd,
170 class OutputRandomAccessIterator,
171 class OutputRandomAccessIteratorEnd
173 int decompress_many(InputRandomAccessIterator in_begin, InputRandomAccessIteratorEnd in_end,
174 OutputRandomAccessIterator out_begin, OutputRandomAccessIteratorEnd out_end) {
176 compat::span<const pressio_data* const> inputs(in_begin, in_end);
177 compat::span<pressio_data*> outputs(out_begin, out_end);
186 if(metrics_plugin->
end_decompress_many(inputs, outputs, ret) != 0 && metrics_errors_fatal) {
223 virtual std::shared_ptr<libpressio_compressor_plugin>
clone()=0;
229 void set_name(std::string
const& new_name)
override final;
290 virtual int decompress_many_impl(compat::span<const pressio_data* const>
const& inputs, compat::span<pressio_data* >& outputs);
295 virtual int compress_many_impl(compat::span<const pressio_data* const>
const& inputs, compat::span<pressio_data*> & outputs);
299 std::string metrics_id;
300 int32_t metrics_errors_fatal = 1;
301 int32_t metrics_copy_impl_results = 1;
320 plugin(compressor->clone()) {}
325 if(&compressor ==
this)
return *
this;
339 operator bool()
const {
356 std::shared_ptr<libpressio_compressor_plugin>
plugin;
Definition: compressor.h:22
libpressio_compressor_plugin(libpressio_compressor_plugin const &plugin)
Definition: compressor.h:30
virtual int set_options_impl(struct pressio_options const &options)=0
virtual int compress_impl(const pressio_data *input, struct pressio_data *output)=0
virtual int check_options_impl(struct pressio_options const &)
libpressio_compressor_plugin & operator=(libpressio_compressor_plugin const &plugin)
Definition: compressor.h:38
virtual int compress_many_impl(compat::span< const pressio_data *const > const &inputs, compat::span< pressio_data * > &outputs)
virtual ~libpressio_compressor_plugin()
struct pressio_options get_metrics_results() const
int check_options(struct pressio_options const &options) override final
virtual int decompress_many_impl(compat::span< const pressio_data *const > const &inputs, compat::span< pressio_data * > &outputs)
struct pressio_options get_options() const override final
struct pressio_options get_metrics_options() const
libpressio_compressor_plugin & operator=(libpressio_compressor_plugin &&plugin) noexcept
Definition: compressor.h:56
virtual struct pressio_options get_documentation_impl() const =0
libpressio_compressor_plugin(libpressio_compressor_plugin &&plugin) noexcept
Definition: compressor.h:48
virtual struct pressio_options get_metrics_results_impl() const
struct pressio_options get_documentation() const override final
int set_options(struct pressio_options const &options) override final
int set_metrics_options(struct pressio_options const &options)
void set_metrics(struct pressio_metrics &plugin)
virtual struct pressio_options get_configuration_impl() const =0
int compress(struct pressio_data const *input, struct pressio_data *output)
struct pressio_options get_configuration() const override final
void set_metrics(struct pressio_metrics &&plugin)
struct pressio_metrics && get_metrics() &&
void set_name(std::string const &new_name) override final
virtual struct pressio_options get_options_impl() const =0
int compress_many(InputRandomAccessIterator in_begin, InputRandomAccessIteratorEnd in_end, OutputRandomAccessIterator out_begin, OutputRandomAccessIteratorEnd out_end)
Definition: compressor.h:141
int decompress(struct pressio_data const *input, struct pressio_data *output)
virtual int decompress_impl(const pressio_data *input, struct pressio_data *output)=0
virtual std::shared_ptr< libpressio_compressor_plugin > clone()=0
int decompress_many(InputRandomAccessIterator in_begin, InputRandomAccessIteratorEnd in_end, OutputRandomAccessIterator out_begin, OutputRandomAccessIteratorEnd out_end)
Definition: compressor.h:173
int end_decompress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs, int rc)
int end_compress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs, int rc)
virtual std::unique_ptr< libpressio_metrics_plugin > clone()=0
int begin_decompress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs)
int begin_compress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs)
Definition: configurable.h:17
const char * error_msg() const
int set_error(int code, std::string const &msg)
Definition: versionable.h:11
interface for configurable types
interface for types which can report and have errors
an extension header for adding metrics plugins to libpressio
Definition: compressor.h:307
libpressio_compressor_plugin * operator->() const noexcept
Definition: compressor.h:349
pressio_compressor & operator=(pressio_compressor &&compressor) noexcept=default
std::shared_ptr< libpressio_compressor_plugin > plugin
Definition: compressor.h:356
pressio_compressor(pressio_compressor &&compressor)=default
pressio_compressor()=default
pressio_compressor(pressio_compressor const &compressor)
Definition: compressor.h:319
pressio_compressor(std::shared_ptr< libpressio_compressor_plugin > &&impl)
Definition: compressor.h:311
pressio_compressor & operator=(pressio_compressor const &compressor)
Definition: compressor.h:324
libpressio_compressor_plugin & operator*() const noexcept
Definition: compressor.h:344
Definition: metrics.h:270
Definition: options.h:352
interface for versionable types