-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.cpp
69 lines (65 loc) · 1.48 KB
/
Task.cpp
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
// Name: ANTONIO BENNETT
// Seneca Student ID: 118914183
// Seneca email: [email protected]
// Date of completion: November 26, 2019 *Think I left this out in MS1*
//
// I confirm that I am the only author of this file
// and the content was created entirely by me.
#include "Task.h"
Task::Task(const std::string& record) : Item(record)
{
m_pNextTask = nullptr;
}
void Task::runProcess(std::ostream& os)
{
if (!m_orders.empty())
{
while (!m_orders.back().getItemFillState(this->getName()))
{
m_orders.back().fillItem(*this, os);
}
}
}
bool Task::moveTask()
{
if (!m_orders.empty())
if (m_orders.back().getItemFillState(this->getName()))
{
if(m_pNextTask != nullptr)
{
*m_pNextTask += std::move(m_orders.back());
m_orders.pop_back();
return true;
}
}
return false;
}
void Task::setNextTask(Task& next)
{
m_pNextTask = &next;
}
bool Task::getCompleted(CustomerOrder& order)
{
if (!this->m_orders.empty())
{
if(m_orders.back().getOrderFillState())
{
order = std::move(this->m_orders.back());
this->m_orders.pop_back();
return true;
}
}
return false;
}
void Task::validate(std::ostream& val)
{
if (m_pNextTask == nullptr)
val << this->getName() << " --> END OF LINE" << std::endl;
else
val << this->getName() << " --> " << m_pNextTask->getName() << std::endl;
}
Task& Task::operator+=(CustomerOrder&& something)
{
m_orders.push_front(std::move(something));
return *this;
}