Seastar
High performance C++ framework for concurrent servers
|
A selection value, allows selection from multiple candidates.
The candidates objects are of an opaque type which may not accessible to whoever is choosing between the available candidates. This allows the user selecting between seastar internal types without exposing them. Each candidate has a name, which is what the users choose based on. Each candidate can also have an associated option_group containing related candidate-specific configuration options, allowing further configuring the selected candidate. The code exposing the candidates should document the concrete types these can be down-casted to.
#include <seastar/util/program-options.hh>
Classes | |
struct | candidate |
Public Types | |
using | deleter = std::function< void(T *)> |
using | value_handle = std::unique_ptr< T, deleter > |
using | candidates = std::vector< candidate > |
Public Member Functions | |
selection_value (option_group &group, std::string name, candidates candidates, std::string default_candidate, std::string description) | |
selection_value (option_group &group, std::string name, candidates candidates, std::string description) | |
selection_value (option_group &group, std::string name, unused) | |
Construct an unused value. | |
operator bool () const | |
Was there a candidate selected (default also counts)? | |
bool | defaulted () const |
Is the currently selected candidate the default one? | |
const std::string & | get_selected_candidate_name () const |
Get the name of the currently selected candidate (assumes there is one selected, see \operator bool()). | |
const option_group * | get_selected_candidate_opts () const |
Get the options of the currently selected candidate (assumes there is one selected, see \operator bool()). | |
option_group * | get_selected_candidate_opts () |
Get the options of the currently selected candidate (assumes there is one selected, see \operator bool()). | |
T & | get_selected_candidate () const |
option_group * | select_candidate (std::string candidate_name) |
option_group * | select_default_candidate (std::string candidate_name) |
bool | used () const |
const std::string & | name () const |
const std::string & | description () const |
void | describe (options_descriptor &descriptor) const |
void | mutate (options_mutator &mutator) |
Public Attributes | |
option_group * | _group |
bool | _used = true |
std::string | _name |
std::string | _description |
struct seastar::program_options::selection_value::candidate |
Class Members | ||
---|---|---|
string | name | |
unique_ptr< option_group > | opts | |
value_handle | value |
|
inline |
Construct a value.
group | - the group containing this value |
name | - the name of this value |
candidates | - the available candidates |
default_candidates | - the name of the default candidate |
description | - the description of the value |
|
inline |
Select a candidate.
candidate_name | - the name of the to-be-selected candidate. |
|
inline |
Select a candidate and make it the default.
candidate_name | - the name of the to-be-selected candidate. |