Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for fake.ksy #8

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src-fake-test/BuilderOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

#ifndef AWKWARD_BUILDEROPTIONS_H_
#define AWKWARD_BUILDEROPTIONS_H_

#include <cassert>
#include <cstring>
#include <tuple>
#include <type_traits>
#include <vector>
#include <stdint.h>

namespace awkward {

/// @class Options
///
/// @brief Container for all configuration options needed by ArrayBuilder,
/// GrowableBuffer, LayoutBuilder and the Builder subclasses.
template <typename... OPTIONS>
struct Options {
static constexpr std::size_t value = sizeof...(OPTIONS);

using OptionsPack = typename std::tuple<OPTIONS...>;

// FIXME:
// std::tuple_element_t is missing on some of the CI node compilers
//
// template<std::size_t INDEX>
// using OptionType = std::tuple_element_t<INDEX, OptionsPack>;

template <std::size_t INDEX>
using OptionType =
typename std::tuple_element<INDEX, decltype(OptionsPack())>::type;

/// @brief Creates an Options tuple from a full set of parameters.
Options(OPTIONS... options) : pars(options...) {}

/// @brief The initial number of
/// {@link GrowableBuffer#reserved reserved} entries for a GrowableBuffer.
int64_t
initial() const noexcept {
return option<0>();
}

/// @brief The factor with which a GrowableBuffer is resized
/// when its {@link GrowableBuffer#length length} reaches its
/// {@link GrowableBuffer#reserved reserved}.
double
resize() const noexcept {
return option<1>();
}

/// @brief Access to all other options.
template <std::size_t INDEX>
const OptionType<INDEX>&
option() const noexcept {
return std::get<INDEX>(pars);
}

OptionsPack pars;
};

using BuilderOptions = Options<int64_t, double>;
} // namespace awkward

#endif // AWKWARD_BUILDEROPTIONS_H_
Loading
Loading