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-sim.org/
13
// Copyright (C) 2001-2014 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
AbstractMutex::ScopedLocker
locker(
myLock
);
76
myContainer
.push_back(
this
);
77
}
78
79
81
virtual
~GLObjectValuePassConnector
() {
82
myLock
.
lock
();
83
typename
std::vector< GLObjectValuePassConnector<T>* >::iterator i = std::find(
myContainer
.begin(),
myContainer
.end(),
this
);
84
if
(i !=
myContainer
.end()) {
85
myContainer
.erase(i);
86
}
87
myLock
.
unlock
();
88
delete
mySource
;
89
}
90
91
94
97
static
void
updateAll
() {
98
AbstractMutex::ScopedLocker
locker(
myLock
);
99
std::for_each(
myContainer
.begin(),
myContainer
.end(), std::mem_fun(&
GLObjectValuePassConnector<T>::passValue
));
100
}
101
102
105
static
void
clear
() {
106
AbstractMutex::ScopedLocker
locker(
myLock
);
107
while
(!
myContainer
.empty()) {
108
delete
(*
myContainer
.begin());
109
}
110
myContainer
.clear();
111
}
112
113
119
static
void
removeObject
(
GUIGlObject
& o) {
120
AbstractMutex::ScopedLocker
locker(
myLock
);
121
for
(
typename
std::vector<
GLObjectValuePassConnector<T>
* >::iterator i =
myContainer
.begin(); i !=
myContainer
.end();) {
122
if
((*i)->myObject.getGlID() == o.
getGlID
()) {
123
i =
myContainer
.erase(i);
124
}
else
{
125
++i;
126
}
127
}
128
}
130
131
132
protected
:
139
virtual
bool
passValue
() {
140
myRetriever
->addValue(
mySource
->getValue());
141
return
true
;
142
}
143
144
145
protected
:
147
GUIGlObject
&
myObject
;
148
150
ValueSource<T>
*
mySource
;
151
153
ValueRetriever<T>
*
myRetriever
;
154
156
static
MFXMutex
myLock
;
157
159
static
std::vector< GLObjectValuePassConnector<T>* >
myContainer
;
160
161
162
private
:
164
GLObjectValuePassConnector<T>
(
const
GLObjectValuePassConnector<T>
&);
165
167
GLObjectValuePassConnector<T>
&
operator=
(
const
GLObjectValuePassConnector<T>
&);
168
169
170
};
171
172
173
template
<
typename
T>
174
std::vector< GLObjectValuePassConnector<T>* >
GLObjectValuePassConnector<T>::myContainer
;
175
template
<
typename
T>
176
MFXMutex
GLObjectValuePassConnector<T>::myLock
;
177
178
179
#endif
180
181
/****************************************************************************/
182
tmp
buildd
sumo-0.21.0+dfsg
src
utils
gui
div
GLObjectValuePassConnector.h
Generated on Thu Nov 20 2014 19:49:53 for SUMO - Simulation of Urban MObility by
1.8.1.2