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