Project

General

Profile

Revision 2009

Rewrote some of the WH_Robot.h code to make it c-compatible. Most of the c++ was commented out instead of deleted.

View differences:

Order.h
1
#include "Order.h"
1
#ifndef _ORDER_
2
#define _ORDER_
2 3

  
3
using namespace std;
4
#include "../Behavior.h"
5
#include "../behaviors/navigationMap.h"
4 6

  
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
}
7
#define MAX_WAIT_TIME 120 //2 minutes in seconds
16 8

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

  
23
Address Order::get_source() const
24
{
25
    return source;
26
}
11
class Order {
12
    int id;
13
    Address source, dest;
14
    Time start_time;
15
    Path path;
16
    Duration est_time;
17
public:
18
    Order(int order_id, Address order_source, Address order_dest, 
19
        Time order_start_time, Path order_path, Duration order_est_time);
20
  
21
    Order() {};
27 22

  
28
Address Order::get_dest() const
29
{
30
    return dest;
31
}
23
    int getid() const;
24
    Address get_source() const;
25
    Address get_dest() const;
26
    Time get_start_time() const;
27
    Path get_path() const;
28
    Duration get_est_time() const;
29
    void set_path(Path order_path);
30
    int get_priority() const;
32 31

  
33
Time Order::get_start_time() const
34
{
35
    return start_time;
36
}
32
    bool operator==(Order& order);
33
    
34
};
37 35

  
38
Path Order::get_path() const
39
{
40
    return path;
41
}
36
class CompareOrder {
37
  public:
38
    bool operator()(Order& o1, Order& o2);   
39
};
42 40

  
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

  
41
#endif

Also available in: Unified diff