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
MsgRetrievingFunction.h
Go to the documentation of this file.
1
/****************************************************************************/
8
// Encapsulates an object's method for using it as a message retriever
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
/****************************************************************************/
21
#ifndef MsgRetrievingFunction_h
22
#define MsgRetrievingFunction_h
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <string>
35
#include <sstream>
36
#include <
utils/iodevices/OutputDevice.h
>
37
#include "
MsgHandler.h
"
38
39
40
// ===========================================================================
41
// class definitions
42
// ===========================================================================
49
template
<
class
T >
50
class
MsgRetrievingFunction
:
public
OutputDevice
{
51
public
:
53
typedef
void(T::*
Operation
)(
const
MsgHandler::MsgType
,
const
std::string&);
54
55
61
MsgRetrievingFunction
(T*
object
,
Operation
operation,
MsgHandler::MsgType
type) :
62
myObject
(object),
63
myOperation
(operation),
64
myMsgType
(type) {}
65
66
68
~MsgRetrievingFunction
() {}
69
70
71
protected
:
74
83
std::ostream&
getOStream
() {
84
return
myMessage
;
85
}
86
87
90
virtual
void
postWriteHook
() {
91
(
myObject
->*
myOperation
)(
myMsgType
,
myMessage
.str());
92
myMessage
.str(
""
);
93
}
95
96
97
private
:
99
T*
myObject
;
100
102
Operation
myOperation
;
103
105
MsgHandler::MsgType
myMsgType
;
106
108
std::ostringstream
myMessage
;
109
110
};
111
112
113
#endif
114
115
/****************************************************************************/
116
build
buildd
sumo-0.17.1~dfsg
src
utils
common
MsgRetrievingFunction.h
Generated on Sun Jun 16 2013 17:30:16 for SUMO - Simulation of Urban MObility by
1.8.3.1