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