libpressio 0.93.0
Loading...
Searching...
No Matches
metrics.h
Go to the documentation of this file.
1#ifndef PRESIO_METRIC_PLUGIN
2#define PRESIO_METRIC_PLUGIN
3
4#include <memory>
5#include <vector>
6#include "configurable.h"
7#include "errorable.h"
8#include "versionable.h"
9#include <std_compat/span.h>
10
11
12struct pressio_options;
13struct pressio_data;
14
23 public:
31 virtual ~libpressio_metrics_plugin()=default;
36 int begin_check_options(struct pressio_options const* options);
42 int end_check_options(struct pressio_options const* options, int rc);
51 int end_get_options(struct pressio_options const* ret);
52
61 int end_get_documentation(struct pressio_options const& ret);
70 int end_get_configuration(struct pressio_options const& ret);
75 int begin_set_options(struct pressio_options const& options);
81 int end_set_options(struct pressio_options const& options, int rc);
82
88 int begin_compress(const struct pressio_data * input, struct pressio_data const * output);
95 int end_compress(struct pressio_data const* input, pressio_data const * output, int rc);
101 int begin_decompress(struct pressio_data const* input, pressio_data const* output);
108 int end_decompress(struct pressio_data const* input, pressio_data const* output, int rc);
109
113 int begin_compress_many(compat::span<const pressio_data* const> const& inputs,
114 compat::span<const pressio_data* const> const& outputs);
115
119 int end_compress_many(compat::span<const pressio_data* const> const& inputs,
120 compat::span<const pressio_data* const> const& outputs, int rc);
121
125 int begin_decompress_many(compat::span<const pressio_data* const> const& inputs,
126 compat::span<const pressio_data* const> const& outputs);
127
131 int end_decompress_many(compat::span<const pressio_data* const> const& inputs,
132 compat::span<const pressio_data* const> const& outputs, int rc);
133
138
142 virtual pressio_options get_documentation() const final;
143
147 void set_name(std::string const& new_name) override final;
148
154
158 virtual std::unique_ptr<libpressio_metrics_plugin> clone()=0;
159
160protected:
165 virtual int begin_check_options_impl(struct pressio_options const* options);
171 virtual int end_check_options_impl(struct pressio_options const* options, int rc);
180 virtual int end_get_options_impl(struct pressio_options const* ret);
181
190 virtual int end_get_documentation_impl(struct pressio_options const& ret);
199 virtual int end_get_configuration_impl(struct pressio_options const& ret);
204 virtual int begin_set_options_impl(struct pressio_options const& options);
210 virtual int end_set_options_impl(struct pressio_options const& options, int rc);
211
217 virtual int begin_compress_impl(const struct pressio_data * input, struct pressio_data const * output);
224 virtual int end_compress_impl(struct pressio_data const* input, pressio_data const * output, int rc);
230 virtual int begin_decompress_impl(struct pressio_data const* input, pressio_data const* output);
237 virtual int end_decompress_impl(struct pressio_data const* input, pressio_data const* output, int rc);
238
242 virtual int begin_compress_many_impl(compat::span<const pressio_data* const> const& inputs,
243 compat::span<const pressio_data* const> const& outputs);
244
248 virtual int end_compress_many_impl(compat::span<const pressio_data* const> const& inputs,
249 compat::span<const pressio_data* const> const& outputs, int rc);
250
254 virtual int begin_decompress_many_impl(compat::span<const pressio_data* const> const& inputs,
255 compat::span<const pressio_data* const> const& outputs);
256
260 virtual int end_decompress_many_impl(compat::span<const pressio_data* const> const& inputs,
261 compat::span<const pressio_data* const> const& outputs, int rc);
262
263
264// virtual pressio_options get_metrics_results_impl(pressio_options const &options)=0;
265};
266
271
273 pressio_metrics(std::unique_ptr<libpressio_metrics_plugin>&& metrics): plugin(std::move(metrics)) {}
275 pressio_metrics(std::shared_ptr<libpressio_metrics_plugin>&& metrics): plugin(std::move(metrics)) {}
276
282 pressio_metrics(pressio_metrics const& metrics): plugin(metrics->clone()) {}
287 if(&metrics == this) return *this;
288 plugin = metrics->clone();
289 return *this;
290 }
299
300
302 libpressio_metrics_plugin* operator->() const noexcept {return plugin.get();}
304 libpressio_metrics_plugin& operator*() const noexcept {return *plugin;}
306 operator bool() const { return plugin.get() != nullptr; }
307
308 private:
309 std::shared_ptr<libpressio_metrics_plugin> plugin;
310};
311
315std::unique_ptr<libpressio_metrics_plugin> make_m_composite(std::vector<pressio_metrics>&& plugins);
316
317
318#endif
Definition: metrics.h:22
virtual pressio_options get_metrics_results(pressio_options const &options)=0
virtual pressio_options get_documentation_impl() const =0
int end_decompress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs, int rc)
int end_decompress(struct pressio_data const *input, pressio_data const *output, int rc)
virtual int begin_decompress_many_impl(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs)
virtual int end_compress_impl(struct pressio_data const *input, pressio_data const *output, int rc)
virtual int begin_get_configuration_impl()
int end_get_configuration(struct pressio_options const &ret)
virtual int end_check_options_impl(struct pressio_options const *options, int rc)
int begin_compress(const struct pressio_data *input, struct pressio_data const *output)
int end_get_documentation(struct pressio_options const &ret)
virtual int begin_compress_many_impl(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs)
virtual int begin_compress_impl(const struct pressio_data *input, struct pressio_data const *output)
int end_compress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs, int rc)
virtual int end_compress_many_impl(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs, int rc)
int begin_check_options(struct pressio_options const *options)
virtual pressio_options get_documentation() const final
virtual int end_decompress_impl(struct pressio_data const *input, pressio_data const *output, int rc)
int end_set_options(struct pressio_options const &options, int rc)
int end_compress(struct pressio_data const *input, pressio_data const *output, int rc)
virtual std::unique_ptr< libpressio_metrics_plugin > clone()=0
virtual int end_get_documentation_impl(struct pressio_options const &ret)
virtual int begin_get_options_impl()
int begin_decompress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs)
int begin_set_options(struct pressio_options const &options)
int end_check_options(struct pressio_options const *options, int rc)
virtual int begin_decompress_impl(struct pressio_data const *input, pressio_data const *output)
int end_get_options(struct pressio_options const *ret)
virtual int end_decompress_many_impl(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs, int rc)
virtual int end_get_configuration_impl(struct pressio_options const &ret)
virtual int begin_get_documentation_impl()
int begin_decompress(struct pressio_data const *input, pressio_data const *output)
void set_name(std::string const &new_name) override final
virtual int end_get_options_impl(struct pressio_options const *ret)
virtual int begin_set_options_impl(struct pressio_options const &options)
virtual int begin_check_options_impl(struct pressio_options const *options)
virtual int end_set_options_impl(struct pressio_options const &options, int rc)
int begin_compress_many(compat::span< const pressio_data *const > const &inputs, compat::span< const pressio_data *const > const &outputs)
virtual ~libpressio_metrics_plugin()=default
Definition: configurable.h:17
enum pressio_options_key_status get(pressio_options const &options, StringType &&key, PointerType value) const
Definition: configurable.h:127
interface for configurable types
interface for types which can report and have errors
std::unique_ptr< libpressio_metrics_plugin > make_m_composite(std::vector< pressio_metrics > &&plugins)
Definition: data.h:52
Definition: metrics.h:270
pressio_metrics(pressio_metrics &&metrics)=default
pressio_metrics(std::unique_ptr< libpressio_metrics_plugin > &&metrics)
Definition: metrics.h:273
pressio_metrics & operator=(pressio_metrics const &metrics)
Definition: metrics.h:286
libpressio_metrics_plugin * operator->() const noexcept
Definition: metrics.h:302
pressio_metrics()=default
pressio_metrics(pressio_metrics const &metrics)
Definition: metrics.h:282
pressio_metrics & operator=(pressio_metrics &&metrics)=default
pressio_metrics(std::shared_ptr< libpressio_metrics_plugin > &&metrics)
Definition: metrics.h:275
libpressio_metrics_plugin & operator*() const noexcept
Definition: metrics.h:304
Definition: options.h:352
interface for versionable types