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
GLObjectValuePassConnector.h
Go to the documentation of this file.
1
/****************************************************************************/
10
// Class passing values from a GUIGlObject to another object
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14
/****************************************************************************/
15
//
16
// This file is part of SUMO.
17
// SUMO is free software: you can redistribute it and/or modify
18
// it under the terms of the GNU General Public License as published by
19
// the Free Software Foundation, either version 3 of the License, or
20
// (at your option) any later version.
21
//
22
/****************************************************************************/
23
#ifndef GLObjectValuePassConnector_h
24
#define GLObjectValuePassConnector_h
25
26
27
// ===========================================================================
28
// included modules
29
// ===========================================================================
30
#ifdef _MSC_VER
31
#include <
windows_config.h
>
32
#else
33
#include <
config.h
>
34
#endif
35
36
#include <algorithm>
37
#include <vector>
38
#include <map>
39
#include <
utils/common/ValueSource.h
>
40
#include <
utils/common/ValueRetriever.h
>
41
#include <
utils/gui/globjects/GUIGlObject.h
>
42
#include <
utils/foxtools/MFXMutex.h
>
43
44
45
// ===========================================================================
46
// class declarations
47
// ===========================================================================
48
class
GUIGlObject
;
49
50
51
// ===========================================================================
52
// class definitions
53
// ===========================================================================
65
template
<
typename
T>
66
class
GLObjectValuePassConnector
{
67
public
:
73
GLObjectValuePassConnector
(
GUIGlObject
& o,
ValueSource<T>
*source,
ValueRetriever<T>
*retriever)
74
:
myObject
(o),
mySource
(source),
myRetriever
(retriever) {
/*, myIsInvalid(false) */
75
myLock
.
lock
();
76
myContainer
.push_back(
this
);
77
myLock
.
unlock
();
78
}
79
80
82
virtual
~GLObjectValuePassConnector
() {
83
myLock
.
lock
();
84
typename
std::vector< GLObjectValuePassConnector<T>* >::iterator i = std::find(
myContainer
.begin(),
myContainer
.end(),
this
);
85
if
(i !=
myContainer
.end()) {
86
myContainer
.erase(i);
87
}
88
myLock
.
unlock
();
89
delete
mySource
;
90
}
91
92
95
98
static
void
updateAll
() {
99
myLock
.
lock
();
100
std::for_each(
myContainer
.begin(),
myContainer
.end(), std::mem_fun(&
GLObjectValuePassConnector<T>::passValue
));
101
myLock
.
unlock
();
102
}
103
104
107
static
void
clear
() {
108
myLock
.
lock
();
109
while
(!
myContainer
.empty()) {
110
delete
(*
myContainer
.begin());
111
}
112
myContainer
.clear();
113
myLock
.
unlock
();
114
}
115
116
122
static
void
removeObject
(
GUIGlObject
& o) {
123
myLock
.
lock
();
124
for
(
typename
std::vector<
GLObjectValuePassConnector<T>
* >::iterator i =
myContainer
.begin(); i !=
myContainer
.end();) {
125
if
((*i)->myObject.getGlID() == o.
getGlID
()) {
126
i =
myContainer
.erase(i);
127
}
else
{
128
++i;
129
}
130
}
131
myLock
.
unlock
();
132
}
134
135
136
protected
:
143
virtual
bool
passValue
() {
144
myRetriever
->addValue(
mySource
->getValue());
145
return
true
;
146
}
147
148
149
protected
:
151
GUIGlObject
&
myObject
;
152
154
ValueSource<T>
*
mySource
;
155
157
ValueRetriever<T>
*
myRetriever
;
158
160
static
MFXMutex
myLock
;
161
163
static
std::vector< GLObjectValuePassConnector<T>* >
myContainer
;
164
165
166
};
167
168
169
template
<
typename
T>
170
std::vector< GLObjectValuePassConnector<T>* >
GLObjectValuePassConnector<T>::myContainer
;
171
template
<
typename
T>
172
MFXMutex
GLObjectValuePassConnector<T>::myLock
;
173
174
175
#endif
176
177
/****************************************************************************/
178
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
utils
gui
div
GLObjectValuePassConnector.h
Generated on Mon Mar 24 2014 09:53:09 for SUMO - Simulation of Urban MObility by
1.8.1.2