blob: 25cf492b86673c7e573a145faed6ff23c8c66dc2 [file] [log] [blame]
Moritz Pflanzerbb4a79b2017-07-05 11:02:46 +01001/*
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
29namespace arm_compute
30{
31namespace test
32{
33namespace framework
34{
35/** Abstract base class for a command line option. */
36class Option
37{
38public:
39 /** Constructor.
40 *
41 * @param[in] name Name of the option.
42 */
43 Option(std::string name);
44
45 /** Constructor.
46 *
47 * @param[in] name Name of the option.
48 * @param[in] is_required Is the option required?
49 * @param[in] is_set Has a value been assigned to the option?
50 */
51 Option(std::string name, bool is_required, bool is_set);
52
53 /** Default destructor. */
54 virtual ~Option() = default;
55
56 /** Parses the given string.
57 *
58 * @param[in] value String representation as passed on the command line.
59 *
60 * @return True if the value could be parsed by the specific subclass.
61 */
62 virtual bool parse(std::string value) = 0;
63
64 /** Help message for the option.
65 *
66 * @return String representing the help message for the specific subclass.
67 */
68 virtual std::string help() const = 0;
69
70 /** Name of the option.
71 *
72 * @return Name of the option.
73 */
74 std::string name() const;
75
76 /** Set whether the option is required.
77 *
78 * @param[in] is_required Pass true if the option is required.
79 */
80 void set_required(bool is_required);
81
82 /** Set the help message for the option.
83 *
84 * @param[in] help Option specific help message.
85 */
86 void set_help(std::string help);
87
88 /** Is the option required?
89 *
90 * @return True if the option is required.
91 */
92 bool is_required() const;
93
94 /** Has a value been assigned to the option?
95 *
96 * @return True if a value has been set.
97 */
98 bool is_set() const;
99
100protected:
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 */