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.dev/sumo
3 // Copyright (C) 2001-2024 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>
29 #include "GUIGlObject.h"
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
50 public:
53 
54 
57 
58 
67 
68  void changeName(GUIGlObject* object, const std::string& fullName);
69 
78 
86  GUIGlObject* getObjectBlocking(const std::string& fullName) const;
87 
97  bool remove(GUIGlID id);
98 
103  void clear();
104 
105 
111  void unblockObject(GUIGlID id);
112 
113 
117  void setNetObject(GUIGlObject* object) {
118  myNetObject = object;
119  }
120 
125  return myNetObject;
126  }
127 
130 
132  const std::vector<GUIGlObject*>& getAllGLObjects() const;
133 
134 private:
136  std::vector<GUIGlObject*> myObjects;
137 
139  std::map<std::string, GUIGlObject*> myFullNameMap;
140 
143 
145  mutable FXMutex myLock;
146 
149 
150 private:
153 
156 };
unsigned int GUIGlID
Definition: GUIGlObject.h:43
A storage for of displayed objects via their numerical id.
GUIGlObjectStorage()
Constructor.
GUIGlObjectStorage(const GUIGlObjectStorage &s)=delete
invalidated copy constructor
GUIGlID registerObject(GUIGlObject *object)
Registers an object.
void clear()
Clears this container.
~GUIGlObjectStorage()
Destructor.
GUIGlObjectStorage & operator=(const GUIGlObjectStorage &s)=delete
invalidate assignment operator
const std::vector< GUIGlObject * > & getAllGLObjects() const
Returns the set of all known objects.
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
void changeName(GUIGlObject *object, const std::string &fullName)
void unblockObject(GUIGlID id)
Marks an object as unblocked.
GUIGlObject * getNetObject() const
Returns the network object.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
std::vector< GUIGlObject * > myObjects
The known objects.
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.
GUIGlID myNextID
The next id to give; initially one, increased by one with each object registration.
std::map< std::string, GUIGlObject * > myFullNameMap
The known objects by their full name.
GUIGlObject * myNetObject
The network object.