Eclipse SUMO - Simulation of Urban MObility
GUIGlObjectStorage.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A storage for displayed objects via their numerical id
18 /****************************************************************************/
19 #ifndef GUIGlObjectStorage_h
20 #define GUIGlObjectStorage_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <map>
29 #include <string>
30 #include <set>
31 #include <fx.h>
32 #include "GUIGlObject.h"
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
53 public:
56 
57 
60 
61 
71  GUIGlID registerObject(GUIGlObject* object, const std::string& fullName);
72 
73 
83 
84 
93  GUIGlObject* getObjectBlocking(const std::string& fullName);
94 
95 
105  bool remove(GUIGlID id);
106 
107 
112  void clear();
113 
114 
120  void unblockObject(GUIGlID id);
121 
122 
126  void setNetObject(GUIGlObject* object) {
127  myNetObject = object;
128  }
129 
130 
135  return myNetObject;
136  }
137 
138 
142 
143 
146  std::set<GUIGlID> getAllIDs() const;
147 
148 private:
150  typedef std::map<GUIGlID, GUIGlObject*> ObjectMap;
151 
154 
155  /* @brief The known objects by their fill name (used when loading selection
156  * from file */
157  std::map<std::string, GUIGlObject*> myFullNameMap;
158 
161 
164 
167 
169  mutable FXMutex myLock;
170 
173 
174 
175 private:
178 
181 
182 
183 };
184 
185 
186 #endif
187 
188 /****************************************************************************/
189 
GUIGlObject.h
GUIGlObjectStorage::ObjectMap
std::map< GUIGlID, GUIGlObject * > ObjectMap
Definition of a container from numerical ids to objects.
Definition: GUIGlObjectStorage.h:150
GUIGlObjectStorage
A storage for of displayed objects via their numerical id.
Definition: GUIGlObjectStorage.h:52
GUIGlObjectStorage::remove
bool remove(GUIGlID id)
Removes the named object from this container.
Definition: GUIGlObjectStorage.cpp:93
GUIGlObjectStorage::registerObject
GUIGlID registerObject(GUIGlObject *object, const std::string &fullName)
Registers an object.
Definition: GUIGlObjectStorage.cpp:53
GUIGlObjectStorage::GUIGlObjectStorage
GUIGlObjectStorage()
Constructor.
Definition: GUIGlObjectStorage.cpp:43
GUIGlObjectStorage::my2Delete
ObjectMap my2Delete
Objects to delete.
Definition: GUIGlObjectStorage.h:163
GUIGlObjectStorage::myLock
FXMutex myLock
A lock to avoid parallel access on the storages.
Definition: GUIGlObjectStorage.h:169
GUIGlObjectStorage::operator=
GUIGlObjectStorage & operator=(const GUIGlObjectStorage &s)
invalidate assignment operator
GUIGlObjectStorage::myBlocked
ObjectMap myBlocked
The currently accessed objects.
Definition: GUIGlObjectStorage.h:160
GUIGlObjectStorage::myNetObject
GUIGlObject * myNetObject
The network object.
Definition: GUIGlObjectStorage.h:172
GUIGlObjectStorage::myAktID
GUIGlID myAktID
The next id to give; initially zero, increased by one with each object registration.
Definition: GUIGlObjectStorage.h:166
GUIGlObjectStorage::setNetObject
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
Definition: GUIGlObjectStorage.h:126
GUIGlObjectStorage::getNetObject
GUIGlObject * getNetObject() const
Returns the network object.
Definition: GUIGlObjectStorage.h:134
GUIGlObjectStorage::getObjectBlocking
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
Definition: GUIGlObjectStorage.cpp:63
GUIGlObject
Definition: GUIGlObject.h:66
GUIGlObjectStorage::unblockObject
void unblockObject(GUIGlID id)
Marks an object as unblocked.
Definition: GUIGlObjectStorage.cpp:120
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GUIGlObjectStorage::myMap
ObjectMap myMap
The known objects which are not accessed currently.
Definition: GUIGlObjectStorage.h:153
GUIGlObjectStorage::getAllIDs
std::set< GUIGlID > getAllIDs() const
Returns the set of all known ids.
Definition: GUIGlObjectStorage.cpp:133
GUIGlObjectStorage::gIDStorage
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
Definition: GUIGlObjectStorage.h:141
config.h
GUIGlObjectStorage::myFullNameMap
std::map< std::string, GUIGlObject * > myFullNameMap
Definition: GUIGlObjectStorage.h:157
GUIGlObjectStorage::~GUIGlObjectStorage
~GUIGlObjectStorage()
Destructor.
Definition: GUIGlObjectStorage.cpp:49
GUIGlObjectStorage::clear
void clear()
Clears this container.
Definition: GUIGlObjectStorage.cpp:112