GDAL
ogrmutexeddatasource.h
1 /******************************************************************************
2  * $Id: ogrmutexeddatasource.h 36501 2016-11-25 14:09:24Z rouault $
3  *
4  * Project: OpenGIS Simple Features Reference Implementation
5  * Purpose: Defines OGRLMutexedDataSource class
6  * Author: Even Rouault, even dot rouault at mines dash paris dot org
7  *
8  ******************************************************************************
9  * Copyright (c) 2013, Even Rouault <even dot rouault at mines-paris dot org>
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
31 #define OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
32 
33 #ifndef DOXYGEN_SKIP
34 
35 #include "ogrsf_frmts.h"
36 #include "cpl_multiproc.h"
37 #include "ogrmutexedlayer.h"
38 #include <map>
39 
47 class CPL_DLL OGRMutexedDataSource : public OGRDataSource
48 {
49  protected:
50  OGRDataSource *m_poBaseDataSource;
51  int m_bHasOwnership;
52  CPLMutex *m_hGlobalMutex;
53  int m_bWrapLayersInMutexedLayer;
54  std::map<OGRLayer*, OGRMutexedLayer* > m_oMapLayers;
55  std::map<OGRMutexedLayer*, OGRLayer* > m_oReverseMapLayers;
56 
57  OGRLayer* WrapLayerIfNecessary(OGRLayer* poLayer);
58 
59  public:
60 
61  /* The construction of the object isn't protected by the mutex */
62  OGRMutexedDataSource(OGRDataSource* poBaseDataSource,
63  int bTakeOwnership,
64  CPLMutex* hMutexIn,
65  int bWrapLayersInMutexedLayer);
66 
67  /* The destruction of the object isn't protected by the mutex */
68  virtual ~OGRMutexedDataSource();
69 
70  OGRDataSource* GetBaseDataSource() { return m_poBaseDataSource; }
71 
72  virtual const char *GetName() override;
73 
74  virtual int GetLayerCount() override ;
75  virtual OGRLayer *GetLayer(int) override;
76  virtual OGRLayer *GetLayerByName(const char *) override;
77  virtual OGRErr DeleteLayer(int) override;
78 
79  virtual int TestCapability( const char * ) override;
80 
81  virtual OGRLayer *ICreateLayer( const char *pszName,
82  OGRSpatialReference *poSpatialRef = NULL,
84  char ** papszOptions = NULL ) override;
85  virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
86  const char *pszNewName,
87  char **papszOptions = NULL ) override;
88 
89  virtual OGRStyleTable *GetStyleTable() override;
90  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable ) override;
91 
92  virtual void SetStyleTable(OGRStyleTable *poStyleTable) override;
93 
94  virtual OGRLayer * ExecuteSQL( const char *pszStatement,
95  OGRGeometry *poSpatialFilter,
96  const char *pszDialect ) override;
97  virtual void ReleaseResultSet( OGRLayer * poResultsSet ) override;
98 
99  virtual void FlushCache() override;
100 
101  virtual OGRErr StartTransaction(int bForce=FALSE) override;
102  virtual OGRErr CommitTransaction() override;
103  virtual OGRErr RollbackTransaction() override;
104 
105  virtual char **GetMetadata( const char * pszDomain = "" ) override;
106  virtual CPLErr SetMetadata( char ** papszMetadata,
107  const char * pszDomain = "" ) override;
108  virtual const char *GetMetadataItem( const char * pszName,
109  const char * pszDomain = "" ) override;
110  virtual CPLErr SetMetadataItem( const char * pszName,
111  const char * pszValue,
112  const char * pszDomain = "" ) override;
113 };
114 
115 #endif /* #ifndef DOXYGEN_SKIP */
116 
117 #endif // OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
LEGACY class.
Definition: ogrsf_frmts.h:247
void virtual char ** GetMetadata(const char *pszDomain="") CPL_OVERRIDE
Fetch metadata.
Definition: gdaldataset.cpp:3465
virtual OGRErr DeleteLayer(int iLayer)
Delete the indicated layer from the datasource.
Definition: gdaldataset.cpp:4598
virtual OGRLayer * GetLayer(int iLayer)
Fetch a layer by index.
Definition: gdaldataset.cpp:6050
virtual void SetStyleTable(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition: gdaldataset.cpp:5992
virtual void FlushCache(void)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:430
virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) CPL_OVERRIDE
Set single metadata item.
virtual OGRErr CommitTransaction()
For datasources which support transactions, CommitTransaction commits a transaction.
Definition: gdaldataset.cpp:6579
unknown type, non-standard
Definition: ogr_core.h:303
virtual OGRLayer * CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions=NULL)
Duplicate an existing layer.
Definition: gdaldataset.cpp:4234
virtual void ReleaseResultSet(OGRLayer *poResultsSet)
Release results of ExecuteSQL().
Definition: gdaldataset.cpp:5924
virtual OGRStyleTable * GetStyleTable()
Returns dataset style table.
Definition: gdaldataset.cpp:5946
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:301
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain) CPL_OVERRIDE
Fetch single metadata item.
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:118
virtual OGRLayer * ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect)
Execute an SQL statement against the data store.
Definition: gdaldataset.cpp:5455
Classes related to registration of format support, and opening datasets.
virtual CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) CPL_OVERRIDE
Set metadata.
virtual OGRLayer * GetLayerByName(const char *)
Fetch a layer by name.
Definition: gdaldataset.cpp:4627
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:132
virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition: gdaldataset.cpp:5966
virtual OGRErr RollbackTransaction()
For datasources which support transactions, RollbackTransaction will roll back a datasource to its st...
Definition: gdaldataset.cpp:6631
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:68
This class represents a style table.
Definition: ogr_featurestyle.h:83
virtual int GetLayerCount()
Get the number of layers in this dataset.
Definition: gdaldataset.cpp:6027
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:274
virtual OGRLayer * ICreateLayer(const char *pszName, OGRSpatialReference *poSpatialRef=NULL, OGRwkbGeometryType eGType=wkbUnknown, char **papszOptions=NULL)
This method attempts to create a new layer on the dataset with the indicated name, coordinate system, geometry type.
Definition: gdaldataset.cpp:4193
virtual int TestCapability(const char *)
Test if capability is available.
Definition: gdaldataset.cpp:6384
virtual OGRErr StartTransaction(int bForce=FALSE)
For datasources which support transactions, StartTransaction creates a `transaction.
Definition: gdaldataset.cpp:6489
CPLErr
Error category.
Definition: cpl_error.h:52

Generated for GDAL by doxygen 1.8.8.