GDAL
|
00001 /****************************************************************************** 00002 * $Id: ogrmutexeddatasource.h 28601 2015-03-03 11:06:40Z rouault $ 00003 * 00004 * Project: OpenGIS Simple Features Reference Implementation 00005 * Purpose: Defines OGRLMutexedDataSource class 00006 * Author: Even Rouault, even dot rouault at mines dash paris dot org 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 2013, Even Rouault <even dot rouault at mines-paris dot org> 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining a 00012 * copy of this software and associated documentation files (the "Software"), 00013 * to deal in the Software without restriction, including without limitation 00014 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00015 * and/or sell copies of the Software, and to permit persons to whom the 00016 * Software is furnished to do so, subject to the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be included 00019 * in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00022 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00023 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00024 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00025 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00026 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00027 * DEALINGS IN THE SOFTWARE. 00028 ****************************************************************************/ 00029 00030 #ifndef _OGRMUTEXEDDATASOURCELAYER_H_INCLUDED 00031 #define _OGRMUTEXEDDATASOURCELAYER_H_INCLUDED 00032 00033 #include "ogrsf_frmts.h" 00034 #include "cpl_multiproc.h" 00035 #include "ogrmutexedlayer.h" 00036 #include <map> 00037 00045 class CPL_DLL OGRMutexedDataSource : public OGRDataSource 00046 { 00047 protected: 00048 OGRDataSource *m_poBaseDataSource; 00049 int m_bHasOwnership; 00050 CPLMutex *m_hGlobalMutex; 00051 int m_bWrapLayersInMutexedLayer; 00052 std::map<OGRLayer*, OGRMutexedLayer* > m_oMapLayers; 00053 std::map<OGRMutexedLayer*, OGRLayer* > m_oReverseMapLayers; 00054 00055 OGRLayer* WrapLayerIfNecessary(OGRLayer* poLayer); 00056 00057 public: 00058 00059 /* The construction of the object isn't protected by the mutex */ 00060 OGRMutexedDataSource(OGRDataSource* poBaseDataSource, 00061 int bTakeOwnership, 00062 CPLMutex* hMutexIn, 00063 int bWrapLayersInMutexedLayer); 00064 00065 /* The destruction of the object isn't protected by the mutex */ 00066 virtual ~OGRMutexedDataSource(); 00067 00068 OGRDataSource* GetBaseDataSource() { return m_poBaseDataSource; } 00069 00070 virtual const char *GetName(); 00071 00072 virtual int GetLayerCount() ; 00073 virtual OGRLayer *GetLayer(int); 00074 virtual OGRLayer *GetLayerByName(const char *); 00075 virtual OGRErr DeleteLayer(int); 00076 00077 virtual int TestCapability( const char * ); 00078 00079 virtual OGRLayer *ICreateLayer( const char *pszName, 00080 OGRSpatialReference *poSpatialRef = NULL, 00081 OGRwkbGeometryType eGType = wkbUnknown, 00082 char ** papszOptions = NULL ); 00083 virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer, 00084 const char *pszNewName, 00085 char **papszOptions = NULL ); 00086 00087 virtual OGRStyleTable *GetStyleTable(); 00088 virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable ); 00089 00090 virtual void SetStyleTable(OGRStyleTable *poStyleTable); 00091 00092 virtual OGRLayer * ExecuteSQL( const char *pszStatement, 00093 OGRGeometry *poSpatialFilter, 00094 const char *pszDialect ); 00095 virtual void ReleaseResultSet( OGRLayer * poResultsSet ); 00096 00097 virtual void FlushCache(); 00098 00099 virtual OGRErr StartTransaction(int bForce=FALSE); 00100 virtual OGRErr CommitTransaction(); 00101 virtual OGRErr RollbackTransaction(); 00102 00103 virtual char **GetMetadata( const char * pszDomain = "" ); 00104 virtual CPLErr SetMetadata( char ** papszMetadata, 00105 const char * pszDomain = "" ); 00106 virtual const char *GetMetadataItem( const char * pszName, 00107 const char * pszDomain = "" ); 00108 virtual CPLErr SetMetadataItem( const char * pszName, 00109 const char * pszValue, 00110 const char * pszDomain = "" ); 00111 }; 00112 00113 #endif // _OGRMUTEXEDDATASOURCELAYER_H_INCLUDED