CreateDataSourceAndUpdateManager.cpp
Go to the documentation of this file.
1 // TerraLib
2 #include <terralib/dataaccess.h>
3 
4 // Examples
5 #include "STExamples.h"
6 
7 // Boost
8 #include <boost/uuid/random_generator.hpp>
9 #include <boost/uuid/uuid_io.hpp>
10 #include <boost/filesystem.hpp>
11 
12 // STL
13 #include <iostream>
14 
16 {
17  try
18  {
19  //Generates a randon id to the data source
20  boost::uuids::basic_random_generator<boost::mt19937> gen;
21  boost::uuids::uuid u = gen();
22  std::string id = boost::uuids::to_string(u);
23  dsinfo.setId(id);
24 
25  //Create the data source and put it into the manager
26  te::da::DataSourceManager::getInstance().open(dsinfo.getId(), dsinfo.getType(), dsinfo.getConnInfo());
27 
28  }
29  catch(const te::common::Exception& e)
30  {
31  std::cout << std::endl << "Failed to create a new data source and put it into the manager: " << e.what() << std::endl;
32  }
33  catch(...)
34  {
35  std::cout << std::endl << "Failed to create a new data source and put it into the manager: unknow exception!" << std::endl;
36  }
37 }
38 
virtual const char * what() const
It outputs the exception message.
Examples on how to load/manipulate st types.
void CreateDataSourceAndUpdateManager(te::da::DataSourceInfo &dsinfo)
It creates a new DataSource and put it into the DataSource manager, using a random id...
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
const te::core::URI & getConnInfo() const
void setId(const std::string &id)
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
const std::string & getId() const
const std::string & getType() const
A class that represents a data source component.
This file contains include headers for the Data Access module of TerraLib.