COIN-OR::LEMON - Graph Library

source: glemon-0.x/mapstorage.h @ 53:e73d7540bd24

gui
Last change on this file since 53:e73d7540bd24 was 53:e73d7540bd24, checked in by Akos Ladanyi, 19 years ago

added support for saving files

File size: 4.2 KB
Line 
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!!
18class MapStorage
19{
20public:
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
40public:
41  ///Constructor of MapStorage. Expects the Graph of
42  ///which maps will be stored in it.
43  ///Its all activity is initializing default values
44  ///for different visualization attributes
45  ///
46  ///\param graph is the graph for which the maps are stored in this object.
47  MapStorage();
48
49  ~MapStorage();
50
51  ///Adds given map to storage. A name and the map itself has to be provided.
52  ///\param name is the name of map
53  ///\nodemap is the pointer of the given nodemap
54  ///\todo map should be given by reference!
55  int addNodeMap(const std::string &,Graph::NodeMap<double> *);
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  ///\edgemap is the pointer of the given edgemap
60  ///\todo map should be given by reference!
61  int addEdgeMap(const std::string &,Graph::EdgeMap<double> *);
62
63  ///Returns how much nodemaps is stored in \ref MapStorage
64  int numOfNodeMaps() {return nodemap_storage.size();};
65
66  ///Returns how much edgemaps is stored in \ref MapStorage
67  int numOfEdgeMaps() {return edgemap_storage.size();};
68
69  ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
70  ///\param name is the name of map of which maximum is searched
71  double maxOfNodeMap(const std::string &);
72
73  ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
74  ///\param name is the name of map of which maximum is searched
75  double maxOfEdgeMap(const std::string &);
76
77  ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
78  ///\param name is the name of map of which minimum is searched
79  double minOfNodeMap(const std::string &);
80
81  ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
82  ///\param name is the name of map of which minimum is searched
83  double minOfEdgeMap(const std::string &);
84
85  ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
86  std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
87
88  ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
89  std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
90
91  ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
92  std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
93
94  ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
95  std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
96
97  ///This function sets a default base value for the newly created node
98  void initMapsForNode(NodeIt);
99
100  ///This function sets a default base value for the newly created node
101  void initMapsForEdge(Graph::Edge);
102
103  void readFromFile(const std::string &);
104  void writeToFile(const std::string &);
105
106  void clear();
107};
108
109#endif //MAPSTORAGE_H
Note: See TracBrowser for help on using the repository browser.