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
AGTime.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// Time manager: able to manipulate the time using Sumo's format (seconds)
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
14
// activitygen module
15
// Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
16
/****************************************************************************/
17
//
18
// This file is part of SUMO.
19
// SUMO is free software: you can redistribute it and/or modify
20
// it under the terms of the GNU General Public License as published by
21
// the Free Software Foundation, either version 3 of the License, or
22
// (at your option) any later version.
23
//
24
/****************************************************************************/
25
26
27
// ===========================================================================
28
// included modules
29
// ===========================================================================
30
#ifdef _MSC_VER
31
#include <
windows_config.h
>
32
#else
33
#include <
config.h
>
34
#endif
35
36
#include "
AGTime.h
"
37
38
39
// ===========================================================================
40
// method definitions
41
// ===========================================================================
42
AGTime::AGTime
(
const
AGTime
& time) {
43
sec
= time.
sec
;
44
}
45
46
int
47
AGTime::convert
(
int
days,
int
hours,
int
minutes,
int
seconds) {
48
sec
= seconds + 60 * (minutes + 60 * (hours + 24 * (days)));
49
return
sec
;
50
}
51
52
int
53
AGTime::getSecondsOf
(
SUMOReal
minutes) {
54
return
static_cast<
int
>
(60.0 * minutes);
55
}
56
57
bool
58
AGTime::operator==
(
const
AGTime
& time) {
59
if
(this->
sec
== time.
sec
) {
60
return
true
;
61
}
else
{
62
return
false
;
63
}
64
}
65
66
bool
67
AGTime::operator<
(
const
AGTime
& time) {
68
if
(this->
sec
< time.
sec
) {
69
return
true
;
70
}
else
{
71
return
false
;
72
}
73
}
74
75
bool
76
AGTime::operator<=
(
const
AGTime
& time) {
77
if
(this->
sec
<= time.
sec
) {
78
return
true
;
79
}
else
{
80
return
false
;
81
}
82
}
83
84
void
85
AGTime::operator+=
(
const
AGTime
& time) {
86
this->
sec
+= time.
sec
;
87
}
88
89
void
90
AGTime::operator+=
(
int
seconds) {
91
this->
sec
+= seconds;
92
}
93
94
void
95
AGTime::operator-=
(
const
AGTime
& time) {
96
this->
sec
-= time.
sec
;
97
}
98
99
AGTime
100
AGTime::operator+
(
const
AGTime
& time) {
101
AGTime
newtime(time.
sec
+ this->sec);
102
return
newtime;
103
}
104
105
int
106
AGTime::getDay
() {
107
return
(
sec
/ 86400);
108
}
109
110
int
111
AGTime::getHour
() {
112
return
((
sec
/ 3600) % 24);
113
}
114
115
int
116
AGTime::getMinute
() {
117
return
((
sec
/ 60) % 60);
118
}
119
120
int
121
AGTime::getSecond
() {
122
return
(
sec
% 60);
123
}
124
125
int
126
AGTime::getSecondsInCurrentDay
() {
127
return
(
sec
% 86400);
128
}
129
130
int
131
AGTime::getTime
() {
132
return
this->
sec
;
133
}
134
135
void
136
AGTime::setDay
(
int
d) {
137
if
(0 <= d) {
138
sec
-= 86400 *
getDay
();
139
sec
+= 86400 * d;
140
}
141
}
142
143
void
144
AGTime::setHour
(
int
h) {
145
if
(0 <= h && h < 24) {
146
sec
-= 3600 *
getHour
();
147
sec
+= 3600 * h;
148
}
149
}
150
151
void
152
AGTime::setMinute
(
int
m) {
153
if
(0 <= m && m < 60) {
154
sec
-= 60 *
getMinute
();
155
sec
+= 60 * m;
156
}
157
}
158
159
void
160
AGTime::setSecond
(
int
s) {
161
if
(0 <= s && s < 60) {
162
sec
-=
getSecond
();
163
sec
+= s;
164
}
165
}
166
167
void
168
AGTime::setTime
(
int
sec) {
169
this->sec =
sec
;
170
}
171
172
void
173
AGTime::addDays
(
int
d) {
174
sec
+= 86400 * d;
175
}
176
177
void
178
AGTime::addHours
(
int
h) {
179
sec
+= 3600 * h;
180
}
181
182
void
183
AGTime::addMinutes
(
int
m) {
184
sec
+= 60 * m;
185
}
186
187
void
188
AGTime::addSeconds
(
int
s) {
189
sec
+= s;
190
}
191
192
/****************************************************************************/
tmp
buildd
sumo-0.21.0+dfsg
src
activitygen
city
AGTime.cpp
Generated on Thu Nov 20 2014 19:49:52 for SUMO - Simulation of Urban MObility by
1.8.1.2