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 
153  ObjectMap myMap;
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 
160  ObjectMap myBlocked;
161 
163  ObjectMap my2Delete;
164 
167 
169  mutable FXMutex myLock;
170 
173 
174 
175 private:
178 
181 
182 
183 };
184 
185 
186 #endif
187 
188 /****************************************************************************/
189 
GUIGlObjectStorage & operator=(const GUIGlObjectStorage &s)
invalidate assignment operator
ObjectMap my2Delete
Objects to delete.
std::set< GUIGlID > getAllIDs() const
Returns the set of all known ids.
std::map< std::string, GUIGlObject * > myFullNameMap
ObjectMap myBlocked
The currently accessed objects.
void clear()
Clears this container.
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
GUIGlID myAktID
The next id to give; initially zero, increased by one with each object registration.
GUIGlObject * myNetObject
The network object.
GUIGlObjectStorage()
Constructor.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
A storage for of displayed objects via their numerical id.
~GUIGlObjectStorage()
Destructor.
FXMutex myLock
A lock to avoid parallel access on the storages.
unsigned int GUIGlID
Definition: GUIGlObject.h:43
GUIGlObject * getNetObject() const
Returns the network object.
GUIGlID registerObject(GUIGlObject *object, const std::string &fullName)
Registers an object.
std::map< GUIGlID, GUIGlObject * > ObjectMap
Definition of a container from numerical ids to objects.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
ObjectMap myMap
The known objects which are not accessed currently.