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