11#ifndef PROGRAM_RUNNER_H
22#define PROGRAM_RUNNER_H
33
4+ #include " prng.hpp"
45#include < cstdint>
5- #include < iostream>
66#include < cstdlib>
7- #include < optional>
8- #include < variant>
7+ #include < iostream>
98#include < map>
109#include < memory>
11- #include " prng.hpp"
10+ #include < optional>
11+ #include < variant>
1212
13- class ProgramRunner {
13+ class ProgramRunner {
1414public:
15- ProgramRunner (int argc, char ** argv, uint64_t warmup_iterations = 0 );
15+ ProgramRunner (int argc, char ** argv, uint64_t warmup_iterations = 0 );
1616
1717 struct ProgramStatus {
1818 std::optional<std::string> stdout_message;
@@ -33,12 +33,7 @@ class ProgramRunner {
3333 const std::string version = " 0.1" ;
3434 const std::string program_name = " randomizer" ;
3535
36-
37-
38-
39-
4036private:
41-
4237 enum class Algorithm {
4338 XORShift,
4439 LinearCongruentialGenerator,
@@ -47,17 +42,15 @@ class ProgramRunner {
4742 };
4843
4944 const std::map<std::string, Algorithm> algorithm_choices {
50- {" xorshift" , Algorithm::XORShift},
51- {" xor" , Algorithm::XORShift},
52- {" linear-congruential-generator" , Algorithm::LinearCongruentialGenerator},
53- {" lcg" , Algorithm::LinearCongruentialGenerator},
54- {" mersenne" , Algorithm::MersenneTwister},
55- {" mersenne-twister" , Algorithm::MersenneTwister},
56- {" mt" , Algorithm::MersenneTwister}
45+ { " xorshift" , Algorithm::XORShift },
46+ { " xor" , Algorithm::XORShift },
47+ { " linear-congruential-generator" , Algorithm::LinearCongruentialGenerator },
48+ { " lcg" , Algorithm::LinearCongruentialGenerator },
49+ { " mersenne" , Algorithm::MersenneTwister },
50+ { " mersenne-twister" , Algorithm::MersenneTwister },
51+ { " mt" , Algorithm::MersenneTwister }
5752 };
5853
59-
60-
6154 enum class ProgramBehaviour {
6255 Error,
6356 Help,
@@ -68,16 +61,16 @@ class ProgramRunner {
6861 };
6962
7063 const std::map<std::string, ProgramBehaviour> generation_types {
71- {" unit" , ProgramBehaviour::GenerateUnitNormal},
72- {" normal" , ProgramBehaviour::GenerateUnitNormal},
73- {" unit-normal" , ProgramBehaviour::GenerateUnitNormal},
74- {" normalized" , ProgramBehaviour::GenerateUnitNormal},
75- {" float" , ProgramBehaviour::GenerateFloating},
76- {" floating" , ProgramBehaviour::GenerateFloating},
77- {" decimal" , ProgramBehaviour::GenerateFloating},
78- {" floating-point" , ProgramBehaviour::GenerateFloating},
79- {" int" , ProgramBehaviour::GenerateInteger},
80- {" integer" , ProgramBehaviour::GenerateInteger}
64+ { " unit" , ProgramBehaviour::GenerateUnitNormal },
65+ { " normal" , ProgramBehaviour::GenerateUnitNormal },
66+ { " unit-normal" , ProgramBehaviour::GenerateUnitNormal },
67+ { " normalized" , ProgramBehaviour::GenerateUnitNormal },
68+ { " float" , ProgramBehaviour::GenerateFloating },
69+ { " floating" , ProgramBehaviour::GenerateFloating },
70+ { " decimal" , ProgramBehaviour::GenerateFloating },
71+ { " floating-point" , ProgramBehaviour::GenerateFloating },
72+ { " int" , ProgramBehaviour::GenerateInteger },
73+ { " integer" , ProgramBehaviour::GenerateInteger }
8174 };
8275
8376 struct RawArguments {
@@ -96,23 +89,21 @@ class ProgramRunner {
9689 std::optional<std::string> count_str;
9790 };
9891
99-
10092 // Defaults
10193
10294 static constexpr uint32_t DefaultCount = 1 ;
10395 static constexpr ProgramBehaviour DefaultGenerationType = ProgramBehaviour::GenerateInteger;
10496
105- static RawArguments parse_args (int argc, char ** argv);
106- void determine_program_configuration (const RawArguments & raw_args);
107- void determine_user_message_configuration (const bool error, const bool show_version, const bool show_help);
108- void determine_generation_range_configuration (const std::optional<std::string> & min_str, const std::optional<std::string> & max_str);
109- void determine_generation_type_configuration (const std::optional<std::string> & generation_type);
110- void determine_count_configuration (const std::optional<std::string> & count_str);
111- void determine_algorithm_configuration (const std::optional<std::string> & alg_str);
97+ static RawArguments parse_args (int argc, char ** argv);
98+ void determine_program_configuration (RawArguments const & raw_args);
99+ void determine_user_message_configuration (bool const error, bool const show_version, bool const show_help);
100+ void determine_generation_range_configuration (std::optional<std::string> const & min_str, std::optional<std::string> const & max_str);
101+ void determine_generation_type_configuration (std::optional<std::string> const & generation_type);
102+ void determine_count_configuration (std::optional<std::string> const & count_str);
103+ void determine_algorithm_configuration (std::optional<std::string> const & alg_str);
112104 void create_prng ();
113105 void warmup (uint64_t iterations);
114106
115-
116107 std::string error_string ();
117108 std::string help_string ();
118109 std::string version_string ();
@@ -131,9 +122,6 @@ class ProgramRunner {
131122 // Exit codes
132123 static constexpr int ExitCodeSuccess = 0 ;
133124 static constexpr int ExitCodeError = 1 ;
134-
135-
136-
137125};
138126
139127#endif
0 commit comments