SUMO - Simulation of Urban MObility
GUIGlObjectStorage.h
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.dlr.de/
12 // Copyright (C) 2001-2016 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 #ifndef GUIGlObjectStorage_h
23 #define GUIGlObjectStorage_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <map>
36 #include <string>
37 #include <set>
38 #include <fx.h>
39 #include "GUIGlObject.h"
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
61 public:
64 
65 
68 
69 
79  GUIGlID registerObject(GUIGlObject* object, const std::string& fullName);
80 
81 
91 
92 
101  GUIGlObject* getObjectBlocking(const std::string& fullName);
102 
103 
113  bool remove(GUIGlID id);
114 
115 
120  void clear();
121 
122 
128  void unblockObject(GUIGlID id);
129 
130 
134  void setNetObject(GUIGlObject* object) {
135  myNetObject = object;
136  }
137 
138 
143  return myNetObject;
144  }
145 
146 
150 
151 
154  std::set<GUIGlID> getAllIDs() const;
155 
156 private:
158  typedef std::map<GUIGlID, GUIGlObject*> ObjectMap;
159 
161  ObjectMap myMap;
162 
163  /* @brief The known objects by their fill name (used when loading selection
164  * from file */
165  std::map<std::string, GUIGlObject*> myFullNameMap;
166 
168  ObjectMap myBlocked;
169 
171  ObjectMap my2Delete;
172 
175 
177  mutable MFXMutex myLock;
178 
181 
182 
183 private:
186 
189 
190 
191 };
192 
193 
194 #endif
195 
196 /****************************************************************************/
197 
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.
GUIGlObject * getNetObject() const
Returns the network object.
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:50
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.