-
Notifications
You must be signed in to change notification settings - Fork 1
/
Task.h
48 lines (34 loc) · 1.13 KB
/
Task.h
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
//
// Created by Anaid Gakhokidze on 2017-05-08.
//
#ifndef TASKSCHEDULER_TASK_H
#define TASKSCHEDULER_TASK_H
#include <string>
#include <unordered_map>
// This task is used for creating tasks that will be scheduled in task scheduler.
class Task {
private:
/*
* Assumptions: - the output of the tasks is a map of metrics(doubles) with corresponding names.
* */
std::unordered_map<std::string, double> (*m_funcToExec)(void);
// How often the task should be run, in seconds.
long m_interval;
// Name of the task, necessary to store metrics in the database under the name of the task
std::string m_name;
public:
Task(std::string name, std::unordered_map<std::string, double> (* funcToExec)(void), long interval)
: m_funcToExec(funcToExec)
, m_interval(interval)
, m_name(name)
{
}
void setInterval(long interval) { m_interval = interval; }
long getInterval() { return m_interval; }
std::string getName() { return m_name; }
std::unordered_map<std::string, double> operator()()
{
return m_funcToExec();
}
};
#endif //TASKSCHEDULER_TASK_H