Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / warehouse / helper_classes / Order.cpp @ 2009

History | View | Annotate | Download (1.29 KB)

1
#include "Order.h"
2

    
3
using namespace std;
4

    
5
/** @Brief: Regular order constructor */
6
Order::Order(int order_id, Address order_source, Address order_dest, 
7
    Time order_start_time, Path order_path, Duration order_est_time) 
8
{ 
9
    id = order_id;
10
    source = order_source;
11
    dest = order_dest;
12
    start_time = order_start_time;
13
    path = order_path;
14
    est_time = order_est_time;
15
}
16

    
17
/** @Brief: Get order ID */
18
int Order::getid() const 
19
{
20
    return id;
21
}  
22

    
23
Address Order::get_source() const
24
{
25
    return source;
26
}
27

    
28
Address Order::get_dest() const
29
{
30
    return dest;
31
}
32

    
33
Time Order::get_start_time() const
34
{
35
    return start_time;
36
}
37

    
38
Path Order::get_path() const
39
{
40
    return path;
41
}
42

    
43
Duration Order::get_est_time() const
44
{
45
    return est_time;
46
}
47

    
48
int Order::get_priority() const
49
{
50
    return start_time.toSec() + MAX_WAIT_TIME - est_time.toSec();
51
}
52

    
53
bool Order::operator==(Order& order)
54
{
55
  return this->id == order.id;
56
}
57

    
58
void Order::set_path(Path order_path)
59
{
60
    path = order_path;
61
    return;
62
}
63
/** @Brief: Order comparison function for PQWrapper 
64
 *  NOTE: In order to have a min priority queue, using c++'s pq
65
 *  implementation, the compare function must return true if
66
 *  o1 is greater than o2.
67
 */
68
bool CompareOrder::operator()(Order& o1, Order& o2) 
69
{
70
  return o1.get_priority() > o2.get_priority();
71
}
72