AbstractGraphFactory.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file AbstractGraphFactory.h
22 
23  \brief This is the abstract factory for Graphs.
24 */
25 
26 #ifndef __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPHFACTORY_H
27 #define __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPHFACTORY_H
28 
29 // TerraLib
30 #include "../../common/AbstractFactory.h"
31 #include "../graphs/Graph.h"
32 #include "../Config.h"
33 
34 
35 namespace te
36 {
37  namespace graph
38  {
39  //forward declarations
40  class AbstractCachePolicy;
41  class AbstractGraph;
42  class AbstractGraphLoaderStrategy;
43 
44  /*!
45  \class AbstractGraphFactory
46 
47  \brief This is the abstract factory for Graphs.
48 
49  \sa AbstractGraph
50  */
51  class TEGRAPHEXPORT AbstractGraphFactory : public te::common::AbstractFactory<AbstractGraph, std::string>
52  {
53  public:
54 
55  /*!
56  \brief It creates and returns an empty graph with default graph type.
57 
58  \return An empty graph.
59 
60  \note The caller will take the ownership of the returned pointer.
61  */
62  static AbstractGraph* make();
63 
64  /*!
65  \brief It creates an empty graph with the proper type.
66 
67  \param gType The name of the specific graph type to be used to create the graph.
68 
69  \return An empty graph.
70 
71  \note The caller will take the ownership of the returned pointer.
72  */
73  static AbstractGraph* make(const std::string& gType);
74 
75  /*!
76  \brief It creates a graph with the given parameters using the default graph type.
77 
78  \param dsInfo The necessary information to access the data source.
79  \param gInfo The necessary information to create the graph.
80 
81  \return A new graph.
82 
83  \note The caller will take the ownership of the returned pointer.
84 
85  */
86  static AbstractGraph* make(const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo);
87 
88  /*!
89  \brief It creates a graph with the given parameters using the default graph type.
90 
91  \param gType The name of the specific driver to create the raster.
92  \param dsInfo The necessary information to access the data source.
93  \param gInfo The necessary information to create the graph.
94 
95  \return A new graph.
96 
97  \note The caller will take the ownership of the returned pointer.
98 
99  */
100  static AbstractGraph* make(const std::string& gType, const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo);
101 
102  /*!
103  \brief It opens a graph with the given parameters and default graph type.
104 
105  \param dsInfo The necessary information to access the data source.
106  \param gInfo The necessary information to create the graph.
107 
108  \return The opened graph.
109 
110  \note The caller will take the ownership of the returned pointer.
111  */
112  static AbstractGraph* open(const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo);
113 
114  /*!
115  \brief It creates a graph with the given parameters.
116 
117  \param gType The name of the specific graph type to create the graph.
118  \param dsInfo The necessary information to access the data source.
119  \param gInfo The necessary information to create the graph.
120 
121  \return The opened graph.
122 
123  \note The caller will take the ownership of the returned pointer.
124  */
125  static AbstractGraph* open(const std::string& gType, const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo);
126 
127 
128  /*! \brief Destructor. */
130 
131  /*! \brief Returns the type (name) of this factory. */
132  virtual const std::string& getType() const = 0;
133 
134  /*! \brief It returns the list of parameters accepted as graph info. */
135  virtual void getCreationalParameters(std::vector< std::pair<std::string, std::string> >& params) const = 0;
136 
137  protected:
138 
139  /*!
140  \brief Constructor.
141 
142  \param factoryKey The key that identifies the factory.
143  */
144  AbstractGraphFactory(const std::string& factoryKey);
145 
146  /*!
147  \brief This method must be re-implemented by subclasses in order to have a finner control for the graph object instantiation.
148 
149  \param dsInfo The necessary information to access the data source.
150  \param gInfo The necessary information to create the graph.
151 
152  \return A graph.
153 
154  \note The caller will take the ownership of the returned pointer.
155  */
156  virtual AbstractGraph* iOpen(const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo) = 0;
157 
158  /*!
159  \brief This method must be implemented by subclasses (graph types).
160 
161  \param dsInfo The necessary information to access the data source.
162  \param gInfo The necessary information to create the graph.
163 
164  \return The new graph.
165 
166  \note The caller will take the ownership of the returned pointer.
167  */
168  virtual AbstractGraph* create(const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo) = 0;
169 
170  /*!
171  \brief This method is a auxiliar function used to get the metadata pointer
172 
173  \param dsInfo The necessary information to access the data source.
174  \param gInfo The necessary information to create the graph.
175 
176  \return The graph metadata pointer.
177 
178  \note The caller will take the ownership of the returned pointer.
179  */
180  static te::graph::GraphMetadata* getMetadata(const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo);
181 
182  /*!
183  \brief This method is a auxiliar function used to get the graph id
184 
185  \param gInfo The necessary information to create the graph.
186 
187  \return The graph id.
188 
189  */
190  static int getId(const std::map<std::string, std::string>& dsInfo, const std::map<std::string, std::string>& gInfo);
191 
192  /*!
193  \brief This method is a auxiliar function used to get the cache policy pointer
194 
195  \param gInfo The necessary information to create the graph.
196 
197  \return The graph cache policy pointer.
198 
199  \note The caller will take the ownership of the returned pointer.
200  */
201  static te::graph::AbstractCachePolicy* getCachePolicy(const std::map<std::string, std::string>& gInfo);
202 
203  /*!
204  \brief This method is a auxiliar function used to get the loader strategy pointer
205 
206  \param gInfo The necessary information to create the graph.
207  \param metadata The graph metadata pointer.
208 
209  \return The graph loader strategy pointer.
210 
211  \note The caller will take the ownership of the returned pointer.
212  */
213  static te::graph::AbstractGraphLoaderStrategy* getLoaderStrategy(const std::map<std::string, std::string>& gInfo, te::graph::GraphMetadata* metadata);
214 
215  static void setMetadataInformation(const std::map<std::string, std::string>& gInfo, te::graph::GraphMetadata* metadata);
216  };
217 
218  } // end namespace graph
219 } // end namespace te
220 
221 #endif // __TERRALIB_GRAPH_INTERNAL_ABSTRACTGRAPHFACTORY_H
This class defines the interface of abstract factories without initializing parameters.
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178
virtual ~AbstractGraphFactory()
Destructor.
This class is used to set the main functions of a cache policy.
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
URI C++ Library.
This class define the main functions necessary to save and load the graph data and metadata informati...
This is the abstract factory for Graphs.
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:56