27 #include "../../dataaccess/datasource/DataSource.h"
28 #include "../../dataaccess/datasource/DataSourceFactory.h"
29 #include "../cache/AbstractCachePolicyFactory.h"
30 #include "../drivers/database/DatabaseGraphMetadata.h"
31 #include "../loader/AbstractGraphLoaderStrategyFactory.h"
32 #include "../Globals.h"
33 #include "../Exception.h"
49 params.push_back(std::pair<std::string, std::string>(
"GRAPH_DATA_SOURCE_TYPE",
""));
50 params.push_back(std::pair<std::string, std::string>(
"GRAPH_ID",
""));
51 params.push_back(std::pair<std::string, std::string>(
"GRAPH_NAME",
""));
52 params.push_back(std::pair<std::string, std::string>(
"GRAPH_DESCRIPTION",
""));
53 params.push_back(std::pair<std::string, std::string>(
"GRAPH_STORAGE_MODE",
""));
54 params.push_back(std::pair<std::string, std::string>(
"GRAPH_STRATEGY_LOADER",
""));
55 params.push_back(std::pair<std::string, std::string>(
"GRAPH_CACHE_POLICY",
""));
77 std::map<std::string, std::string>::const_iterator it;
78 std::map<std::string, std::string>::const_iterator itend = gInfo.end();
81 it = gInfo.find(
"GRAPH_DATA_SOURCE_TYPE");
83 std::auto_ptr<te::da::DataSource> dsPtr;
88 dsPtr->setConnectionInfo(dsInfo);
97 it = gInfo.find(
"GRAPH_ID");
102 int id = atoi(it->second.c_str());
106 catch(
const std::exception& e)
108 std::string errorMessage =
TR_GRAPH(
"Error saving graph metadata: ");
109 errorMessage += e.what();
111 throw Exception(errorMessage);
121 it = gInfo.find(
"GRAPH_CACHE_POLICY");
129 it = gInfo.find(
"GRAPH_STRATEGY_LOADER");
143 std::map<std::string, std::string>::const_iterator it;
144 std::map<std::string, std::string>::const_iterator itend = gInfo.end();
147 it = gInfo.find(
"GRAPH_DATA_SOURCE_TYPE");
149 std::auto_ptr<te::da::DataSource> dsPtr;
154 dsPtr->setConnectionInfo(dsInfo);
163 it = gInfo.find(
"GRAPH_NAME");
166 gMetadata->
setName(it->second);
169 it = gInfo.find(
"GRAPH_DESCRIPTION");
175 it = gInfo.find(
"GRAPH_STORAGE_MODE");
192 catch(
const std::exception& e)
194 std::string errorMessage =
TR_GRAPH(
"Error saving graph metadata: ");
195 errorMessage += e.what();
197 throw Exception(errorMessage);
202 it = gInfo.find(
"GRAPH_CACHE_POLICY");
210 it = gInfo.find(
"GRAPH_STRATEGY_LOADER");
This is the abstract factory for Graphs.
static AbstractGraphLoaderStrategy * make()
It creates and returns default graph loader strategy.
Abstract class used to define the main functions of graph struct. All graph implementations must used...
This class define the main functions necessary to save and load the graph data and metadata informati...
static void initialize()
It initializes the factory: the singleton instance will be registered in the abstract factory ...
te::graph::AbstractGraph * iOpen(const std::map< std::string, std::string > &dsInfo, const std::map< std::string, std::string > &gInfo)
This method must be re-implemented by subclasses in order to have a finner control for the graph obje...
te::graph::AbstractGraph * create(const std::map< std::string, std::string > &dsInfo, const std::map< std::string, std::string > &gInfo)
This method must be implemented by subclasses (graph types).
void setStorageMode(GraphStorageMode value)
Set the graph storage mode (defined in Enums file)
An static class with global definitions for the TerraLib Graph Module.
#define TE_GRAPH_STORAGE_MODE_BY_VERTEX
This definition is used to set the vertex storage mode.
static std::auto_ptr< DataSource > make(const std::string &dsType)
#define TR_GRAPH(message)
It marks a string in order to get translated. This is a special mark used in the Graph module of Terr...
This is a implementation of a Bidirectional Graph. By convention a bidirectional graph provides acces...
void load(int id)
Function used to load the graph information given a graph id.
BidirectionalGraphFactory()
Constructor.
static AbstractCachePolicy * make()
It creates and returns default cache policy.
void setName(std::string name)
Set the graph name.
static void finalize()
It finalizes the factory: the singleton instance will be destroyed and will be unregistered from the ...
#define TE_GRAPH_STORAGE_MODE_BY_EDGE
This definition is used to set the edge storage mode.
void getCreationalParameters(std::vector< std::pair< std::string, std::string > > ¶ms) const
It returns the list of parameters accepted as graph info.
This is the main graph implementation, that uses a cache policy anda graph loader to get all elements...
This is the concrete factory for the bidirectional Graph type.
static const std::string sm_factoryGraphTypeBidirectionalGraph
Bidirectional Graph Factory Name.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
const std::string & getType() const
Returns the type (name) of this factory.
void setDescription(std::string desc)
Set the graph description.
This class is used to set the main functions of a cache policy.
static BidirectionalGraphFactory * sm_factory
Static instance used to register the factory.
This is a implementation of a Bidirectional Graph. By convention a bidirectional graph provides acces...
Class used to define the graph metadata informations over a SGBD source.
te::graph::AbstractGraph * build()
Builder Function used to create the class object.
void save()
Function used to save the graph information.