SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUISelectedStorage.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Storage for "selected" objects
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 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 #ifndef GUISelectedStorage_h
23 #define GUISelectedStorage_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <set>
36 #include <string>
37 #include <map>
38 #include <fstream>
39 #include <fx.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class OutputDevice;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
78 
79 public:
80  class UpdateTarget {
81  public:
82  virtual ~UpdateTarget() {};
83  virtual void selectionUpdated() = 0;
84  };
85 
86 public:
89 
90 
93 
94 
111  bool isSelected(GUIGlObjectType type, GUIGlID id);
112 
113 
129  void select(GUIGlID id, bool update = true);
130 
131 
147  void deselect(GUIGlID id);
148 
149 
164  void toggleSelection(GUIGlID id);
165 
166 
172  const std::set<GUIGlID> &getSelected() const;
173 
174 
181  const std::set<GUIGlID> &getSelected(GUIGlObjectType type);
182 
183 
190  void clear();
191 
192 
199  std::string load(const std::string& filename, GUIGlObjectType type = GLO_MAX);
200 
201 
210  std::set<GUIGlID> loadIDs(const std::string& filename, std::string& msgOut, GUIGlObjectType type = GLO_MAX);
211 
212 
218  void save(GUIGlObjectType type, const std::string& filename);
219 
224  void save(const std::string& filename) const;
225 
226 
230  void add2Update(UpdateTarget* updateTarget);
231 
232 
235  void remove2Update();
236 
237 
243  public:
246 
249 
250 
255  bool isSelected(GUIGlID id);
256 
257 
261  void select(GUIGlID id);
262 
263 
267  void deselect(GUIGlID id);
268 
269 
271  void clear();
272 
273 
277  void save(const std::string& filename);
278 
279 
283  const std::set<GUIGlID> &getSelected() const;
284 
285  private:
287  std::set<GUIGlID> mySelected;
288 
289  };
290  friend class SingleTypeSelections;
291 
292 
293 private:
294  std::map<GUIGlObjectType, SingleTypeSelections> mySelections;
295 
297  std::set<GUIGlID> myAllSelected;
298 
301 
302  /* @brief load items into the given set, optionally restricting to type
303  */
304  std::string load(GUIGlObjectType type, const std::string& filename, bool restrictType, std::set<GUIGlID>& into);
305 
306 
308  static void save(const std::string& filename, const std::set<GUIGlID>& ids);
309 
310 };
311 
312 
313 #endif
314 
315 /****************************************************************************/
316