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-2013 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
private
:
105
SUMOAbstractRouter
&
operator=
(
const
SUMOAbstractRouter
& s);
106
};
107
108
109
template
<
class
E,
class
V>
110
struct
prohibited_withRestrictions
{
111
public
:
112
inline
bool
operator()
(
const
E* edge,
const
V* vehicle)
const
{
113
if
(std::find(
myProhibited
.begin(),
myProhibited
.end(), edge) !=
myProhibited
.end()) {
114
return
true
;
115
}
116
return
edge->prohibits(vehicle);
117
}
118
119
void
prohibit
(
const
std::vector<E*>& toProhibit) {
120
myProhibited
= toProhibit;
121
}
122
123
protected
:
124
std::vector<E*>
myProhibited
;
125
126
};
127
128
template
<
class
E,
class
V>
129
struct
prohibited_noRestrictions
{
130
public
:
131
inline
bool
operator()
(
const
E*,
const
V*)
const
{
132
return
false
;
133
}
134
};
135
136
137
138
139
#endif
140
141
/****************************************************************************/
142
home
gladk
tmp
05
sumo-0.17.1~dfsg
src
utils
common
SUMOAbstractRouter.h
Generated on Sun Jun 16 2013 07:08:31 for SUMO - Simulation of Urban MObility by
1.8.1.2