Project

General

Profile

Statistics
| Branch: | Revision:

root / scout / libscout / src / helper_classes / Order.cpp @ 6ee555a3

History | View | Annotate | Download (1.29 KB)

1 4469dadd unknown
#include "Order.h"
2
3
using namespace std;
4
5 76cefba1 Priya
/** @Brief: Regular order constructor */
6 ca164875 Leon
Order::Order(int order_id, Address order_source, Address order_dest, 
7 2f025967 Priya
    Time order_start_time, Path order_path, Duration order_est_time) 
8 76cefba1 Priya
{ 
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 4469dadd unknown
{
20 76cefba1 Priya
    return id;
21
}  
22
23 9b4328d7 Priya
Address Order::get_source() const
24 76cefba1 Priya
{
25
    return source;
26 4469dadd unknown
}
27
28 9b4328d7 Priya
Address Order::get_dest() const
29 76cefba1 Priya
{
30
    return dest;
31 4469dadd unknown
}
32
33 9b4328d7 Priya
Time Order::get_start_time() const
34 76cefba1 Priya
{
35
    return start_time;
36 4469dadd unknown
}
37
38 9b4328d7 Priya
Path Order::get_path() const
39 76cefba1 Priya
{
40
    return path;
41
}
42 4469dadd unknown
43 2f025967 Priya
Duration Order::get_est_time() const
44 ca164875 Leon
{
45
    return est_time;
46
}
47
48 6761a531 Priya
int Order::get_priority() const
49
{
50
    return start_time.toSec() + MAX_WAIT_TIME - est_time.toSec();
51
}
52
53 2f025967 Priya
bool Order::operator==(Order& order)
54 9b4328d7 Priya
{
55 2f025967 Priya
  return this->id == order.id;
56 9b4328d7 Priya
}
57
58
void Order::set_path(Path order_path)
59 76cefba1 Priya
{
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 6761a531 Priya
  return o1.get_priority() > o2.get_priority();
71 4469dadd unknown
}