SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SUMOAbstractRouter.h
Go to the documentation of this file.
1
/****************************************************************************/
8
// The dijkstra-router
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
/****************************************************************************/
21
#ifndef SUMOAbstractRouter_h
22
#define SUMOAbstractRouter_h
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <string>
35
#include <vector>
36
#include <algorithm>
37
#include <assert.h>
38
#include <
utils/common/SysUtils.h
>
39
#include <
utils/common/MsgHandler.h
>
40
#include <
utils/common/SUMOTime.h
>
41
#include <
utils/common/ToString.h
>
42
43
44
// ===========================================================================
45
// class definitions
46
// ===========================================================================
51
template
<
class
E,
class
V>
52
class
SUMOAbstractRouter
{
53
public
:
55
SUMOAbstractRouter
(
const
std::string& type):
56
myType
(type),
57
myQueryVisits
(0),
58
myNumQueries
(0),
59
myQueryStartTime
(0),
60
myQueryTimeSum
(0)
61
{ }
62
64
virtual
~SUMOAbstractRouter
() {
65
if
(
myNumQueries
> 0) {
66
WRITE_MESSAGE
(
myType
+
" answered "
+
toString
(
myNumQueries
) +
" queries and explored "
+
toString
(
double
(
myQueryVisits
) /
myNumQueries
) +
" edges on average."
);
67
WRITE_MESSAGE
(
myType
+
" spent "
+
toString
(
myQueryTimeSum
) +
" ms answering queries ("
+
toString
(
double
(
myQueryTimeSum
) /
myNumQueries
) +
" ms on average)."
);
68
}
69
}
70
73
virtual
void
compute
(
const
E* from,
const
E* to,
const
V*
const
vehicle,
74
SUMOTime
msTime, std::vector<const E*> &into) = 0;
75
76
virtual
SUMOReal
recomputeCosts
(
const
std::vector<const E*> &edges,
77
const
V*
const
v,
SUMOTime
msTime)
const
= 0;
78
79
// interface extension for BulkStarRouter
80
virtual
void
prepare
(
const
E*,
const
V*,
bool
) {
81
assert(
false
);
82
}
83
84
inline
void
startQuery
() {
85
myNumQueries
++;
86
myQueryStartTime
=
SysUtils::getCurrentMillis
();
87
}
88
89
inline
void
endQuery
(
int
visits) {
90
myQueryVisits
+= visits;
91
myQueryTimeSum
+= (
SysUtils::getCurrentMillis
() -
myQueryStartTime
);
92
}
93
94
private
:
96
const
std::string
myType
;
98
int
myQueryVisits
;
99
int
myNumQueries
;
101
long
myQueryStartTime
;
102
long
myQueryTimeSum
;
103
};
104
105
106
template
<
class
E,
class
V>
107
struct
prohibited_withRestrictions
{
108
public
:
109
inline
bool
operator()
(
const
E* edge,
const
V* vehicle)
const
{
110
if
(std::find(
myProhibited
.begin(),
myProhibited
.end(), edge) !=
myProhibited
.end()) {
111
return
true
;
112
}
113
return
edge->prohibits(vehicle);
114
}
115
116
void
prohibit
(
const
std::vector<E*> &toProhibit) {
117
myProhibited
= toProhibit;
118
}
119
120
protected
:
121
std::vector<E*>
myProhibited
;
122
123
};
124
125
template
<
class
E,
class
V>
126
struct
prohibited_noRestrictions
{
127
public
:
128
inline
bool
operator()
(
const
E*,
const
V*)
const
{
129
return
false
;
130
}
131
};
132
133
134
135
136
#endif
137
138
/****************************************************************************/
139
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
utils
common
SUMOAbstractRouter.h
Generated on Mon Mar 24 2014 09:53:15 for SUMO - Simulation of Urban MObility by
1.8.1.2