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
GUIGlObjectStorage.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A storage for displayed objects via their numerical id
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12
// Copyright (C) 2001-2012 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 <map>
34
#include <iostream>
35
#include <cassert>
36
#include <
utils/foxtools/MFXMutex.h
>
37
#include "
GUIGlObject.h
"
38
#include "
GUIGlObjectStorage.h
"
39
40
#ifdef CHECK_MEMORY_LEAKS
41
#include <
foreign/nvwa/debug_new.h
>
42
#endif // CHECK_MEMORY_LEAKS
43
44
45
// ===========================================================================
46
// static variables (instances in this case)
47
// ===========================================================================
48
GUIGlObjectStorage
GUIGlObjectStorage::gIDStorage
;
49
50
51
// ===========================================================================
52
// method definitions
53
// ===========================================================================
54
GUIGlObjectStorage::GUIGlObjectStorage
()
55
: myAktID(0) {}
56
57
58
GUIGlObjectStorage::~GUIGlObjectStorage
() {}
59
60
61
GUIGlID
62
GUIGlObjectStorage::registerObject
(
GUIGlObject
*
object
,
const
std::string& fullName) {
63
myLock
.
lock
();
64
GUIGlID
id
=
myAktID
++;
65
myMap
[id] = object;
66
myFullNameMap
[fullName] = object;
67
myLock
.
unlock
();
68
return
id;
69
}
70
71
72
GUIGlObject
*
73
GUIGlObjectStorage::getObjectBlocking
(
GUIGlID
id
) {
74
myLock
.
lock
();
75
ObjectMap::iterator i =
myMap
.find(
id
);
76
if
(i ==
myMap
.end()) {
77
i =
myBlocked
.find(
id
);
78
if
(i !=
myBlocked
.end()) {
79
GUIGlObject
* o = (*i).second;
80
myLock
.
unlock
();
81
return
o;
82
}
83
myLock
.
unlock
();
84
return
0;
85
}
86
GUIGlObject
* o = (*i).second;
87
myMap
.erase(
id
);
88
myBlocked
[id] = o;
89
myLock
.
unlock
();
90
return
o;
91
}
92
93
94
GUIGlObject
*
95
GUIGlObjectStorage::getObjectBlocking
(
const
std::string& fullName) {
96
myLock
.
lock
();
97
if
(
myFullNameMap
.count(fullName)) {
98
GUIGlID
id
=
myFullNameMap
[fullName]->getGlID();
99
myLock
.
unlock
();
100
return
getObjectBlocking
(
id
);
101
}
else
{
102
myLock
.
unlock
();
103
return
0;
104
}
105
}
106
107
108
bool
109
GUIGlObjectStorage::remove
(
GUIGlID
id
) {
110
myLock
.
lock
();
111
ObjectMap::iterator i =
myMap
.find(
id
);
112
if
(i ==
myMap
.end()) {
113
i =
myBlocked
.find(
id
);
114
assert(i !=
myBlocked
.end());
115
GUIGlObject
* o = (*i).second;
116
myFullNameMap
.erase(o->getFullName());
117
myBlocked
.erase(
id
);
118
my2Delete
[id] = o;
119
myLock
.
unlock
();
120
return
false
;
121
}
else
{
122
myFullNameMap
.erase(i->second->getFullName());
123
myMap
.erase(
id
);
124
myLock
.
unlock
();
125
return
true
;
126
}
127
}
128
129
130
void
131
GUIGlObjectStorage::clear
() {
132
myLock
.
lock
();
133
myMap
.clear();
134
myAktID
= 0;
135
myLock
.
unlock
();
136
}
137
138
139
void
140
GUIGlObjectStorage::unblockObject
(
GUIGlID
id
) {
141
myLock
.
lock
();
142
ObjectMap::iterator i =
myBlocked
.find(
id
);
143
if
(i ==
myBlocked
.end()) {
144
myLock
.
unlock
();
145
return
;
146
}
147
GUIGlObject
* o = (*i).second;
148
myBlocked
.erase(
id
);
149
myMap
[id] = o;
150
myLock
.
unlock
();
151
}
152
153
154
std::set<GUIGlID>
155
GUIGlObjectStorage::getAllIDs
()
const
{
156
std::set<GUIGlID> result;
157
for
(ObjectMap::const_iterator it =
myMap
.begin(); it !=
myMap
.end(); it++) {
158
result.insert(it->first);
159
}
160
return
result;
161
}
162
/****************************************************************************/
163
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
utils
gui
globjects
GUIGlObjectStorage.cpp
Generated on Mon Mar 24 2014 09:53:09 for SUMO - Simulation of Urban MObility by
1.8.1.2