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
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-sim.org/
12
// Copyright (C) 2001-2013 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
35
36
// ===========================================================================
37
// type definitions
38
// ===========================================================================
39
#ifdef HAVE_SUBSECOND_TIMESTEPS
40
SUMOTime
DELTA_T
= 1000;
41
#endif
42
43
44
// ===========================================================================
45
// method definitions
46
// ===========================================================================
47
SUMOTime
48
string2time
(
const
std::string& r) {
49
double
time;
50
std::istringstream buf(r);
51
buf >> time;
52
if
(buf.fail()) {
53
throw
ProcessError
(
"Input string '"
+ r +
"' cannot be parsed as a time"
);
54
}
else
{
55
return
TIME2STEPS
(time);
56
}
57
}
58
59
60
std::string
61
time2string
(
SUMOTime
t) {
62
// 123456 -> "12.34"
63
std::ostringstream oss;
64
oss.setf(oss.fixed);
65
oss.precision(
OUTPUT_ACCURACY
);
66
oss <<
STEPS2TIME
(t);
67
return
oss.str();
68
}
69
70
71
/****************************************************************************/
72
windows_config.h
time2string
std::string time2string(SUMOTime t)
Definition:
SUMOTime.cpp:61
config.h
TIME2STEPS
#define TIME2STEPS(x)
Definition:
SUMOTime.h:66
OUTPUT_ACCURACY
#define OUTPUT_ACCURACY
Definition:
config.h:162
STEPS2TIME
#define STEPS2TIME(x)
Definition:
SUMOTime.h:65
string2time
SUMOTime string2time(const std::string &r)
Definition:
SUMOTime.cpp:48
TplConvert.h
SUMOTime
int SUMOTime
Definition:
SUMOTime.h:43
DELTA_T
#define DELTA_T
Definition:
SUMOTime.h:50
ProcessError
Definition:
UtilExceptions.h:63
SUMOTime.h
build
buildd
sumo-0.19.0+dfsg
src
utils
common
SUMOTime.cpp
Generated on Sun Dec 15 2013 23:23:26 for SUMO - Simulation of Urban MObility by
1.8.5