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 /****************************************************************************/
16 // A storage for displayed objects via their numerical id
17 /****************************************************************************/
18 #ifndef GUIGlObjectStorage_h
19 #define GUIGlObjectStorage_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <map>
28 #include <string>
29 #include <set>
30 #include <fx.h>
31 #include "GUIGlObject.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
52 public:
55 
56 
59 
60 
70  GUIGlID registerObject(GUIGlObject* object, const std::string& fullName);
71 
72 
82 
83 
92  GUIGlObject* getObjectBlocking(const std::string& fullName);
93 
94 
104  bool remove(GUIGlID id);
105 
106 
111  void clear();
112 
113 
119  void unblockObject(GUIGlID id);
120 
121 
125  void setNetObject(GUIGlObject* object) {
126  myNetObject = object;
127  }
128 
129 
134  return myNetObject;
135  }
136 
137 
141 
142 
145  std::set<GUIGlID> getAllIDs() const;
146 
147 private:
149  typedef std::map<GUIGlID, GUIGlObject*> ObjectMap;
150 
153 
154  /* @brief The known objects by their fill name (used when loading selection
155  * from file */
156  std::map<std::string, GUIGlObject*> myFullNameMap;
157 
160 
163 
166 
168  mutable FXMutex myLock;
169 
172 
173 
174 private:
177 
180 
181 
182 };
183 
184 
185 #endif
186 
187 /****************************************************************************/
188 
GUIGlObject.h
GUIGlObjectStorage::GUIGlObjectStorage
GUIGlObjectStorage(const GUIGlObjectStorage &s)
invalidated copy constructor
GUIGlObjectStorage::ObjectMap
std::map< GUIGlID, GUIGlObject * > ObjectMap
Definition of a container from numerical ids to objects.
Definition: GUIGlObjectStorage.h:149
GUIGlObjectStorage
A storage for of displayed objects via their numerical id.
Definition: GUIGlObjectStorage.h:51
GUIGlObjectStorage::remove
bool remove(GUIGlID id)
Removes the named object from this container.
Definition: GUIGlObjectStorage.cpp:92
GUIGlObjectStorage::registerObject
GUIGlID registerObject(GUIGlObject *object, const std::string &fullName)
Registers an object.
Definition: GUIGlObjectStorage.cpp:52
GUIGlObjectStorage::GUIGlObjectStorage
GUIGlObjectStorage()
Constructor.
Definition: GUIGlObjectStorage.cpp:42
GUIGlObjectStorage::my2Delete
ObjectMap my2Delete
Objects to delete.
Definition: GUIGlObjectStorage.h:162
GUIGlObjectStorage::myLock
FXMutex myLock
A lock to avoid parallel access on the storages.
Definition: GUIGlObjectStorage.h:168
GUIGlObjectStorage::operator=
GUIGlObjectStorage & operator=(const GUIGlObjectStorage &s)
invalidate assignment operator
GUIGlObjectStorage::myBlocked
ObjectMap myBlocked
The currently accessed objects.
Definition: GUIGlObjectStorage.h:159
GUIGlObjectStorage::myNetObject
GUIGlObject * myNetObject
The network object.
Definition: GUIGlObjectStorage.h:171
GUIGlObjectStorage::myAktID
GUIGlID myAktID
The next id to give; initially zero, increased by one with each object registration.
Definition: GUIGlObjectStorage.h:165
GUIGlObjectStorage::setNetObject
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
Definition: GUIGlObjectStorage.h:125
GUIGlObjectStorage::getNetObject
GUIGlObject * getNetObject() const
Returns the network object.
Definition: GUIGlObjectStorage.h:133
GUIGlObjectStorage::getObjectBlocking
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
Definition: GUIGlObjectStorage.cpp:62
GUIGlObject
Definition: GUIGlObject.h:65
GUIGlObjectStorage::unblockObject
void unblockObject(GUIGlID id)
Marks an object as unblocked.
Definition: GUIGlObjectStorage.cpp:119
GUIGlID
unsigned int GUIGlID
Definition: GUIGlObject.h:42
GUIGlObjectStorage::myMap
ObjectMap myMap
The known objects which are not accessed currently.
Definition: GUIGlObjectStorage.h:152
GUIGlObjectStorage::getAllIDs
std::set< GUIGlID > getAllIDs() const
Returns the set of all known ids.
Definition: GUIGlObjectStorage.cpp:132
GUIGlObjectStorage::gIDStorage
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
Definition: GUIGlObjectStorage.h:140
config.h
GUIGlObjectStorage::myFullNameMap
std::map< std::string, GUIGlObject * > myFullNameMap
Definition: GUIGlObjectStorage.h:156
GUIGlObjectStorage::~GUIGlObjectStorage
~GUIGlObjectStorage()
Destructor.
Definition: GUIGlObjectStorage.cpp:48
GUIGlObjectStorage::clear
void clear()
Clears this container.
Definition: GUIGlObjectStorage.cpp:111