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-2017 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 
41 // ===========================================================================
42 // static member definitions
43 // ===========================================================================
44 std::map<std::string, GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjects;
45 std::vector<GUIGlObject_AbstractAdd*> GUIGlObject_AbstractAdd::myObjectList;
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
51 GUIGlObject_AbstractAdd::GUIGlObject_AbstractAdd(const std::string& prefix, GUIGlObjectType type, const std::string& id) :
52  GUIGlObject(prefix, type, id) {
53  myObjects[getFullName()] = this;
54  myObjectList.push_back(this);
55 }
56 
57 
59 
60 
61 void
63  std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i;
64  for (i = myObjects.begin(); i != myObjects.end(); i++) {
66  }
67  myObjects.clear();
68  myObjectList.clear();
69 }
70 
71 
73 GUIGlObject_AbstractAdd::get(const std::string& name) {
74  std::map<std::string, GUIGlObject_AbstractAdd*>::iterator i = myObjects.find(name);
75  if (i == myObjects.end()) {
76  return 0;
77  }
78  return (*i).second;
79 }
80 
81 
82 void
84  myObjects.erase(o->getFullName());
85  myObjectList.erase(std::remove(myObjectList.begin(), myObjectList.end(), o), myObjectList.end());
86 }
87 
88 
89 const std::vector<GUIGlObject_AbstractAdd*>&
91  return myObjectList;
92 }
93 
94 
95 std::vector<GUIGlID>
97  std::vector<GUIGlID> ret;
98  for (std::vector<GUIGlObject_AbstractAdd*>::iterator i = myObjectList.begin(); i != myObjectList.end(); ++i) {
99  ret.push_back((*i)->getGlID());
100  }
101  return ret;
102 }
103 
104 /****************************************************************************/
105 
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