mapstorage.h
author ladanyi
Wed, 17 Aug 2005 12:35:43 +0000
branchgui
changeset 60 3e58623c588d
parent 31 66e85f44a66f
child 63 59768817442a
permissions -rw-r--r--
Toolbar has custom icons now. Works only when installed.
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@6
    40
public:
ladanyi@6
    41
  ///Constructor of MapStorage. Expects the Graph of
ladanyi@6
    42
  ///which maps will be stored in it.
ladanyi@6
    43
  ///Its all activity is initializing default values
ladanyi@6
    44
  ///for different visualization attributes
ladanyi@6
    45
  ///
ladanyi@6
    46
  ///\param graph is the graph for which the maps are stored in this object.
ladanyi@53
    47
  MapStorage();
ladanyi@53
    48
ladanyi@53
    49
  ~MapStorage();
ladanyi@6
    50
ladanyi@6
    51
  ///Adds given map to storage. A name and the map itself has to be provided.
ladanyi@6
    52
  ///\param name is the name of map
ladanyi@6
    53
  ///\nodemap is the pointer of the given nodemap
ladanyi@6
    54
  ///\todo map should be given by reference!
ladanyi@6
    55
  int addNodeMap(const std::string &,Graph::NodeMap<double> *);
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
  ///\edgemap is the pointer of the given edgemap
ladanyi@6
    60
  ///\todo map should be given by reference!
ladanyi@6
    61
  int addEdgeMap(const std::string &,Graph::EdgeMap<double> *);
ladanyi@6
    62
ladanyi@6
    63
  ///Returns how much nodemaps is stored in \ref MapStorage
ladanyi@6
    64
  int numOfNodeMaps() {return nodemap_storage.size();};
ladanyi@6
    65
ladanyi@6
    66
  ///Returns how much edgemaps is stored in \ref MapStorage
ladanyi@6
    67
  int numOfEdgeMaps() {return edgemap_storage.size();};
ladanyi@6
    68
ladanyi@6
    69
  ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
ladanyi@6
    70
  ///\param name is the name of map of which maximum is searched
ladanyi@6
    71
  double maxOfNodeMap(const std::string &);
ladanyi@6
    72
ladanyi@6
    73
  ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
ladanyi@6
    74
  ///\param name is the name of map of which maximum is searched
ladanyi@6
    75
  double maxOfEdgeMap(const std::string &);
ladanyi@6
    76
ladanyi@6
    77
  ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
ladanyi@6
    78
  ///\param name is the name of map of which minimum is searched
ladanyi@6
    79
  double minOfNodeMap(const std::string &);
ladanyi@6
    80
ladanyi@6
    81
  ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
ladanyi@6
    82
  ///\param name is the name of map of which minimum is searched
ladanyi@6
    83
  double minOfEdgeMap(const std::string &);
ladanyi@6
    84
ladanyi@6
    85
  ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
ladanyi@6
    86
  std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
ladanyi@6
    87
ladanyi@6
    88
  ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
ladanyi@6
    89
  std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
hegyi@26
    90
hegyi@31
    91
  ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
hegyi@31
    92
  std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
hegyi@31
    93
hegyi@31
    94
  ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
hegyi@31
    95
  std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
hegyi@31
    96
hegyi@26
    97
  ///This function sets a default base value for the newly created node
hegyi@30
    98
  void initMapsForNode(NodeIt);
hegyi@26
    99
hegyi@26
   100
  ///This function sets a default base value for the newly created node
hegyi@30
   101
  void initMapsForEdge(Graph::Edge);
ladanyi@53
   102
ladanyi@53
   103
  void 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