gui/mapstorage.h
author deba
Fri, 28 Oct 2005 09:01:59 +0000
changeset 1747 bccf2379b5dd
parent 1606 dc4ea2010dee
child 1837 8dd6160ff699
permissions -rw-r--r--
Faster implementation
     1 // -*- C++ -*- //
     2 
     3 #ifndef MAPSTORAGE_H
     4 #define MAPSTORAGE_H
     5 
     6 #include "all_include.h"
     7 #include "xymap.h"
     8 
     9 ///Class MapStorage is responsible for storing
    10 ///NodeMaps and EdgeMaps that can be shown later
    11 ///on GUI. Therefore maps can be added to it,
    12 ///and datas over the added maps can be queried.
    13 ///The maps will be stored in an std::map,
    14 ///referenced with their names. Unfortunately at
    15 ///the moment it works only with double type maps
    16 ///
    17 ///\todo too many things are public!!
    18 class MapStorage
    19 {
    20 public:
    21 
    22   Graph graph;
    23   XYMap<Graph::NodeMap<double> > coords;
    24 
    25   bool modified;
    26   std::string file_name;
    27 
    28   ///Stores double type NodeMaps
    29   std::map< std::string,Graph::NodeMap<double> * > nodemap_storage;
    30 
    31   ///Stores double type EdgeMaps
    32   std::map< std::string,Graph::EdgeMap<double> * > edgemap_storage;
    33 
    34   //Stores the default values for the different visualization node attributes
    35   std::vector<Graph::NodeMap<double> > default_nodemaps;
    36 
    37   //Stores the default values for the different visualization edge attributes
    38   std::vector<Graph::EdgeMap<double> > default_edgemaps;
    39 
    40   // Default values for the maps
    41   std::map< std::string, double > nodemap_default;
    42 
    43   // Default values for the maps
    44   std::map< std::string, double > edgemap_default;
    45 
    46 public:
    47   ///Constructor of MapStorage. Expects the Graph of
    48   ///which maps will be stored in it.
    49   ///Its all activity is initializing default values
    50   ///for different visualization attributes
    51   ///
    52   ///\param graph is the graph for which the maps are stored in this object.
    53   MapStorage();
    54 
    55   ~MapStorage();
    56 
    57   ///Adds given map to storage. A name and the map itself has to be provided.
    58   ///\param name is the name of map
    59   ///\nodemap is the pointer of the given nodemap
    60   ///\todo map should be given by reference!
    61   int addNodeMap(const std::string &,Graph::NodeMap<double> *, double);
    62 
    63   ///Adds given map to storage. A name and the map itself has to be provided.
    64   ///\param name is the name of map
    65   ///\edgemap is the pointer of the given edgemap
    66   ///\todo map should be given by reference!
    67   int addEdgeMap(const std::string &,Graph::EdgeMap<double> *, double);
    68 
    69   ///Returns how much nodemaps is stored in \ref MapStorage
    70   int numOfNodeMaps() {return nodemap_storage.size();};
    71 
    72   ///Returns how much edgemaps is stored in \ref MapStorage
    73   int numOfEdgeMaps() {return edgemap_storage.size();};
    74 
    75   ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
    76   ///\param name is the name of map of which maximum is searched
    77   double maxOfNodeMap(const std::string &);
    78 
    79   ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
    80   ///\param name is the name of map of which maximum is searched
    81   double maxOfEdgeMap(const std::string &);
    82 
    83   ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
    84   ///\param name is the name of map of which minimum is searched
    85   double minOfNodeMap(const std::string &);
    86 
    87   ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
    88   ///\param name is the name of map of which minimum is searched
    89   double minOfEdgeMap(const std::string &);
    90 
    91   ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
    92   std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
    93 
    94   ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
    95   std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
    96 
    97   ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
    98   std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
    99 
   100   ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
   101   std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
   102 
   103   int readFromFile(const std::string &);
   104   void writeToFile(const std::string &);
   105 
   106   void clear();
   107 };
   108 
   109 #endif //MAPSTORAGE_H