examples/ado/main.cpp
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 main.cpp
22 
23  \brief An example of using the TerraLib ADO Driver.
24  */
25 
26 // TerraLib
28 #include <terralib/core/plugin.h>
33 
34 
35 // Example
36 #include "ADOExamples.h"
37 
38 // STL
39 #include <cassert>
40 #include <cstdlib>
41 #include <exception>
42 #include <iostream>
43 
44 int main(int /*argc*/, char** /*argv*/)
45 {
46  try
47  {
48  // Initialize Terralib support
50 
51  LoadModules();
52 
53  std::unique_ptr<te::da::DataSource> ds = GetADOConnection();
54 
55  // Show the information about datasets stored in the data source catalog
56  PrintCatalog(ds.get());
57 
58  // Retrieve and then print the datasets stored in the data source
59  PrintDataSets(ds.get());
60 
61  // Copying data from a shapefile
62  CopyFromShapeFile(ds.get());
63  }
64  catch(const std::exception& e)
65  {
66  std::cout << std::endl << "An exception has occurred: " << e.what() << std::endl;
67 
68  return EXIT_FAILURE;
69  }
70  catch(...)
71  {
72  std::cout << std::endl << "An unexpected exception has occurred!" << std::endl;
73 
74  return EXIT_FAILURE;
75  }
76 
78 
80 
81  return EXIT_SUCCESS;
82 }
void PrintCatalog(te::da::DataSource *ds)
This example will print to the standard output all the information about the datasets stored in a dat...
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...
Include files for Core Plugin Library.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Examples that show how to access/manipulate an ADO data source.
void PrintDataSets(te::da::DataSource *ds)
It prints datasets in a given data source.
static te::dt::Date ds(2010, 01, 01)
void CopyFromShapeFile(te::da::DataSource *ds)
It copies a shapefile to the given datasource.
Definition: CopyDataSet.cpp:81
static PluginManager & instance()
Access the singleton.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
A factory for data sources.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void initialize()
It initializes the TerraLib Platform.
int main(int, char **)
void clear()
Stop and unload all plugins, then clear the internal list of plugins.
std::unique_ptr< te::da::DataSource > GetADOConnection()
void LoadModules()
Load terralib modules.