-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputList.cpp
More file actions
102 lines (92 loc) · 1.75 KB
/
InputList.cpp
File metadata and controls
102 lines (92 loc) · 1.75 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "InputList.h"
InputList::InputList()
{
processID = 0;
operation = "";
meter = 0;
bool doneProcess = false;
inProcess = false;
next = NULL;
prev = NULL;
}
InputList::~InputList()
{
}
InputList* InputList::setData(int ID, string opr,int met, InputList *current, bool empty, InputList *newList)
{
newList->processID = ID;
newList->operation = opr;
newList->meter = met;
if (empty) { newList->prev = NULL, newList->next = NULL; }
else
{
newList->prev = current;
newList->next = NULL;
current->next = newList;
}
return newList;
}
InputList* InputList::updateData(InputList* input, int met, bool done)
{
input->meter = met;
input->doneProcess = done;
return input;
}
InputList* InputList::returnActiveProcess(InputList* input)
{
if (input->operation == "NEW")
{
input->inProcess = true;
return input->next;
}
else if (input->meter == 0 && input->doneProcess)
return input->next;
return NULL;
}
int InputList::getProcessID()
{
return this->processID;
}
string InputList::getOperation()
{
return this->operation;
}
int InputList::getMeter()
{
return this->meter;
}
bool InputList::checkInProcess(InputList* list)
{
if (!list->inProcess)
return false;
return true;
}
void InputList::clean(InputList* list)
{
do
{
InputList* temp = list;
if (list->next != NULL)
{
list->next->prev = NULL;
list = list->next;
delete temp;
}
else
{
delete temp;
break;
}
} while (1);
}
string InputList::toString(InputList *list)
{
string toString;
do
{
toString += list->getOperation() + " " + to_string(list->getMeter()) + "\n";
if (list->next != NULL) list = list->next;
else break;
} while (1);
return toString;
}