Statistics
| Revision:

root / trunk / code / projects / warehouse / helper_classes / Order.h @ 2003

History | View | Annotate | Download (1.31 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, Time 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
Time Order::get_est_time() const
44
{
45
    return est_time;
46
}
47

    
48
bool Order::operator==(Order& o1, Order& o2)
49
{
50
  return o1.id == o2.id;
51
}
52

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