Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
seastar::program_options::selection_value< T > Class Template Reference

Detailed Description

template<typename T = std::monostate>
class seastar::program_options::selection_value< T >

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>

Inheritance diagram for seastar::program_options::selection_value< T >:
seastar::program_options::basic_value

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_groupget_selected_candidate_opts () const
 Get the options of the currently selected candidate (assumes there is one selected, see \operator bool()).
 
option_groupget_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_groupselect_candidate (std::string candidate_name)
 
option_groupselect_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
 

Class Documentation

◆ seastar::program_options::selection_value::candidate

struct seastar::program_options::selection_value::candidate
Class Members
string name
unique_ptr< option_group > opts
value_handle value

Constructor & Destructor Documentation

◆ selection_value()

template<typename T = std::monostate>
seastar::program_options::selection_value< T >::selection_value ( option_group group,
std::string  name,
candidates  candidates,
std::string  default_candidate,
std::string  description 
)
inline

Construct a value.

Parameters
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

Member Function Documentation

◆ select_candidate()

template<typename T = std::monostate>
option_group * seastar::program_options::selection_value< T >::select_candidate ( std::string  candidate_name)
inline

Select a candidate.

Parameters
candidate_name- the name of the to-be-selected candidate.

◆ select_default_candidate()

template<typename T = std::monostate>
option_group * seastar::program_options::selection_value< T >::select_default_candidate ( std::string  candidate_name)
inline

Select a candidate and make it the default.

Parameters
candidate_name- the name of the to-be-selected candidate.

The documentation for this class was generated from the following file: