@@ -39,6 +39,22 @@ enum TypeOfTask : uint8_t {
3939 kUnknown
4040};
4141
42+ constexpr std::pair<TypeOfTask, std::string_view> kTypeOfTaskStrings [] = {
43+ {TypeOfTask::kALL , " all" },
44+ {TypeOfTask::kMPI , " mpi" },
45+ {TypeOfTask::kOMP , " omp" },
46+ {TypeOfTask::kSEQ , " seq" },
47+ {TypeOfTask::kSTL , " stl" },
48+ {TypeOfTask::kTBB , " tbb" },
49+ };
50+
51+ inline std::string_view TypeOfTaskToString (TypeOfTask type) {
52+ for (const auto & [key, value] : kTypeOfTaskStrings ) {
53+ if (key == type) return value;
54+ }
55+ return " unknown" ;
56+ }
57+
4258enum class PipelineStage { None, Validation, PreProcessing, Run, Done };
4359
4460// / @brief Indicates whether a task is enabled or disabled.
@@ -64,7 +80,7 @@ inline std::string GetStringTaskStatus(StatusOfTask status_of_task) {
6480// / @param settings_file_path Path to the JSON file containing task type strings.
6581// / @return Formatted string combining the task type and its corresponding value from the file.
6682// / @throws std::runtime_error If the file cannot be opened.
67- inline std::string GetStringTaskType (TypeOfTask type_of_task, const std::string & settings_file_path) {
83+ inline std::string GetStringTaskType (TypeOfTask type_of_task, const std::string& settings_file_path) {
6884 std::ifstream file (settings_file_path);
6985 if (!file.is_open ()) {
7086 throw std::runtime_error (" Failed to open " + settings_file_path);
@@ -73,26 +89,12 @@ inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string
7389 auto list_settings = ppc::util::InitJSONPtr ();
7490 file >> *list_settings;
7591
76- auto to_type_str = [&](const std::string &type) -> std::string {
77- return type + " _" + std::string ((*list_settings)[" tasks" ][type]);
78- };
79-
80- switch (type_of_task) {
81- case TypeOfTask::kALL :
82- return to_type_str (" all" );
83- case TypeOfTask::kSTL :
84- return to_type_str (" stl" );
85- case TypeOfTask::kOMP :
86- return to_type_str (" omp" );
87- case TypeOfTask::kMPI :
88- return to_type_str (" mpi" );
89- case TypeOfTask::kTBB :
90- return to_type_str (" tbb" );
91- case TypeOfTask::kSEQ :
92- return to_type_str (" seq" );
93- default :
94- return " unknown" ;
92+ std::string type_str = std::string (TypeOfTaskToString (type_of_task));
93+ if (type_str == " unknown" ) {
94+ return " unknown" ;
9595 }
96+
97+ return type_str + " _" + std::string ((*list_settings)[" tasks" ][type_str]);
9698}
9799
98100enum StateOfTesting : uint8_t { kFunc , kPerf };
0 commit comments