-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkstation.cpp
More file actions
64 lines (54 loc) · 1.39 KB
/
Copy pathWorkstation.cpp
File metadata and controls
64 lines (54 loc) · 1.39 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
#include "Workstation.h"
namespace sdds
{
std::deque<CustomerOrder> g_pending{};
std::deque<CustomerOrder> g_completed{};
std::deque<CustomerOrder> g_incomplete{};
Workstation::Workstation(const std::string& str) : Station(str) {}
void Workstation::fill(std::ostream& os)
{
if (!m_orders.empty())
m_orders.front().fillItem(*this, os);
}
bool Workstation::attemptToMoveOrder()
{
bool Ordermoved = false;
if (!m_orders.empty())
{
if (m_orders.front().isItemFilled(Station::getItemName()) || Station::getQuantity() <= 0)
{
Ordermoved = true;
if (m_pNextStation)
{
*m_pNextStation += std::move(m_orders.front());
}
else
{
(m_orders.front().isOrderFilled()) ? g_completed.push_back(std::move(m_orders.front())) : g_incomplete.push_back(std::move(m_orders.front()));
}
m_orders.pop_front();
}
}
return Ordermoved;
}
void Workstation::setNextStation(Workstation* station)
{
m_pNextStation = station;
}
Workstation* Workstation::getNextStation() const
{
return m_pNextStation;
}
void Workstation::display(std::ostream& os) const
{
if (m_pNextStation)
os << getItemName() << " --> " << getNextStation()->getItemName() << std::endl;
else
os << getItemName() << " --> End of Line" << "\n";
}
Workstation& Workstation::operator+=(CustomerOrder&& newOrder)
{
m_orders.push_back(std::move(newOrder));
return *this;
}
}