diff -r 004b239908e6 -r cfd49e5c8723 mapstorage.h --- a/mapstorage.h Mon Jan 09 12:41:06 2006 +0000 +++ b/mapstorage.h Tue Jan 10 15:15:57 2006 +0000 @@ -9,6 +9,8 @@ #include "xymap.h" #include +///class MapStorage handles NodeMaps and EdgeMaps. + ///Class MapStorage is responsible for storing ///NodeMaps and EdgeMaps that can be shown later ///on GUI. Therefore maps can be added to it, @@ -22,13 +24,17 @@ { public: + ///The graph for which the datas are stored. Graph graph; /// the coordinates of the nodes XYMap > coords; /// the coordinates of the arrows on the edges XYMap > arrow_pos; + ///The content of the object has changed, update is needed. bool modified; + + ///Name of file loaded in object. std::string file_name; ///Stores double type NodeMaps @@ -37,67 +43,119 @@ ///Stores double type EdgeMaps std::map< std::string,Graph::EdgeMap * > edgemap_storage; - //Stores the default values for the different visualization node attributes + ///Stores the default values for the different visualization node attributes std::vector > default_nodemaps; - //Stores the default values for the different visualization edge attributes + ///Stores the default values for the different visualization edge attributes std::vector > default_edgemaps; - //Stores the active maps for the different visualization node attributes + ///Stores the active maps for the different visualization node attributes std::vector< std::string > active_nodemaps; - //Stores the active maps for the different visualization edge attributes + /// Stores the active maps for the different visualization edge attributes std::vector< std::string > active_edgemaps; - // Default values for the maps + /// Default values for the maps std::map< std::string, double > nodemap_default; - // Default values for the maps + /// Default values for the maps std::map< std::string, double > edgemap_default; bool arrow_pos_read_ok; protected: + /// type of the signal emitted if the visualization of the maps might have to be updated. + + /// bool shows us whether the changed map is edge or nodemap. + /// int tells us the refreshed property typedef sigc::signal Signal_Prop; + + /// Signal emitted on any change made on map values Signal_Prop signal_prop; + + /// Signal emitted in the case of nodemap addition + + /// std::string is the + ///name of the new map sigc::signal signal_node_map; + + /// Signal emitted in the case of edgemap addition + + /// std::string is the + ///name of the new map sigc::signal signal_edge_map; public: - ///Constructor of MapStorage. Expects the Graph of - ///which maps will be stored in it. + ///Constructor of MapStorage. + ///Its all activity is initializing default values - ///for different visualization attributes - /// - ///\param graph is the graph for which the maps are stored in this object. + ///for different visualization attributes. MapStorage(); + ///Destructor of MapStorage + + ///Maps stored here are created with new. Destructor + ///deletes them to free up the reserved memory. ~MapStorage(); - void changeActiveMap(bool, int, std::string); + /// Registrates if the shown map by any attribute has changed to another. - std::string getActiveEdgeMap(int); - std::string getActiveNodeMap(int); + ///It handles the \ref active_edgemaps and + ///\ref active_nodemaps vectors. It also emits \ref signal_prop signal to let + ///know the interested objects that the visible map of a certain + ///attribute has changed. + ///\param itisedge edgemap or nodemap has changed + ///\param prop the property of which the map is changed + ///\param mapname the visible map + void changeActiveMap(bool itisedge , int prop , std::string mapname); + /// Returns the active edgemap shown by a visualization property. + + /// \param prop is the property + ///that shows the requested map. + std::string getActiveEdgeMap(int prop); + + /// Returns the active nodemap shown by a visualization property. + + /// \param prop is the property + ///that shows the requested map. + std::string getActiveNodeMap(int prop); + + /// Returns the names of the edgemaps stored here. std::vector getEdgeMapList(); + + /// Returns the names of the nodemaps stored here. std::vector getNodeMapList(); + ///returns \ref signal_prop to be able to connect functions to it Signal_Prop signal_prop_ch(); + ///returns \ref signal_node_map to be able to connect functions to it sigc::signal signal_node_map_ch(){return signal_node_map;}; + + ///returns \ref signal_edge_map to be able to connect functions to it sigc::signal signal_edge_map_ch(){return signal_edge_map;}; - ///Adds given map to storage. A name and the map itself has to be provided. - ///\param name is the name of map - ///\nodemap is the pointer of the given nodemap + ///Adds given map to storage. + + ///A name and the map itself has to be provided. + ///\param mapname is the name of map + ///\param nodemap is the pointer of the given nodemap + ///\param def the default value of the map. If not given, it will be 0. + ///If new edge is added to graph the value of it in the map will be this. ///\todo map should be given by reference! - int addNodeMap(const std::string &,Graph::NodeMap *, double); + ///\todo why is default value stored? + int addNodeMap(const std::string & mapname,Graph::NodeMap * nodemap, double def=0.0); ///Adds given map to storage. A name and the map itself has to be provided. - ///\param name is the name of map - ///\edgemap is the pointer of the given edgemap + + ///A name and the map itself has to be provided. + ///\param mapname is the name of map + ///\param edgemap is the pointer of the given edgemap + ///\param def the default value of the map. If not given, it will be 0. + ///If new edge is added to graph the value of it in the map will be this. ///\todo map should be given by reference! - int addEdgeMap(const std::string &,Graph::EdgeMap *, double); + int addEdgeMap(const std::string & mapname,Graph::EdgeMap * edgemap, double def=0.0); ///Returns how much nodemaps is stored in \ref MapStorage int numOfNodeMaps() {return nodemap_storage.size();}; @@ -105,39 +163,74 @@ ///Returns how much edgemaps is stored in \ref MapStorage int numOfEdgeMaps() {return edgemap_storage.size();}; - ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name. - ///\param name is the name of map of which maximum is searched - double maxOfNodeMap(const std::string &); + ///Returns the maximum value of the given NodeMap. - ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name. - ///\param name is the name of map of which maximum is searched - double maxOfEdgeMap(const std::string &); + ///NodeMap has to be given by its name. + ///\param name the name of map of which maximum is searched + double maxOfNodeMap(const std::string & name); - ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name. - ///\param name is the name of map of which minimum is searched - double minOfNodeMap(const std::string &); + ///Returns the maximum value of the given EdgeMap. - ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name. - ///\param name is the name of map of which minimum is searched - double minOfEdgeMap(const std::string &); + ///EdgeMap has to be given by its name. + ///\param name the name of map of which maximum is searched + double maxOfEdgeMap(const std::string & name); - ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage. + ///Returns the minimum value of the given NodeMap. + + ///NodeMap has to be given by its name. + ///\param name the name of map of which minimum is searched + double minOfNodeMap(const std::string & name); + + ///Returns the minimum value of the given EdgeMap. + + ///EdgeMap has to be given by its name. + ///\param name the name of map of which minimum is searched + double minOfEdgeMap(const std::string & name); + + ///Returns iterator pointing to the first NodeMap in storage. + + ///To be able to iterate through each maps this function + ///returns an iterator pointing to the first nodemap in + ///the storage. std::map< std::string,Graph::NodeMap * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();}; - ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage. + ///Returns iterator pointing to the first EdgeMap in storage. + + ///To be able to iterate through each maps this function + ///returns an iterator pointing to the first edgemap in + ///the storage. std::map< std::string,Graph::EdgeMap * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();}; - ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage. + ///Returns iterator pointing after the last NodeMap in storage. + + ///To be able to iterate through each maps this function + ///returns an iterator pointing to the last nodemap in the storage. std::map< std::string,Graph::NodeMap * >::iterator endOfNodeMaps(){return nodemap_storage.end();}; - ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage. + ///Returns iterator pointing after the last EdgeMap in storage. + + ///To be able to iterate through each maps this function + ///returns an iterator pointing to the last edgemap in the storage. std::map< std::string,Graph::EdgeMap * >::iterator endOfEdgeMaps(){return edgemap_storage.end();}; - void mapChanged(bool, std::string); + ///Emits \ref signal_prop if mapvalues have changed, and MapStorage gets to know it. + ///If values in a map have changed, this function checks, whether it is displayed. + ///This check means searching the given mapname between active maps + ///(\ref active_nodemaps, \ref active_edgemaps). If it is there at a certain property, + ///it emits a signal with the property, where the gotten mapname was found. One signal + ///is emitted for each property displaying the given map. + ///\param itisedge whether the map an edgemap or nodemap + ///\param mapname name of map to visualize + void mapChanged(bool itisedge, std::string mapname); + + ///Read datas from the given filename. int readFromFile(const std::string &); + + ///Save datas to the given filename. void writeToFile(const std::string &); + ///Deletes all datastructures stored here. void clear(); void ArrowPosReadOK();