DataSetsManager.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/gdal/DataSetsManager.h
22 
23  \brief GDAL data set manager.
24  */
25 
26 #ifndef __TERRALIB_DATAACCES_GDAL_INTERNAL_DATASETSMANAGER_H
27 #define __TERRALIB_DATAACCES_GDAL_INTERNAL_DATASETSMANAGER_H
28 
29 #include "Config.h"
30 #include "../common/Singleton.h"
31 
32 #include <map>
33 #include <string>
34 
35 #include <memory>
36 #include <mutex>
37 
38 namespace te
39 {
40  namespace gdal
41  {
42  class DataSet;
43 
44  /*!
45  \class DataSetsManager
46 
47  \brief GDAL data set manager.
48  */
49  class TEGDALEXPORT DataSetsManager : public te::common::Singleton< te::gdal::DataSetsManager >
50  {
52 
53  public :
54 
55  /*! \enum Info regarding the uri access (bit field). */
57  {
58  MultipleAccessType = 0, /*!< Allows multiple concurrent connections to the uri. */
59  SingleAccessType = 1 /*!< Allows just one single connection to the uri. */
60  };
61 
62  /*!
63  \brief Try to increment the use counter for the given raster URI.
64  \param uri RasterURI.
65  \param aType Access type.
66  \return true if OK, false if the increment could not be done.
67  */
68  bool incrementUseCounter( const std::string& uri, const AccessType aType );
69 
70  /*!
71  \brief Decrement the use counter for the given raster URI.
72  \param uri RasterURI.
73  */
74  void decrementUseCounter( const std::string& uri );
75 
76 
77  protected :
78 
79  typedef std::map< std::string, std::pair< AccessType, unsigned long int > > UrisInfoT;
80 
82 
84 
85  mutable UrisInfoT m_openURIS; //!< Current open URIs.
86 
87  mutable std::mutex m_mutex; //!< Internal thread sync mutex.
88  };
89  } // end namespace gdal
90 } // end namespace te
91 
92 #endif // __TERRALIB_DATAACCES_GDAL_INTERNAL_DATASETSMANAGER_H
Template support for singleton pattern.
Definition: Singleton.h:101
A GDAL data set gives access to a raster file.
Definition: DataSet.h:51
GDAL data set manager.
UrisInfoT m_openURIS
Current open URIs.
void decrementUseCounter(const std::string &uri)
Decrement the use counter for the given raster URI.
std::mutex m_mutex
Internal thread sync mutex.
bool incrementUseCounter(const std::string &uri, const AccessType aType)
Try to increment the use counter for the given raster URI.
std::map< std::string, std::pair< AccessType, unsigned long int > > UrisInfoT
TerraLib.
#define TEGDALEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:67
Proxy configuration file for TerraView (see terraview_config.h).