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-2018 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"
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
54 public:
57 
58 
61 
62 
72  GUIGlID registerObject(GUIGlObject* object, const std::string& fullName);
73 
74 
84 
85 
94  GUIGlObject* getObjectBlocking(const std::string& fullName);
95 
96 
106  bool remove(GUIGlID id);
107 
108 
113  void clear();
114 
115 
121  void unblockObject(GUIGlID id);
122 
123 
127  void setNetObject(GUIGlObject* object) {
128  myNetObject = object;
129  }
130 
131 
136  return myNetObject;
137  }
138 
139 
143 
144 
147  std::set<GUIGlID> getAllIDs() const;
148 
149 private:
151  typedef std::map<GUIGlID, GUIGlObject*> ObjectMap;
152 
154  ObjectMap myMap;
155 
156  /* @brief The known objects by their fill name (used when loading selection
157  * from file */
158  std::map<std::string, GUIGlObject*> myFullNameMap;
159 
161  ObjectMap myBlocked;
162 
164  ObjectMap my2Delete;
165 
168 
170  mutable MFXMutex myLock;
171 
174 
175 
176 private:
179 
182 
183 
184 };
185 
186 
187 #endif
188 
189 /****************************************************************************/
190 
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: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.
MFXMutex myLock
A lock to avoid parallel access on the storages.