src/terralib/postgis/Plugin.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled
5  applications.
6 
7  TerraLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License,
10  or (at your option) any later version.
11 
12  TerraLib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with TerraLib. See COPYING. If not, write to
19  TerraLib Team at <terralib-team@terralib.org>.
20  */
21 
22 /*!
23  \file terralib/postgis/Plugin.cpp
24 
25  \brief Plugin interface for dynamic loading of Postgis Driver for TerraLib.
26 */
27 
28 // TerraLib
29 #include "../core/logger/Logger.h"
30 #include "../core/plugin/CppPlugin.h"
31 #include "../core/translator/Translator.h"
32 #include "../core/utils/Platform.h"
33 #include "../dataaccess/datasource/DataSourceCapabilities.h"
34 #include "../dataaccess/datasource/DataSourceFactory.h"
35 #include "../dataaccess/datasource/DataSourceManager.h"
36 #include "../dataaccess/query/BinaryOpEncoder.h"
37 #include "../dataaccess/query/FunctionEncoder.h"
38 #include "../dataaccess/query/SQLDialect.h"
39 #include "../dataaccess/query/SQLFunctionEncoder.h"
40 #include "../dataaccess/query/TemplateEncoder.h"
41 #include "../dataaccess/query/UnaryOpEncoder.h"
42 #include "../dataaccess/serialization/xml/Serializer.h"
43 #include "DataSource.h"
44 #include "DataSourceFactory.h"
45 #include "Globals.h"
46 
47 // Boost
48 #include <boost/filesystem.hpp>
49 namespace te
50 {
51  namespace pgis
52  {
54 
56  {
57  if(m_initialized)
58  return;
59 
60  // Register the data source factory
62 
63  // retrieve the Capabilities
64  std::string capabilitiesFile = te::core::FindInTerraLibPath(
65  "share/terralib/plugins/postgis-capabilities.xml");
66 
69 
70  te::serialize::xml::Read(capabilitiesFile,
73 
74  TE_LOG_INFO(TE_TR("TerraLib PostGIS driver support initialized!"));
75 
76  m_initialized = true;
77  }
78 
80  {
81  if(!m_initialized)
82  return;
83 
84  // Unregister the PostGIS factory support.
86 
87  // Free the PostGIS registered drivers
90 
91  TE_LOG_INFO(TE_TR("TerraLib PostGIS driver shutdown!"));
92 
93  m_initialized = false;
94  }
95 
96  TERRALIB_CPP_PLUGIN_END(te::pgis::Plugin)
97  }
98 }
#define TERRALIB_CPP_PLUGIN_END(plugin_class_name)
te::da::DataSource * Build(const te::core::URI &uri)
static te::da::DataSourceCapabilities * sm_capabilities
The query dialect supported by PostGIS driver.
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:55
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
TEDATAACCESSEXPORT void Read(const std::string &dialectFileName, te::da::DataSourceCapabilities &capabilities, te::da::SQLDialect &dialect)
static void remove(const std::string &dsType)
it finalizes the GDAL factory support.
static te::da::SQLDialect * sm_queryDialect
The query dialect supported by PostGIS driver.
#define PGIS_DRIVER_IDENTIFIER
The PostGIS driver identifier string.
TE_LOG_INFO(TE_TR("TerraLib PostGIS driver shutdown!"))
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
TERRALIB_CPP_PLUGIN_BEGIN(Plugin) TERRALIB_CPP_PLUGIN_STARTUP
URI C++ Library.
Definition: Attributes.h:37
#define TERRALIB_CPP_PLUGIN_STARTUP
A factory for data sources.
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
An static class with global definitions.
static void add(const std::string &dsType, FactoryFnctType f)
Implementation of the data source for the PostGIS driver.