Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/unittest/src/utils/iodevices/OutputDeviceMock.h
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file OutputDeviceMock.h
15
/// @author Matthias Heppner
16
/// @author Michael Behrisch
17
/// @date 2009-11-23
18
///
19
//
20
/****************************************************************************/
21
22
#ifndef OutputDeviceMock_h
23
#define OutputDeviceMock_h
24
25
26
// ===========================================================================
27
// included modules
28
// ===========================================================================
29
#include <config.h>
30
31
#include <fstream>
32
#include <utils/iodevices/OutputDevice.h>
33
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
/**
39
* @class OutputDeviceMock
40
* Mock Implementation for Unit Tests
41
*
42
*/
43
class OutputDeviceMock : public OutputDevice {
44
public:
45
/** @brief Constructor
46
*/
47
OutputDeviceMock() {}
48
49
/// @brief Destructor
50
~OutputDeviceMock() {}
51
52
53
/** @brief Returns the current content as a string
54
*/
55
std::string getString() {
56
return myStream.str();
57
}
58
59
protected:
60
/** @brief Returns the associated ostream
61
*/
62
std::ostream& getOStream() {
63
return myStream;
64
}
65
66
private:
67
/// the string stream
68
std::ostringstream myStream;
69
70
};
71
72
73
#endif
74
75
/****************************************************************************/
76
77