-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIProcess.h
More file actions
63 lines (52 loc) · 1.31 KB
/
IProcess.h
File metadata and controls
63 lines (52 loc) · 1.31 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
#ifndef _IProcess_h
#define _IProcess_h
#include "ProcessHandler.h"
#include "ParamsHandler.h"
class ProcessHandler;
class IProcess
{
public:
IProcess(ProcessHandler* owner, int minPriority, int maxPriority, bool persistent)
{
this->owner = owner;
this->minPriority = minPriority;
this->maxPriority = maxPriority;
this->priority = maxPriority;
this->persistent = persistent;
}
//Retorna a prioridade do processo
virtual int GetPriority(int) = 0;
//Executa o processo
virtual int Execute() = 0;
//Retorna caso o processo seja persistente
inline bool Persistent()
{
return this->persistent;
}
protected:
bool persistent;
int minPriority;
int maxPriority;
int priority;
int busyLvl;
ProcessHandler* owner;
inline void SetPriority(int value)
{
if (value > maxPriority)
priority = maxPriority;
else if (value < minPriority)
priority = minPriority;
else
priority = value;
}
inline void SetBusyLvl(int value)
{
if (value > busyLvl)
busyLvl = MAX_BUSY_VALUE;
else if (value < MIN_BUSY_VALUE)
busyLvl = MIN_BUSY_VALUE;
else
busyLvl = value;
}
};
#endif