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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A storage for displayed objects via their numerical id
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <map>
26 #include <string>
27 #include <set>
28 #include <fx.h>
29 #include "GUIGlObject.h"
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
50 public:
53 
54 
57 
58 
68  GUIGlID registerObject(GUIGlObject* object, const std::string& fullName);
69 
70 
80 
81 
90  GUIGlObject* getObjectBlocking(const std::string& fullName);
91 
92 
102  bool remove(GUIGlID id);
103 
104 
109  void clear();
110 
111 
117  void unblockObject(GUIGlID id);
118 
119 
123  void setNetObject(GUIGlObject* object) {
124  myNetObject = object;
125  }
126 
127 
132  return myNetObject;
133  }
134 
135 
139 
140 
143  std::set<GUIGlID> getAllIDs() const;
144 
145 private:
147  typedef std::map<GUIGlID, GUIGlObject*> ObjectMap;
148 
151 
152  /* @brief The known objects by their fill name (used when loading selection
153  * from file */
154  std::map<std::string, GUIGlObject*> myFullNameMap;
155 
158 
161 
164 
166  mutable FXMutex myLock;
167 
170 
171 
172 private:
175 
178 
179 
180 };
unsigned int GUIGlID
Definition: GUIGlObject.h:40
A storage for of displayed objects via their numerical id.
GUIGlObjectStorage(const GUIGlObjectStorage &s)
invalidated copy constructor
GUIGlObjectStorage()
Constructor.
GUIGlID registerObject(GUIGlObject *object, const std::string &fullName)
Registers an object.
void clear()
Clears this container.
~GUIGlObjectStorage()
Destructor.
GUIGlObjectStorage & operator=(const GUIGlObjectStorage &s)
invalidate assignment operator
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlID myAktID
The next id to give; initially zero, increased by one with each object registration.
ObjectMap myBlocked
The currently accessed objects.
GUIGlObject * getNetObject() const
Returns the network object.
ObjectMap myMap
The known objects which are not accessed currently.
std::set< GUIGlID > getAllIDs() const
Returns the set of all known ids.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
FXMutex myLock
A lock to avoid parallel access on the storages.
bool remove(GUIGlID id)
Removes the named object from this container.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
std::map< std::string, GUIGlObject * > myFullNameMap
ObjectMap my2Delete
Objects to delete.
std::map< GUIGlID, GUIGlObject * > ObjectMap
Definition of a container from numerical ids to objects.
GUIGlObject * myNetObject
The network object.