@@ -19,16 +19,48 @@ using namespace std::chrono;
1919
2020namespace ppc ::core {
2121
22- enum TypeOfTask : uint8_t { kALL , kMPI , kOMP , kSEQ , kSTL , kTBB , kUnknown };
23- enum StatusOfTask : uint8_t { kEnabled , kDisabled };
22+ // / @brief Represents the type of task (parallelization technology).
23+ // / @details Used to select the implementation type in tests and execution logic.
24+ enum TypeOfTask : uint8_t {
25+ // / Use all available implementations
26+ kALL ,
27+ // / MPI (Message Passing Interface)
28+ kMPI ,
29+ // / OpenMP (Open Multi-Processing)
30+ kOMP ,
31+ // / Sequential implementation
32+ kSEQ ,
33+ // / Standard Thread Library (STL threads)
34+ kSTL ,
35+ // / Intel Threading Building Blocks (TBB)
36+ kTBB ,
37+ // / Unknown task type
38+ kUnknown
39+ };
40+
41+ // / @brief Indicates whether a task is enabled or disabled.
42+ enum StatusOfTask : uint8_t {
43+ // / Task is enabled and should be executed
44+ kEnabled ,
45+ // / Task is disabled and will be skipped
46+ kDisabled
47+ };
2448
49+ // / @brief Returns a string representation of the task status.
50+ // / @param status_of_task Task status (enabled or disabled).
51+ // / @return "enabled" if the task is enabled, otherwise "disabled".
2552inline std::string GetStringTaskStatus (StatusOfTask status_of_task) {
2653 if (status_of_task == kDisabled ) {
2754 return " disabled" ;
2855 }
2956 return " enabled" ;
3057}
3158
59+ // / @brief Returns a string representation of the task type based on the JSON settings file.
60+ // / @param type_of_task Type of the task.
61+ // / @param settings_file_path Path to the JSON file containing task type strings.
62+ // / @return Formatted string combining the task type and its corresponding value from the file.
63+ // / @throws std::runtime_error If the file cannot be opened.
3264inline std::string GetStringTaskType (TypeOfTask type_of_task, const std::string &settings_file_path) {
3365 std::ifstream file (settings_file_path);
3466 if (!file.is_open ()) {
@@ -65,20 +97,24 @@ inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string
6597
6698enum StateOfTesting : uint8_t { kFunc , kPerf };
6799
68- // Memory of inputs and outputs need to be initialized before create an object of
69- // Task class
70100template <typename InType, typename OutType>
101+ // / @brief Base abstract class representing a generic task with a defined pipeline.
102+ // / @tparam InType Input data type.
103+ // / @tparam OutType Output data type.
71104class Task {
72105 public:
106+ // / @brief Constructs a new Task object.
73107 explicit Task (StateOfTesting /* state_of_testing*/ = StateOfTesting::kFunc ) { functions_order_.clear (); }
74108
75- // validation of data and validation of task attributes before running
109+ // / @brief Validates input data and task attributes before execution.
110+ // / @return True if validation is successful.
76111 virtual bool Validation () final {
77112 InternalOrderTest (__builtin_FUNCTION ());
78113 return ValidationImpl ();
79114 }
80115
81- // pre-processing of input data
116+ // / @brief Performs preprocessing on the input data.
117+ // / @return True if preprocessing is successful.
82118 virtual bool PreProcessing () final {
83119 InternalOrderTest (__builtin_FUNCTION ());
84120 if (state_of_testing_ == StateOfTesting::kFunc ) {
@@ -87,13 +123,15 @@ class Task {
87123 return PreProcessingImpl ();
88124 }
89125
90- // realization of the current task
126+ // / @brief Executes the main logic of the task.
127+ // / @return True if execution is successful.
91128 virtual bool Run () final {
92129 InternalOrderTest (__builtin_FUNCTION ());
93130 return RunImpl ();
94131 }
95132
96- // post-processing of output data
133+ // / @brief Performs postprocessing on the output data.
134+ // / @return True if postprocessing is successful.
97135 virtual bool PostProcessing () final {
98136 InternalOrderTest (__builtin_FUNCTION ());
99137 if (state_of_testing_ == StateOfTesting::kFunc ) {
@@ -102,25 +140,36 @@ class Task {
102140 return PostProcessingImpl ();
103141 }
104142
105- // get state of testing
143+ // / @brief Returns the current testing mode.
144+ // / @return Reference to the current StateOfTesting.
106145 StateOfTesting &GetStateOfTesting () { return state_of_testing_; }
107146
108- // set a type of task
147+ // / @brief Sets the dynamic task type.
148+ // / @param type_of_task Task type to set.
109149 void SetTypeOfTask (TypeOfTask type_of_task) { type_of_task_ = type_of_task; }
110150
111- // get a dynamic type of task
151+ // / @brief Returns the dynamic task type.
152+ // / @return Current dynamic task type.
112153 [[nodiscard]] TypeOfTask GetDynamicTypeOfTask () const { return type_of_task_; }
113154
114- // get a dynamic type of task
155+ // / @brief Returns the current task status.
156+ // / @return Task status (enabled or disabled).
115157 [[nodiscard]] StatusOfTask GetStatusOfTask () const { return status_of_task_; }
116158
117- // get a static type of task
159+ // / @brief Returns the static task type.
160+ // / @return Static task type (default: kUnknown).
118161 static constexpr TypeOfTask GetStaticTypeOfTask () { return TypeOfTask::kUnknown ; }
119162
163+ // / @brief Returns a reference to the input data.
164+ // / @return Reference to the task's input data.
120165 InType &GetInput () { return input_; }
121166
167+ // / @brief Returns a reference to the output data.
168+ // / @return Reference to the task's output data.
122169 OutType &GetOutput () { return output_; }
123170
171+ // / @brief Destructor. Verifies that the pipeline was executed in the correct order.
172+ // / @note Terminates the program if pipeline order is incorrect or incomplete.
124173 virtual ~Task () {
125174 if (!functions_order_.empty () || !was_worked_) {
126175 std::cerr << " ORDER OF FUNCTIONS IS NOT RIGHT! \n Expected - \" Validation\" , \" PreProcessing\" , \" Run\" , "
@@ -132,6 +181,8 @@ class Task {
132181 }
133182
134183 protected:
184+ // / @brief Verifies the correct order of pipeline method calls.
185+ // / @param str Name of the method being called.
135186 virtual void InternalOrderTest (const std::string &str) final {
136187 functions_order_.push_back (str);
137188 if (str == " PostProcessing" && IsFullPipelineStage ()) {
@@ -141,6 +192,9 @@ class Task {
141192 }
142193 }
143194
195+ // / @brief Measures execution time between preprocessing and postprocessing steps.
196+ // / @param str Name of the method being timed.
197+ // / @throws std::runtime_error If execution exceeds the allowed time limit.
144198 virtual void InternalTimeTest (const std::string &str) final {
145199 if (str == " PreProcessing" ) {
146200 tmp_time_point_ = std::chrono::high_resolution_clock::now ();
@@ -162,16 +216,20 @@ class Task {
162216 }
163217 }
164218
165- // implementation of "Validation" function
219+ // / @brief User-defined validation logic.
220+ // / @return True if validation is successful.
166221 virtual bool ValidationImpl () = 0;
167222
168- // implementation of "PreProcessing" function
223+ // / @brief User-defined preprocessing logic.
224+ // / @return True if preprocessing is successful.
169225 virtual bool PreProcessingImpl () = 0;
170226
171- // implementation of "Run" function
227+ // / @brief User-defined task execution logic.
228+ // / @return True if run is successful.
172229 virtual bool RunImpl () = 0;
173230
174- // implementation of "PostProcessing" function
231+ // / @brief User-defined postprocessing logic.
232+ // / @return True if postprocessing is successful.
175233 virtual bool PostProcessingImpl () = 0;
176234
177235 private:
@@ -198,9 +256,17 @@ class Task {
198256 }
199257};
200258
259+ // / @brief Smart pointer alias for Task.
260+ // / @tparam InType Input data type.
261+ // / @tparam OutType Output data type.
201262template <typename InType, typename OutType>
202263using TaskPtr = std::shared_ptr<Task<InType, OutType>>;
203264
265+ // / @brief Constructs and returns a shared pointer to a task with the given input.
266+ // / @tparam TaskType Type of the task to create.
267+ // / @tparam InType Type of the input.
268+ // / @param in Input to pass to the task constructor.
269+ // / @return Shared pointer to the newly created task.
204270template <typename TaskType, typename InType>
205271std::shared_ptr<TaskType> TaskGetter (InType in) {
206272 return std::make_shared<TaskType>(in);
0 commit comments