HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_cliconfig.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include "dependencies/CLI11/CLI11.hpp"
5
6namespace hart
7{
8
9/// @brief Holds values set by the user via CLI interface
10/// @details It's mostly intended for the internal use, but you may access it in your own test cases as well
11/// @ingroup TestRunner
13{
14public:
15 /// @brief Get the singleton instance
17 {
18 static CLIConfig cfg;
19 return cfg;
20 }
21
22 /// @brief Inits the CLI arguments
24 {
25 app.add_option ("--data-root-path,-d", m_dataRootPath, "Data root path");
26 app.add_option ("--tags,-t", m_tags, "Test tags");
27 app.add_option ("--seed,-s", m_seed, "Random seed")->default_val (0);
28
29 app.add_option (
30 "--lin-decimals",
31 m_linDecimals,
32 "Number of displayed decimal places for samples' linear values in test output"
33 )->default_val (6);
34
35 app.add_option (
36 "--db-decimals",
37 m_dbDecimals,
38 "Number of displayed decimal places for values in decidels in test output"
39 )->default_val (1);
40
41 app.add_option (
42 "--sec-decimals",
43 m_secDecimals,
44 "Number of displayed decimal places for values in seconds in test output"
45 )->default_val (3);
46
47 app.add_option (
48 "--hz-decimals",
49 m_hzDecimals,
50 "Number of displayed decimal places for values in hertz in test output"
51 )->default_val (1);
52
53 app.add_option (
54 "--rad-decimals",
55 m_radDecimals,
56 "Number of displayed decimal places for values in radians in test output"
57 )->default_val (1);
58
59 app.add_option (
60 "--cents-decimals",
61 m_centsDecimals,
62 "Number of displayed decimal places for values in cents in test output"
63 )->default_val (0);
64
65 app.add_flag ("--run-generators,-g", m_runGeneratorsNotTests, "Run generators instead of tests");
66 app.add_flag ("--shuffle", m_shuffle, "Shuffle task order. Obeys --seed value.");
67 }
68
69 CLI::App& getCLIApp() { return app; }
70
71 /// @brief Get data root path set by a "`--data-root-path`,`-d`" argument
72 std::string getDataRootPath() { return m_dataRootPath; }
73
74 /// @brief Gets random seed set by a "`--seed`/`-s`" argument
75 /// @details You can use it in your test cases to keep your own random-ness dependent on the global random seed
76 uint_fast32_t getRandomSeed() { return m_seed; }
77
78 /// @see linPrecision
79 int getLinDecimals() { return m_linDecimals; }
80
81 /// @see dbPrecision
82 int getDbDecimals() { return m_dbDecimals; }
83
84 /// @see secPrecision
85 int getSecDecimals() { return m_secDecimals; }
86
87 /// @see hzPrecision
88 int getHzDecimals() { return m_hzDecimals; }
89
90 /// @see radPrecision
91 int getRadDecimals() { return m_radDecimals; }
92
93 /// @see centsPrecision
94 int getCentsDecimals() { return m_centsDecimals; }
95
96 bool shouldRunGenerators() { return m_runGeneratorsNotTests; }
97 bool shouldShuffleTasks() { return m_shuffle; }
98 std::string& getTags() { return m_tags; }
99
100private:
101 CLI::App app { "HART" };
102
103 std::string m_dataRootPath = ".";
104 std::string m_tags = "";
105 uint_fast32_t m_seed = 0;
106 bool m_runGeneratorsNotTests = false;
107 bool m_shuffle = false;
108
109 int m_linDecimals = 0;
110 int m_dbDecimals = 0;
111 int m_secDecimals = 0;
112 int m_hzDecimals = 0;
113 int m_radDecimals = 0;
114 int m_centsDecimals = 0;
115
116 CLIConfig() = default;
117};
118
119} // namespace hart
Holds values set by the user via CLI interface.
uint_fast32_t getRandomSeed()
Gets random seed set by a "`--seed`/`-s`" argument.
std::string getDataRootPath()
Get data root path set by a "`--data-root-path`,`-d`" argument.
CLI::App & getCLIApp()
void initCommandLineArgs()
Inits the CLI arguments.
std::string & getTags()
static CLIConfig & getInstance()
Get the singleton instance.