1#ifndef LIBPRESSSIO_SUBGROUP_MANAGER
2#define LIBPRESSSIO_SUBGROUP_MANAGER
4#include "std_compat/memory.h"
5#include "std_compat/span.h"
36 output_data_groups = tmp.
to_vector<
int>();
42 set(opts,
"subgroups:input_data_groups",
"which inputs get mapped to which sub compression operations");
43 set(opts,
"subgroups:output_data_groups",
"which outputs get mapped to which sub compression operations");
48 set(opts,
"subgroups:input_data_groups",
pressio_data(std::begin(input_data_groups), std::end(input_data_groups)));
49 set(opts,
"subgroups:output_data_groups",
pressio_data(std::begin(output_data_groups), std::end(output_data_groups)));
53 const char*
prefix()
const override {
63 template <
class U,
class V>
65 effective_input_group = normalize_data_group(input_data_groups, inputs.size());
66 effective_output_group = normalize_data_group(output_data_groups, outputs.size());
68 if(effective_input_group.size() != inputs.size()) {
69 return set_error(1,
"invalid input group");
71 if(effective_output_group.size() != outputs.size()) {
72 return set_error(1,
"invalid output group");
74 size_t num_groups = valid_data_groups(effective_input_group, effective_output_group);
76 return set_error(2,
"invalid data groups");
87 std::vector<pressio_data const*>
get_input_group(Span
const& inputs,
int idx)
const {
88 return make_data_group<pressio_data const*>(inputs, idx, effective_input_group);
98 return make_data_group<pressio_data*>(inputs, idx, effective_output_group);
105 return effective_input_group;
112 return effective_output_group;
118 template <
class T,
class Span>
119 static std::vector<T> make_data_group(Span
const& inputs,
int idx, std::vector<int>
const& data_groups) {
120 std::vector<T> data_group;
121 for (
size_t i = 0; i < inputs.size(); ++i) {
122 if(data_groups[i] == idx) {
123 data_group.push_back(inputs[i]);
128 static std::vector<int> normalize_data_group(std::vector<int>
const& data_group,
size_t size) {
129 std::vector<int> ret;
130 if(not data_group.empty()) {
134 std::iota(std::begin(ret), std::end(ret), 0);
142 static size_t valid_data_groups(std::vector<int>
const& effective_input_group, std::vector<int>
const& effective_output_group) {
143 std::set<int> s1(std::begin(effective_input_group), std::end(effective_input_group));
144 std::set<int> s2(std::begin(effective_output_group), std::end(effective_output_group));
145 return (s1 == s2)? s1.size(): 0;
148 std::vector<int> effective_input_group, effective_output_group;
149 std::vector<int> input_data_groups, output_data_groups;
Definition: configurable.h:17
enum pressio_options_key_status get(pressio_options const &options, StringType &&key, PointerType value) const
Definition: configurable.h:127
int set_error(int code, std::string const &msg)
Definition: subgroup_manager.h:28
struct pressio_options get_options() const override
Definition: subgroup_manager.h:46
std::vector< pressio_data * > get_output_group(Span const &inputs, int idx) const
Definition: subgroup_manager.h:97
std::vector< int > const & effective_input_groups() const
Definition: subgroup_manager.h:104
struct pressio_options get_documentation() const override
Definition: subgroup_manager.h:40
std::vector< pressio_data const * > get_input_group(Span const &inputs, int idx) const
Definition: subgroup_manager.h:87
std::vector< int > const & effective_output_groups() const
Definition: subgroup_manager.h:111
int set_options(const struct pressio_options &options) override
Definition: subgroup_manager.h:30
const char * prefix() const override
Definition: subgroup_manager.h:53
int normalize_and_validate(compat::span< U > const &inputs, compat::span< V > const &outputs)
Definition: subgroup_manager.h:64
an extension header for adding compressor plugins to libpressio
interface for configurable types
C++ pressio_data interface.
C++ interface to the compressor loader.
C++ pressio_options and pressio_option interfaces.
Compress, decompress, and configure pressio and lossless compressors.
an abstraction for a contagious memory region of a specified type
A set of options for a compressor.
@ pressio_options_key_set
Definition: pressio_options.h:29
std::vector< T > to_vector() const
Definition: data.h:484
Definition: options.h:352