Skip to content

Commit

Permalink
IndicesOption: Add function to initialize option by default
Browse files Browse the repository at this point in the history
  • Loading branch information
aartdem committed Nov 29, 2023
1 parent 3fcf006 commit de2671a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/core/config/indices/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ static void NormalizeIndices(config::IndicesType& indices) {
indices.erase(std::unique(indices.begin(), indices.end()), indices.end());
}

IndicesOption::IndicesOption(std::string_view name, std::string_view description)
: common_option_(name, description, {}, NormalizeIndices) {}
IndicesOption::IndicesOption(std::string_view name, std::string_view description,
typename Option<config::IndicesType>::DefaultFunc calculate_default)
: common_option_(name, description, {}, NormalizeIndices, nullptr,
std::move(calculate_default)) {}

std::string_view IndicesOption::GetName() const {
return common_option_.GetName();
Expand Down
3 changes: 2 additions & 1 deletion src/core/config/indices/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace config {

// This class is meant for creating options that are collections of indices.
struct IndicesOption {
IndicesOption(std::string_view name, std::string_view description);
IndicesOption(std::string_view name, std::string_view description,
typename Option<config::IndicesType>::DefaultFunc calculate_default = nullptr);

[[nodiscard]] std::string_view GetName() const;

Expand Down

0 comments on commit de2671a

Please sign in to comment.