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
OutputDevice_File.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// An output device that encapsulates an ofstream
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2004-2014 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
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
#include <iostream>
34
#include <
utils/common/UtilExceptions.h
>
35
#include "
OutputDevice_File.h
"
36
37
#ifdef CHECK_MEMORY_LEAKS
38
#include <
foreign/nvwa/debug_new.h
>
39
#endif // CHECK_MEMORY_LEAKS
40
41
42
// ===========================================================================
43
// method definitions
44
// ===========================================================================
45
OutputDevice_File::OutputDevice_File
(
const
std::string& fullName,
const
bool
binary)
46
:
OutputDevice
(binary), myFileStream(0) {
47
#ifdef WIN32
48
if
(fullName ==
"/dev/null"
) {
49
myFileStream
=
new
std::ofstream(
"NUL"
);
50
#else
51
if
(fullName ==
"nul"
|| fullName ==
"NUL"
) {
52
myFileStream
=
new
std::ofstream(
"/dev/null"
);
53
#endif
54
}
else
{
55
myFileStream
=
new
std::ofstream(fullName.c_str(), binary ? std::ios::binary : std::ios_base::out);
56
}
57
if
(!
myFileStream
->good()) {
58
delete
myFileStream
;
59
throw
IOError
(
"Could not build output file '"
+ fullName +
"'."
);
60
}
61
}
62
63
64
OutputDevice_File::~OutputDevice_File
() {
65
myFileStream
->close();
66
delete
myFileStream
;
67
}
68
69
70
std::ostream&
71
OutputDevice_File::getOStream
() {
72
return
*
myFileStream
;
73
}
74
75
76
/****************************************************************************/
77
tmp
buildd
sumo-0.21.0+dfsg
src
utils
iodevices
OutputDevice_File.cpp
Generated on Thu Nov 20 2014 19:49:58 for SUMO - Simulation of Urban MObility by
1.8.1.2