SUMO - Simulation of Urban MObility
SUMOTime.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// Variables, methods, and tools for internal time representation
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12
// Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
// ===========================================================================
23
// included modules
24
// ===========================================================================
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <sstream>
32
#include "
SUMOTime.h
"
33
#include "
TplConvert.h
"
34
#include "
StdDefs.h
"
35
36
37
// ===========================================================================
38
// type definitions
39
// ===========================================================================
40
SUMOTime
DELTA_T
= 1000;
41
42
43
// ===========================================================================
44
// method definitions
45
// ===========================================================================
46
SUMOTime
47
string2time
(
const
std::string& r) {
48
double
time;
49
std::istringstream buf(r);
50
buf >> time;
51
if
(buf.fail() || time >
STEPS2TIME
(
SUMOTime_MAX
)) {
52
throw
ProcessError
(
"Input string '"
+ r +
"' is not a valid number or exceeds the time value range."
);
53
}
else
{
54
return
TIME2STEPS
(time);
55
}
56
}
57
58
59
std::string
60
time2string
(
SUMOTime
t) {
61
// 123456 -> "12.34"
62
std::ostringstream oss;
63
oss.setf(oss.fixed);
64
oss.precision(
gPrecision
);
65
oss <<
STEPS2TIME
(t);
66
return
oss.str();
67
}
68
69
70
/****************************************************************************/
71
windows_config.h
gPrecision
int gPrecision
the precision for floating point outputs
Definition:
StdDefs.cpp:30
time2string
std::string time2string(SUMOTime t)
Definition:
SUMOTime.cpp:60
config.h
DELTA_T
SUMOTime DELTA_T
Definition:
SUMOTime.cpp:40
TIME2STEPS
#define TIME2STEPS(x)
Definition:
SUMOTime.h:66
SUMOTime_MAX
#define SUMOTime_MAX
Definition:
TraCIDefs.h:53
STEPS2TIME
#define STEPS2TIME(x)
Definition:
SUMOTime.h:65
StdDefs.h
string2time
SUMOTime string2time(const std::string &r)
Definition:
SUMOTime.cpp:47
TplConvert.h
SUMOTime
long long int SUMOTime
Definition:
TraCIDefs.h:52
ProcessError
Definition:
UtilExceptions.h:49
SUMOTime.h
src
utils
common
SUMOTime.cpp
Generated on Sun Dec 17 2017 21:15:31 for SUMO - Simulation of Urban MObility by
1.8.13