forked from learning-process/parallel_programming_course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.hpp
More file actions
70 lines (51 loc) · 1.82 KB
/
task.hpp
File metadata and controls
70 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <chrono>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
namespace ppc::core {
struct TaskData {
std::vector<uint8_t *> inputs;
std::vector<std::uint32_t> inputs_count;
std::vector<uint8_t *> outputs;
std::vector<std::uint32_t> outputs_count;
enum StateOfTesting : uint8_t { kFunc, kPerf } state_of_testing;
};
using TaskDataPtr = std::shared_ptr<ppc::core::TaskData>;
// Memory of inputs and outputs need to be initialized before create object of
// Task class
class Task {
public:
explicit Task(TaskDataPtr task_data);
// set input and output data
virtual void SetData(TaskDataPtr task_data) final;
// validation of data and validation of task attributes before running
virtual bool Validation() final;
// pre-processing of input data
virtual bool PreProcessing() final;
// realization of current task
virtual bool Run() final;
// post-processing of output data
virtual bool PostProcessing() final;
// get input and output data
[[nodiscard]] virtual TaskDataPtr GetData() const final;
virtual ~Task();
protected:
virtual void InternalOrderTest(const std::string &str = __builtin_FUNCTION()) final;
TaskDataPtr task_data;
// implementation of "validation" function
virtual bool ValidationImpl() = 0;
// implementation of "PreProcessing" function
virtual bool PreProcessingImpl() = 0;
// implementation of "run" function
virtual bool RunImpl() = 0;
// implementation of "post_processing" function
virtual bool PostProcessingImpl() = 0;
private:
std::vector<std::string> functions_order_;
std::vector<std::string> right_functions_order_ = {"Validation", "PreProcessing", "Run", "PostProcessing"};
static constexpr double kMaxTestTime = 1.0;
std::chrono::high_resolution_clock::time_point tmp_time_point_;
};
} // namespace ppc::core