DataSourceFactory.h
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 terralib/dataaccess/datasource/DataSourceFactory.h
22 
23  \brief A factory for data sources.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCEFACTORY_H
27 #define __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCEFACTORY_H
28 
29 // TerraLib
30 #include "../../common/Static.h"
31 #include "../Config.h"
32 #include "../Exception.h"
33 
34 // STL
35 #include <map>
36 #include <memory>
37 #include <string>
38 
39 // Boost
40 #include <boost/function.hpp>
41 
42 namespace te
43 {
44  namespace core { class URI; }
45 
46  namespace da
47  {
48  class DataSource;
49 
50  /*!
51  \class DataSourceFactory
52 
53  \brief A factory for data sources.
54 
55  \ingroup dataaccess
56 
57  \sa DataSource
58  */
60  {
61  public:
62 
63  typedef boost::function<DataSource* (const te::core::URI& uri)> FactoryFnctType;
64 
65  static std::unique_ptr<DataSource> make(const std::string& driver, const te::core::URI& connInfo);
66 
67  static std::unique_ptr<DataSource> make(const std::string& driver, const std::string& connInfo);
68 
69  static void add(const std::string& dsType, FactoryFnctType f);
70 
71  static void remove(const std::string& dsType);
72 
73  static bool find(const std::string& dsType);
74 
75  private:
76 
77  static std::map<std::string, FactoryFnctType> sm_factories;
78  };
79  } // end namespace da
80 } // end namespace te
81 
82 #endif // __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCEFACTORY_H
static std::map< std::string, FactoryFnctType > sm_factories
URI C++ Library.
boost::function< DataSource *(const te::core::URI &uri)> FactoryFnctType
A class for representing an Uniform Resource Identifier (URI).
Definition: URI.h:49
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97
A base type for static classes.
Definition: Static.h:43
A factory for data sources.