SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 <utils/gui/div/GLHelper.h>
38 
39 #ifdef CHECK_MEMORY_LEAKS
40 #include <foreign/nvwa/debug_new.h>
41 #endif // CHECK_MEMORY_LEAKS
42 
43 
44 // ===========================================================================
45 // static member definitions
46 // ===========================================================================
47 std::map<std::string, GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjects;
48 std::vector<GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjectList;
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 GUIGlObject_AbstractAdd::GUIGlObject_AbstractAdd(const std::string& prefix, GUIGlObjectType type, const std::string& id) :
55  GUIGlObject(prefix, type, id) {
56  myObjects[getFullName()] = this;
57  myObjectList.push_back(this);
58 }
59 
60 
62 
63 
64 void
66  std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i;
67  for (i = myObjects.begin(); i != myObjects.end(); i++) {
69  }
70  myObjects.clear();
71  myObjectList.clear();
72 }
73 
74 
76 GUIGlObject_AbstractAdd::get(const std::string& name) {
77  std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i = myObjects.find(name);
78  if (i == myObjects.end()) {
79  return 0;
80  }
81  return (*i).second;
82 }
83 
84 
85 void
87  myObjects.erase(o->getFullName());
88  myObjectList.erase(std::remove(myObjectList.begin(), myObjectList.end(), o), myObjectList.end());
89 }
90 
91 
92 const std::vector<GUIGlObject_AbstractAdd*>&
94  return myObjectList;
95 }
96 
97 
98 std::vector<GUIGlID>
100  std::vector<GUIGlID> ret;
101  for (std::vector<GUIGlObject_AbstractAdd*>::iterator i = myObjectList.begin(); i != myObjectList.end(); ++i) {
102  ret.push_back((*i)->getGlID());
103  }
104  return ret;
105 }
106 
107 /****************************************************************************/
108 
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:107