Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018 Arm Limited. |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 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_COMMONOPTIONS |
| 25 | #define ARM_COMPUTE_TEST_COMMONOPTIONS |
| 26 | |
| 27 | #include "../instruments/Instruments.h" |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 28 | |
| 29 | #include "utils/command_line/CommandLineOptions.h" |
| 30 | #include "utils/command_line/CommandLineParser.h" |
| 31 | |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 32 | #include <memory> |
| 33 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace test |
| 37 | { |
| 38 | namespace framework |
| 39 | { |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 40 | class Printer; |
| 41 | enum class LogFormat; |
| 42 | enum class LogLevel; |
| 43 | |
| 44 | /** Common command line options used to configure the framework |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 45 | * |
| 46 | * The options in this object get populated when "parse()" is called on the parser used to construct it. |
| 47 | * The expected workflow is: |
| 48 | * |
| 49 | * CommandLineParser parser; |
| 50 | * CommonOptions options( parser ); |
| 51 | * parser.parse(argc, argv); |
| 52 | * if(options.log_level->value() > LogLevel::NONE) --> Use the options values |
| 53 | */ |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 54 | class CommonOptions |
| 55 | { |
| 56 | public: |
| 57 | /** Constructor |
| 58 | * |
| 59 | * @param[in,out] parser A parser on which "parse()" hasn't been called yet. |
| 60 | */ |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 61 | CommonOptions(arm_compute::utils::CommandLineParser &parser); |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 62 | /** Prevent instances of this class from being copy constructed */ |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 63 | CommonOptions(const CommonOptions &) = delete; |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 64 | /** Prevent instances of this class from being copied */ |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 65 | CommonOptions &operator=(const CommonOptions &) = delete; |
| 66 | /** Create the printers based on parsed command line options |
| 67 | * |
| 68 | * @pre "parse()" has been called on the parser used to construct this object |
| 69 | * |
| 70 | * @return List of printers |
| 71 | */ |
| 72 | std::vector<std::unique_ptr<Printer>> create_printers(); |
| 73 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 74 | arm_compute::utils::ToggleOption *help; /**< Show help option */ |
| 75 | arm_compute::utils::EnumListOption<InstrumentsDescription> *instruments; /**< Instruments option */ |
| 76 | arm_compute::utils::SimpleOption<int> *iterations; /**< Number of iterations option */ |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 77 | arm_compute::utils::EnumOption<LogFormat> *log_format; /**< Log format option */ |
| 78 | arm_compute::utils::SimpleOption<std::string> *log_file; /**< Log file option */ |
| 79 | arm_compute::utils::EnumOption<LogLevel> *log_level; /**< Logging level option */ |
| 80 | arm_compute::utils::ToggleOption *throw_errors; /**< Throw errors option */ |
| 81 | arm_compute::utils::ToggleOption *color_output; /**< Color output option */ |
| 82 | arm_compute::utils::ToggleOption *pretty_console; /**< Pretty console option */ |
| 83 | arm_compute::utils::SimpleOption<std::string> *json_file; /**< JSON output file option */ |
| 84 | arm_compute::utils::SimpleOption<std::string> *pretty_file; /**< Pretty output file option */ |
| 85 | std::vector<std::shared_ptr<std::ofstream>> log_streams; /**< Log streams */ |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // namespace framework |
| 89 | } // namespace test |
| 90 | } // namespace arm_compute |
| 91 | #endif /* ARM_COMPUTE_TEST_COMMONOPTIONS */ |