#include <GUIGlObjectStorage.h>
This is a container for GUIGlObject - objects, which may be displayed and due to this may generate tooltips or be grapped in other ways.
As in case of vehicles (other, later implemented objects may have this property, too) they may be deleted by the simulation while being accessed
Definition at line 66 of file GUIGlObjectStorage.h.
Public Member Functions | |
| void | clear () throw () |
| Clears this container. | |
| GUIGlObject *const | getNetObject () const throw () |
| Returns the network object. | |
| GUIGlObject * | getObjectBlocking (GLuint id) throw () |
| Returns the object from the container locking it. | |
| GLuint | getUniqueID () throw () |
| retrieves a unique id for an object to display | |
| GUIGlObjectStorage () throw () | |
| Constructor. | |
| void | registerObject (GUIGlObject *object) throw () |
| Registers an object. | |
| bool | remove (GLuint id) throw () |
| Removes the named object from this container. | |
| void | setNetObject (GUIGlObject *object) throw () |
| Sets the given object as the "network" object. | |
| void | unblockObject (GLuint id) throw () |
| Marks an object as unblocked. | |
| ~GUIGlObjectStorage () throw () | |
| Destructor. | |
Static Public Attributes | |
| static GUIGlObjectStorage | gIDStorage |
| A single static instance of this class. | |
Private Types | |
| typedef std::map< size_t, GUIGlObject * > | ObjectMap |
| Definition of a container from numerical ids to objects. | |
Private Member Functions | |
| GUIGlObjectStorage (const GUIGlObjectStorage &s) | |
| invalidated copy constructor | |
| GUIGlObjectStorage & | operator= (const GUIGlObjectStorage &s) |
| invalidate assignment operator | |
Private Attributes | |
| ObjectMap | my2Delete |
| Objects to delete. | |
| GLuint | myAktID |
| The next id to give; initially zero, increased by one with each object registration. | |
| ObjectMap | myBlocked |
| The currently accessed objects. | |
| MFXMutex | myLock |
| A lock to avoid parallel access on the storages. | |
| ObjectMap | myMap |
| The known objects which are not accessed currently. | |
| GUIGlObject * | myNetObject |
| The network object. | |
typedef std::map<size_t, GUIGlObject *> GUIGlObjectStorage::ObjectMap [private] |
Definition of a container from numerical ids to objects.
Definition at line 152 of file GUIGlObjectStorage.h.
| GUIGlObjectStorage::GUIGlObjectStorage | ( | ) | throw () |
| GUIGlObjectStorage::~GUIGlObjectStorage | ( | ) | throw () |
| GUIGlObjectStorage::GUIGlObjectStorage | ( | const GUIGlObjectStorage & | s | ) | [private] |
invalidated copy constructor
| void GUIGlObjectStorage::clear | ( | ) | throw () |
Clears this container.
The objects are not deleted.
Definition at line 118 of file GUIGlObjectStorage.cpp.
References MFXMutex::lock(), myAktID, myLock, myMap, and MFXMutex::unlock().
Referenced by GUINet::~GUINet().
| GUIGlObject* const GUIGlObjectStorage::getNetObject | ( | ) | const throw () [inline] |
Returns the network object.
Definition at line 141 of file GUIGlObjectStorage.h.
References myNetObject.
Referenced by GUISUMOAbstractView::openObjectDialog().
00141 { 00142 return myNetObject; 00143 }
| GUIGlObject * GUIGlObjectStorage::getObjectBlocking | ( | GLuint | id | ) | throw () |
Returns the object from the container locking it.
The lock prevents the object from being deleted while it is accessed. The object is moved from "myMap" to "myBlocked".
| [in] | id | The id of the object to return |
Definition at line 76 of file GUIGlObjectStorage.cpp.
References MFXMutex::lock(), myBlocked, myLock, myMap, and MFXMutex::unlock().
Referenced by GUISelectedStorage::deselect(), GUISUMOAbstractView::getObjectUnderCursor(), GUISelectedStorage::isSelected(), GUISUMOAbstractView::openObjectDialog(), GUISUMOAbstractView::paintGL(), GUIDialog_GLChosenEditor::rebuildList(), GUISelectedStorage::save(), GUISelectedStorage::SingleTypeSelections::save(), GUISelectedStorage::select(), GUISUMOAbstractView::showToolTipFor(), and GUISelectedStorage::toggleSelection().
00076 { 00077 myLock.lock(); 00078 ObjectMap::iterator i=myMap.find(id); 00079 if (i==myMap.end()) { 00080 i = myBlocked.find(id); 00081 if (i!=myBlocked.end()) { 00082 GUIGlObject *o = (*i).second; 00083 myLock.unlock(); 00084 return o; 00085 } 00086 myLock.unlock(); 00087 return 0; 00088 } 00089 GUIGlObject *o = (*i).second; 00090 myMap.erase(id); 00091 myBlocked[id] = o; 00092 myLock.unlock(); 00093 return o; 00094 }
| GLuint GUIGlObjectStorage::getUniqueID | ( | ) | throw () |
retrieves a unique id for an object to display
Definition at line 67 of file GUIGlObjectStorage.cpp.
References MFXMutex::lock(), myAktID, myLock, and MFXMutex::unlock().
00067 { 00068 myLock.lock(); 00069 GLuint ret = myAktID++; 00070 myLock.unlock(); 00071 return ret; 00072 }
| GUIGlObjectStorage& GUIGlObjectStorage::operator= | ( | const GUIGlObjectStorage & | s | ) | [private] |
invalidate assignment operator
| void GUIGlObjectStorage::registerObject | ( | GUIGlObject * | object | ) | throw () |
Registers an object.
This done within the constructor of the GUIGlObject; The object's "setGLID" method is called giving the next free id.
| [in] | object | The object to register |
Definition at line 58 of file GUIGlObjectStorage.cpp.
References MFXMutex::lock(), myAktID, myLock, myMap, and MFXMutex::unlock().
00058 { 00059 myLock.lock(); 00060 object->setGlID(myAktID); 00061 myMap[myAktID++] = object; 00062 myLock.unlock(); 00063 }
| bool GUIGlObjectStorage::remove | ( | GLuint | id | ) | throw () |
Removes the named object from this container.
This function returns true if the object may be deleted; otherwise it's kept in an internal storage (for visualisation etc.) and will be removed by this class
| [in] | id | The id of the object to remove |
Definition at line 98 of file GUIGlObjectStorage.cpp.
References MFXMutex::lock(), my2Delete, myBlocked, myLock, myMap, and MFXMutex::unlock().
00098 { 00099 myLock.lock(); 00100 ObjectMap::iterator i=myMap.find(id); 00101 if (i==myMap.end()) { 00102 i = myBlocked.find(id); 00103 assert(i!=myBlocked.end()); 00104 GUIGlObject *o = (*i).second; 00105 myBlocked.erase(id); 00106 my2Delete[id] = o; 00107 myLock.unlock(); 00108 return false; 00109 } else { 00110 myMap.erase(id); 00111 myLock.unlock(); 00112 return true; 00113 } 00114 }
| void GUIGlObjectStorage::setNetObject | ( | GUIGlObject * | object | ) | throw () [inline] |
Sets the given object as the "network" object.
| [in] | object | The object to set as network object |
Definition at line 133 of file GUIGlObjectStorage.h.
References myNetObject.
Referenced by GUINet::GUINet().
00133 { 00134 myNetObject = object; 00135 }
| void GUIGlObjectStorage::unblockObject | ( | GLuint | id | ) | throw () |
Marks an object as unblocked.
The object is moved from "myBlocked" to "myMap".
| [in] | id | The id of the object to unblock |
Definition at line 127 of file GUIGlObjectStorage.cpp.
References MFXMutex::lock(), myBlocked, myLock, myMap, and MFXMutex::unlock().
Referenced by GUISelectedStorage::deselect(), GUISUMOAbstractView::getObjectUnderCursor(), GUISelectedStorage::isSelected(), GUIDialog_GLChosenEditor::rebuildList(), GUISelectedStorage::save(), GUISelectedStorage::SingleTypeSelections::save(), GUISelectedStorage::select(), GUISUMOAbstractView::showToolTipFor(), and GUISelectedStorage::toggleSelection().
00127 { 00128 myLock.lock(); 00129 ObjectMap::iterator i=myBlocked.find(id); 00130 if (i==myBlocked.end()) { 00131 myLock.unlock(); 00132 return; 00133 } 00134 GUIGlObject *o = (*i).second; 00135 myBlocked.erase(id); 00136 myMap[id] = o; 00137 myLock.unlock(); 00138 }
A single static instance of this class.
Definition at line 148 of file GUIGlObjectStorage.h.
Referenced by GUIVehicleControl::buildVehicle(), GUIEdgeControlBuilder::closeEdge(), GUIVehicleControl::deleteVehicle(), GUISelectedStorage::deselect(), GUISUMOAbstractView::getObjectUnderCursor(), GUINet::GUINet(), GUINet::initDetectors(), GUINet::initGUIStructures(), GUINet::initTLMap(), GUISelectedStorage::isSelected(), GUISUMOAbstractView::openObjectDialog(), GUISUMOAbstractView::paintGL(), GUIDialog_GLChosenEditor::rebuildList(), GUILoadThread::run(), GUISelectedStorage::save(), GUISelectedStorage::SingleTypeSelections::save(), GUISelectedStorage::select(), GUISUMOViewParent::showLocator(), GUISUMOAbstractView::showToolTipFor(), GUISelectedStorage::toggleSelection(), and GUINet::~GUINet().
ObjectMap GUIGlObjectStorage::my2Delete [private] |
GLuint GUIGlObjectStorage::myAktID [private] |
The next id to give; initially zero, increased by one with each object registration.
Definition at line 164 of file GUIGlObjectStorage.h.
Referenced by clear(), getUniqueID(), and registerObject().
ObjectMap GUIGlObjectStorage::myBlocked [private] |
The currently accessed objects.
Definition at line 158 of file GUIGlObjectStorage.h.
Referenced by getObjectBlocking(), remove(), and unblockObject().
MFXMutex GUIGlObjectStorage::myLock [private] |
A lock to avoid parallel access on the storages.
Definition at line 167 of file GUIGlObjectStorage.h.
Referenced by clear(), getObjectBlocking(), getUniqueID(), registerObject(), remove(), and unblockObject().
ObjectMap GUIGlObjectStorage::myMap [private] |
The known objects which are not accessed currently.
Definition at line 155 of file GUIGlObjectStorage.h.
Referenced by clear(), getObjectBlocking(), registerObject(), remove(), and unblockObject().
GUIGlObject* GUIGlObjectStorage::myNetObject [private] |
The network object.
Definition at line 170 of file GUIGlObjectStorage.h.
Referenced by getNetObject(), and setNetObject().
1.5.6