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 da
45  {
46  class DataSource;
47 
48  /*!
49  \class DataSourceFactory
50 
51  \brief A factory for data sources.
52 
53  \ingroup dataaccess
54 
55  \sa DataSource
56  */
58  {
59  public:
60 
61  typedef boost::function<DataSource* ()> FactoryFnctType;
62 
63  static std::auto_ptr<DataSource> make(const std::string& dsType);
64 
65  static void add(const std::string& dsType, FactoryFnctType f);
66 
67  static void remove(const std::string& dsType);
68 
69  static bool find(const std::string& dsType);
70 
71  private:
72 
73  static std::map<std::string, FactoryFnctType> sm_factories;
74  };
75 
76  } // end namespace da
77 } // end namespace te
78 
79 #endif // __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCEFACTORY_H
static std::map< std::string, FactoryFnctType > sm_factories
boost::function< DataSource *()> FactoryFnctType
URI C++ Library.
#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.