All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DataSource.h
Go to the documentation of this file.
1 /* Copyright (C) 2009-2013 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 terralib/terralib4/DataSource.h
22 
23  \brief Implements the DataSource class for the TerraLib 4.x Data Access Driver.
24 */
25 
26 #ifndef __TERRALIB_TERRALIB4_INTERNAL_DATASOURCE_H
27 #define __TERRALIB_TERRALIB4_INTERNAL_DATASOURCE_H
28 
29 // TerraLib
30 #include "../dataaccess/datasource/DataSource.h"
31 #include "../dataaccess/datasource/DataSourceCapabilities.h"
32 
33 class TeDatabase;
34 
35 namespace terralib4
36 {
38  {
39  public:
40 
41  DataSource();
42 
43  ~DataSource();
44 
45  std::string getType() const;
46 
47  const std::map<std::string, std::string>& getConnectionInfo() const;
48 
49  void setConnectionInfo(const std::map<std::string, std::string>& connInfo);
50 
51  std::auto_ptr<te::da::DataSourceTransactor> getTransactor();
52 
53  void open();
54 
55  void close();
56 
57  bool isOpened() const;
58 
59  bool isValid() const;
60 
62 
63  const te::da::SQLDialect* getDialect() const;
64 
65  TeDatabase* getTerralib4Db();
66 
67  protected:
68 
69  void create(const std::map<std::string, std::string>& dsInfo);
70 
71  void drop(const std::map<std::string, std::string>& dsInfo);
72 
73  bool exists(const std::map<std::string, std::string>& dsInfo);
74 
75  std::vector<std::string> getDataSourceNames(const std::map<std::string, std::string>& dsInfo);
76 
77  std::vector<std::string> getEncodings(const std::map<std::string, std::string>& dsInfo);
78 
79  private:
80 
81  TeDatabase* m_db;
82  std::map<std::string, std::string> m_dbInfo;
83 
86  };
87 
88 }
89 
90 #endif // __TERRALIB_TERRALIB4_INTERNAL_DATASOURCE_H
std::auto_ptr< te::da::DataSourceTransactor > getTransactor()
It returns an object that can execute transactions in the context of a data source.
Definition: DataSource.cpp:64
bool isValid() const
It checks if the data source is valid (available for using).
Definition: DataSource.cpp:121
void create(const std::map< std::string, std::string > &dsInfo)
It creates a new data source.
Definition: DataSource.cpp:136
~DataSource()
Virtual destructor.
Definition: DataSource.cpp:45
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
Definition: DataSource.cpp:131
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
Definition: DataSource.cpp:49
const std::map< std::string, std::string > & getConnectionInfo() const
It returns the set of parameters used to set up the access channel to the underlying repository...
Definition: DataSource.cpp:54
std::map< std::string, std::string > m_dbInfo
Definition: DataSource.h:82
TeDatabase * getTerralib4Db()
Definition: DataSource.cpp:179
static te::da::SQLDialect * sm_dialect
Definition: DataSource.h:85
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
bool exists(const std::map< std::string, std::string > &dsInfo)
Check the existence of a data source in a driver.
Definition: DataSource.cpp:146
void drop(const std::map< std::string, std::string > &dsInfo)
It removes the data source with the connection information from a driver.
Definition: DataSource.cpp:141
std::vector< std::string > getEncodings(const std::map< std::string, std::string > &dsInfo)
It gets the encodings for the data source.
Definition: DataSource.cpp:166
void setConnectionInfo(const std::map< std::string, std::string > &connInfo)
It sets the connection information to be used when connecting to the data source. ...
Definition: DataSource.cpp:59
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:55
static te::da::DataSourceCapabilities sm_capabilities
Definition: DataSource.h:84
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
Definition: DataSource.cpp:116
void open()
It opens the data source and makes it ready for using.
Definition: DataSource.cpp:70
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:116
TeDatabase * m_db
Definition: DataSource.h:81
std::vector< std::string > getDataSourceNames(const std::map< std::string, std::string > &dsInfo)
It gets the data source names available in a driver.
Definition: DataSource.cpp:153
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
Definition: DataSource.cpp:126
void close()
It closes the data source and clears all the resources used by its internal communication channel...
Definition: DataSource.cpp:110