SUMO - Simulation of Urban MObility
GUIGlObject_AbstractAdd.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Base class for additional objects (detectors etc.)
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2015 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 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
34 #include <cassert>
35 #include <iostream>
36 #include <algorithm>
37 #include <utils/gui/div/GLHelper.h>
39 
40 #ifdef CHECK_MEMORY_LEAKS
41 #include <foreign/nvwa/debug_new.h>
42 #endif // CHECK_MEMORY_LEAKS
43 
44 
45 // ===========================================================================
46 // static member definitions
47 // ===========================================================================
48 std::map<std::string, GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjects;
49 std::vector<GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjectList;
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 GUIGlObject_AbstractAdd::GUIGlObject_AbstractAdd(const std::string& prefix, GUIGlObjectType type, const std::string& id) :
56  GUIGlObject(prefix, type, id) {
57  myObjects[getFullName()] = this;
58  myObjectList.push_back(this);
59 }
60 
61 
63 
64 
65 void
67  std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i;
68  for (i = myObjects.begin(); i != myObjects.end(); i++) {
70  }
71  myObjects.clear();
72  myObjectList.clear();
73 }
74 
75 
77 GUIGlObject_AbstractAdd::get(const std::string& name) {
78  std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i = myObjects.find(name);
79  if (i == myObjects.end()) {
80  return 0;
81  }
82  return (*i).second;
83 }
84 
85 
86 void
88  myObjects.erase(o->getFullName());
89  myObjectList.erase(std::remove(myObjectList.begin(), myObjectList.end(), o), myObjectList.end());
90 }
91 
92 
93 const std::vector<GUIGlObject_AbstractAdd*>&
95  return myObjectList;
96 }
97 
98 
99 std::vector<GUIGlID>
101  std::vector<GUIGlID> ret;
102  for (std::vector<GUIGlObject_AbstractAdd*>::iterator i = myObjectList.begin(); i != myObjectList.end(); ++i) {
103  ret.push_back((*i)->getGlID());
104  }
105  return ret;
106 }
107 
108 /****************************************************************************/
109 
static std::vector< GUIGlID > getIDList()
Returns the list of gl-ids of all additional objects.
static std::map< std::string, GUIGlObject_AbstractAdd * > myObjects
Map from names of loaded additional objects to the objects themselves.
static void remove(GUIGlObject_AbstractAdd *o)
Removes an object.
GUIGlObjectType
static GUIGlObject_AbstractAdd * get(const std::string &name)
Returns a named object.
GUIGlObject_AbstractAdd(const std::string &prefix, GUIGlObjectType type, const std::string &id)
static std::vector< GUIGlObject_AbstractAdd * > myObjectList
The list of all addtional objects currently loaded.
static void clearDictionary()
Clears the dictionary (the objects will not be deleted)
static const std::vector< GUIGlObject_AbstractAdd * > & getObjectList()
Returns the list of all additional objects.
const std::string & getFullName() const
Returns the full name appearing in the tool tip.
Definition: GUIGlObject.h:108