Compute Library
 23.05
SimpleOption< T > Class Template Reference

Implementation of an option that accepts a single value. More...

#include <SimpleOption.h>

Collaboration diagram for SimpleOption< T >:
[legend]

Public Member Functions

 SimpleOption (std::string name, T default_value)
 Construct the option with the given default value. More...
 
bool parse (std::string value) override
 Parses the given string. More...
 
std::string help () const override
 Help message for the option. More...
 
const T & value () const
 Get the option value. More...
 
template<>
bool parse (std::string value)
 Parses the given string. More...
 
- Public Member Functions inherited from Option
 Option (std::string name)
 Constructor. More...
 
 Option (std::string name, bool is_required, bool is_set)
 Constructor. More...
 
virtual ~Option ()=default
 Default destructor. More...
 
std::string name () const
 Name of the option. More...
 
void set_required (bool is_required)
 Set whether the option is required. More...
 
void set_help (std::string help)
 Set the help message for the option. More...
 
bool is_required () const
 Is the option required? More...
 
bool is_set () const
 Has a value been assigned to the option? More...
 

Detailed Description

template<typename T>
class arm_compute::utils::SimpleOption< T >

Implementation of an option that accepts a single value.

Definition at line 39 of file SimpleOption.h.

Constructor & Destructor Documentation

◆ SimpleOption()

SimpleOption ( std::string  name,
default_value 
)
inline

Construct the option with the given default value.

Parameters
[in]nameName of the option.
[in]default_valueDefault value.

Definition at line 76 of file SimpleOption.h.

77  : Option{ std::move(name), false, true }, _value{ std::move(default_value) }
78 {
79 }
std::string name() const
Name of the option.
Definition: Option.h:115
Option(std::string name)
Constructor.
Definition: Option.h:105

Member Function Documentation

◆ help()

std::string help ( ) const
inlineoverridevirtual

Help message for the option.

Returns
String representing the help message for the specific subclass.

Implements Option.

Definition at line 106 of file SimpleOption.h.

107 {
108  return "--" + name() + "=VALUE - " + _help;
109 }
std::string name() const
Name of the option.
Definition: Option.h:115

◆ parse() [1/2]

bool parse ( std::string  value)
overridevirtual

Parses the given string.

Parameters
[in]valueString representation as passed on the command line.
Returns
True if the value could be parsed by the specific subclass.

Implements Option.

Definition at line 82 of file SimpleOption.h.

83 {
84  try
85  {
86  std::stringstream stream{ std::move(value) };
87  stream >> _value;
88  _is_set = !stream.fail();
89  return _is_set;
90  }
91  catch(const std::invalid_argument &)
92  {
93  return false;
94  }
95 }
const T & value() const
Get the option value.
Definition: SimpleOption.h:112

◆ parse() [2/2]

bool parse ( std::string  value)
inlinevirtual

Parses the given string.

Parameters
[in]valueString representation as passed on the command line.
Returns
True if the value could be parsed by the specific subclass.

Implements Option.

Definition at line 98 of file SimpleOption.h.

99 {
100  _value = std::move(value);
101  _is_set = true;
102  return true;
103 }
const T & value() const
Get the option value.
Definition: SimpleOption.h:112

◆ value()

const T & value ( ) const
inline

Get the option value.

Returns
the option value.

Definition at line 112 of file SimpleOption.h.

Referenced by gemm_tuner::consume_common_gemm_example_parameters(), arm_compute::utils::consume_common_graph_parameters(), CommonOptions::create_printers(), main(), arm_compute::utils::run_example(), and GraphEdsr::setup().

113 {
114  return _value;
115 }

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