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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A storage for displayed objects via their numerical id
20 /****************************************************************************/
21 #ifndef GUIGlObjectStorage_h
22 #define GUIGlObjectStorage_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <map>
35 #include <string>
36 #include <set>
37 #include <fx.h>
38 #include "GUIGlObject.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
60 public:
63 
64 
67 
68 
78  GUIGlID registerObject(GUIGlObject* object, const std::string& fullName);
79 
80 
90 
91 
100  GUIGlObject* getObjectBlocking(const std::string& fullName);
101 
102 
112  bool remove(GUIGlID id);
113 
114 
119  void clear();
120 
121 
127  void unblockObject(GUIGlID id);
128 
129 
133  void setNetObject(GUIGlObject* object) {
134  myNetObject = object;
135  }
136 
137 
142  return myNetObject;
143  }
144 
145 
149 
150 
153  std::set<GUIGlID> getAllIDs() const;
154 
155 private:
157  typedef std::map<GUIGlID, GUIGlObject*> ObjectMap;
158 
160  ObjectMap myMap;
161 
162  /* @brief The known objects by their fill name (used when loading selection
163  * from file */
164  std::map<std::string, GUIGlObject*> myFullNameMap;
165 
167  ObjectMap myBlocked;
168 
170  ObjectMap my2Delete;
171 
174 
176  mutable MFXMutex myLock;
177 
180 
181 
182 private:
185 
188 
189 
190 };
191 
192 
193 #endif
194 
195 /****************************************************************************/
196 
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.
unsigned int GUIGlID
Definition: GUIGlObject.h:49
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.
MFXMutex myLock
A lock to avoid parallel access on the storages.