Compute Library  17.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Option.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 ARM Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_TEST_OPTIONBASE
25 #define ARM_COMPUTE_TEST_OPTIONBASE
26 
27 #include <string>
28 
29 namespace arm_compute
30 {
31 namespace test
32 {
33 namespace framework
34 {
36 class Option
37 {
38 public:
43  Option(std::string name);
44 
51  Option(std::string name, bool is_required, bool is_set);
52 
54  virtual ~Option() = default;
55 
62  virtual bool parse(std::string value) = 0;
63 
68  virtual std::string help() const = 0;
69 
74  std::string name() const;
75 
80  void set_required(bool is_required);
81 
86  void set_help(std::string help);
87 
92  bool is_required() const;
93 
98  bool is_set() const;
99 
100 protected:
101  std::string _name;
102  bool _is_required{ false };
103  bool _is_set{ false };
104  std::string _help{};
105 };
106 } // namespace framework
107 } // namespace test
108 } // namespace arm_compute
109 #endif /* ARM_COMPUTE_TEST_OPTIONBASE */
void set_required(bool is_required)
Set whether the option is required.
Definition: Option.cpp:47
virtual std::string help() const =0
Help message for the option.
virtual bool parse(std::string value)=0
Parses the given string.
bool is_set() const
Has a value been assigned to the option?
Definition: Option.cpp:62
bool is_required() const
Is the option required?
Definition: Option.cpp:57
Abstract base class for a command line option.
Definition: Option.h:36
Option(std::string name)
Constructor.
Definition: Option.cpp:32
std::string name() const
Name of the option.
Definition: Option.cpp:42
void * value
Definition: hwc.hpp:269
virtual ~Option()=default
Default destructor.
void set_help(std::string help)
Set the help message for the option.
Definition: Option.cpp:52