SUMO - Simulation of Urban MObility

GUISelectedStorage.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Storage for "selected" objects
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef GUISelectedStorage_h
00020 #define GUISelectedStorage_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <set>
00033 #include <string>
00034 #include <map>
00035 #include <fstream>
00036 #include <fx.h>
00037 #include <utils/common/UtilExceptions.h>
00038 #include <utils/gui/globjects/GUIGlObject.h>
00039 
00040 
00041 // ===========================================================================
00042 // class declarations
00043 // ===========================================================================
00044 class OutputDevice;
00045 
00046 
00047 // ===========================================================================
00048 // class definitions
00049 // ===========================================================================
00074 class GUISelectedStorage {
00075 
00076 public:
00077     class UpdateTarget {
00078     public:
00079         virtual ~UpdateTarget() {};
00080         virtual void selectionUpdated() = 0;
00081     };
00082 
00083 public:
00085     GUISelectedStorage();
00086 
00087 
00089     ~GUISelectedStorage();
00090 
00091 
00108     bool isSelected(GUIGlObjectType type, GUIGlID id);
00109 
00110 
00126     void select(GUIGlID id, bool update=true);
00127 
00128 
00144     void deselect(GUIGlID id);
00145 
00146 
00161     void toggleSelection(GUIGlID id);
00162 
00163 
00169     const std::set<GUIGlID> &getSelected() const;
00170 
00171 
00178     const std::set<GUIGlID> &getSelected(GUIGlObjectType type);
00179 
00180 
00187     void clear();
00188 
00189 
00196     std::string load(const std::string& filename, GUIGlObjectType type = GLO_MAX);
00197 
00198 
00207     std::set<GUIGlID> loadIDs(const std::string& filename, std::string& msgOut, GUIGlObjectType type = GLO_MAX);
00208 
00209 
00215     void save(GUIGlObjectType type, const std::string& filename);
00216 
00221     void save(const std::string& filename) const;
00222 
00223 
00227     void add2Update(UpdateTarget* updateTarget);
00228 
00229 
00232     void remove2Update();
00233 
00234 
00239     class SingleTypeSelections {
00240     public:
00242         SingleTypeSelections();
00243 
00245         ~SingleTypeSelections();
00246 
00247 
00252         bool isSelected(GUIGlID id);
00253 
00254 
00258         void select(GUIGlID id);
00259 
00260 
00264         void deselect(GUIGlID id);
00265 
00266 
00268         void clear();
00269 
00270 
00274         void save(const std::string& filename);
00275 
00276 
00280         const std::set<GUIGlID> &getSelected() const;
00281 
00282     private:
00284         std::set<GUIGlID> mySelected;
00285 
00286     };
00287     friend class SingleTypeSelections;
00288 
00289 
00290 private:
00291     std::map<GUIGlObjectType, SingleTypeSelections> mySelections;
00292 
00294     std::set<GUIGlID> myAllSelected;
00295 
00297     UpdateTarget* myUpdateTarget;
00298 
00299     /* @brief load items into the given set, optionally restricting to type
00300      */
00301     std::string load(GUIGlObjectType type, const std::string& filename, bool restrictType, std::set<GUIGlID>& into);
00302 
00303 
00305     static void save(const std::string& filename, const std::set<GUIGlID>& ids);
00306 
00307 };
00308 
00309 
00310 #endif
00311 
00312 /****************************************************************************/
00313 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines