My Project
Loading...
Searching...
No Matches
vehicle.h
Go to the documentation of this file.
1#pragma once
2#include <list>
3#include <vector>
4#include <string>
5#include <utility>
6
7using namespace std;
8
9template <class t> struct vehicle {
10 int id;
14 list<t> path;
15 pair<t, t> currentRoad;
16 int state;
17 bool inQueue;
18 vector<t> selected_path;
21 id = 0;
22 dest = t();
23 source = t();
24 current = t();
25 state = -1;
26 inQueue = false;
28 currentRoad.first = currentRoad.second = t();
29
30 }
31 vehicle(int i, t s, t d) {
32 id = i;
33 dest = d;
34 source = s;
35 current = s;
36 state = 0;
37 inQueue = false;
39 currentRoad.first = currentRoad.second = t();
40 }
41
42 string getTakenPath() {
43 string path = "";
44 if (selected_path.empty())
45 return path;
46
47 for (typename vector<t>::size_type i = 0; i < selected_path.size(); i++) {
48 path = path + selected_path[i];
49
50 if (i < selected_path.size() - 1) {
51 path = path + " -> ";
52 }
53 }
54 return path;
55 }
56
57 string getstart_and_end() { return source + "->" + dest; }
58};
vehicle()
Definition vehicle.h:20
string getstart_and_end()
Definition vehicle.h:57
string getTakenPath()
Definition vehicle.h:42
bool inQueue
Definition vehicle.h:17
int state
Definition vehicle.h:16
vector< t > selected_path
Definition vehicle.h:18
t dest
Definition vehicle.h:11
float timespent
Definition vehicle.h:19
pair< t, t > currentRoad
Definition vehicle.h:15
float timeRemaining
Definition vehicle.h:19
int id
Definition vehicle.h:10
list< t > path
Definition vehicle.h:14
vehicle(int i, t s, t d)
Definition vehicle.h:31
t current
Definition vehicle.h:13
t source
Definition vehicle.h:12