GDAL

ogrmutexeddatasource.h
1/******************************************************************************
2 * $Id$
3 *
4 * Project: OpenGIS Simple Features Reference Implementation
5 * Purpose: Defines OGRLMutexedDataSource class
6 * Author: Even Rouault, even dot rouault at spatialys.com
7 *
8 ******************************************************************************
9 * Copyright (c) 2013, Even Rouault <even dot rouault at spatialys.com>
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 CPL_DISALLOW_COPY_ASSIGN(OGRMutexedDataSource)
50
51 protected:
52 OGRDataSource *m_poBaseDataSource;
53 int m_bHasOwnership;
54 CPLMutex *m_hGlobalMutex;
55 int m_bWrapLayersInMutexedLayer;
56 std::map<OGRLayer *, OGRMutexedLayer *> m_oMapLayers{};
57 std::map<OGRMutexedLayer *, OGRLayer *> m_oReverseMapLayers{};
58
59 OGRLayer *WrapLayerIfNecessary(OGRLayer *poLayer);
60
61 public:
62 /* The construction of the object isn't protected by the mutex */
63 OGRMutexedDataSource(OGRDataSource *poBaseDataSource, int bTakeOwnership,
64 CPLMutex *hMutexIn, int bWrapLayersInMutexedLayer);
65
66 /* The destruction of the object isn't protected by the mutex */
67 virtual ~OGRMutexedDataSource() override;
68
69 OGRDataSource *GetBaseDataSource()
70 {
71 return m_poBaseDataSource;
72 }
73
74 virtual const char *GetName() override;
75
76 virtual int GetLayerCount() override;
77 virtual OGRLayer *GetLayer(int) override;
78 virtual OGRLayer *GetLayerByName(const char *) override;
79 virtual OGRErr DeleteLayer(int) override;
80 virtual bool IsLayerPrivate(int iLayer) const override;
81
82 virtual int TestCapability(const char *) override;
83
84 virtual OGRLayer *ICreateLayer(const char *pszName,
85 const OGRGeomFieldDefn *poGeomFieldDefn,
86 CSLConstList papszOptions) override;
87 virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName,
88 char **papszOptions = nullptr) override;
89
90 virtual OGRStyleTable *GetStyleTable() override;
91 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override;
92
93 virtual void SetStyleTable(OGRStyleTable *poStyleTable) override;
94
95 virtual OGRLayer *ExecuteSQL(const char *pszStatement,
96 OGRGeometry *poSpatialFilter,
97 const char *pszDialect) override;
98 virtual void ReleaseResultSet(OGRLayer *poResultsSet) override;
99
100 virtual CPLErr FlushCache(bool bAtClosing) override;
101
102 virtual OGRErr StartTransaction(int bForce = FALSE) override;
103 virtual OGRErr CommitTransaction() override;
104 virtual OGRErr RollbackTransaction() override;
105
106 virtual char **GetMetadata(const char *pszDomain = "") override;
107 virtual CPLErr SetMetadata(char **papszMetadata,
108 const char *pszDomain = "") override;
109 virtual const char *GetMetadataItem(const char *pszName,
110 const char *pszDomain = "") override;
111 virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
112 const char *pszDomain = "") override;
113
114 virtual std::vector<std::string>
115 GetFieldDomainNames(CSLConstList papszOptions = nullptr) const override;
116 virtual const OGRFieldDomain *
117 GetFieldDomain(const std::string &name) const override;
118
119 virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
120 std::string &failureReason) override;
121 virtual bool DeleteFieldDomain(const std::string &name,
122 std::string &failureReason) override;
123 virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
124 std::string &failureReason) override;
125
126 std::vector<std::string>
127 GetRelationshipNames(CSLConstList papszOptions = nullptr) const override;
128
129 const GDALRelationship *
130 GetRelationship(const std::string &name) const override;
131
132 virtual std::shared_ptr<GDALGroup> GetRootGroup() const override;
133};
134
135#endif /* #ifndef DOXYGEN_SKIP */
136
137#endif // OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
GDALDataset::IsLayerPrivate
virtual bool IsLayerPrivate(int iLayer) const
Returns true if the layer at the specified index is deemed a private or system table,...
Definition gdaldataset.cpp:7519
GDALDataset::SetStyleTableDirectly
virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition gdaldataset.cpp:7404
GDALDataset::UpdateFieldDomain
virtual bool UpdateFieldDomain(std::unique_ptr< OGRFieldDomain > &&domain, std::string &failureReason)
Updates an existing field domain by replacing its definition.
Definition gdaldataset.cpp:9287
GDALDataset::GetLayerCount
virtual int GetLayerCount()
Get the number of layers in this dataset.
Definition gdaldataset.cpp:7466
GDALDataset::GetStyleTable
virtual OGRStyleTable * GetStyleTable()
Returns dataset style table.
Definition gdaldataset.cpp:7381
GDALDataset::StartTransaction
virtual OGRErr StartTransaction(int bForce=FALSE)
For datasources which support transactions, StartTransaction creates a `transaction.
Definition gdaldataset.cpp:7963
GDALDataset::GetRelationship
virtual const GDALRelationship * GetRelationship(const std::string &name) const
Get a relationship from its name.
Definition gdaldataset.cpp:9399
GDALDataset::GetLayerByName
virtual OGRLayer * GetLayerByName(const char *)
Fetch a layer by name.
Definition gdaldataset.cpp:6007
GDALDataset::SetStyleTable
virtual void SetStyleTable(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition gdaldataset.cpp:7430
GDALDataset::ExecuteSQL
virtual OGRLayer * ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect)
Execute an SQL statement against the data store.
Definition gdaldataset.cpp:6766
GDALDataset::GetFieldDomain
virtual const OGRFieldDomain * GetFieldDomain(const std::string &name) const
Get a field domain from its name.
Definition gdaldataset.cpp:9082
GDALDataset::RollbackTransaction
virtual OGRErr RollbackTransaction()
For datasources which support transactions, RollbackTransaction will roll back a datasource to its st...
Definition gdaldataset.cpp:8108
GDALDataset::ICreateLayer
virtual OGRLayer * ICreateLayer(const char *pszName, const OGRGeomFieldDefn *poGeomFieldDefn, CSLConstList papszOptions)
This method attempts to create a new layer on the dataset with the indicated name,...
Definition gdaldataset.cpp:5597
GDALDataset::SetMetadata
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALDataset::FlushCache
virtual CPLErr FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition gdaldataset.cpp:558
GDALDataset::GetLayer
virtual OGRLayer * GetLayer(int iLayer)
Fetch a layer by index.
Definition gdaldataset.cpp:7496
GDALDataset::ReleaseResultSet
virtual void ReleaseResultSet(OGRLayer *poResultsSet)
Release results of ExecuteSQL().
Definition gdaldataset.cpp:7359
GDALDataset::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
GDALDataset::AddFieldDomain
virtual bool AddFieldDomain(std::unique_ptr< OGRFieldDomain > &&domain, std::string &failureReason)
Add a field domain to the dataset.
Definition gdaldataset.cpp:9138
GDALDataset::GetMetadata
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition gdaldataset.cpp:4601
GDALDataset::GetRootGroup
virtual std::shared_ptr< GDALGroup > GetRootGroup() const
Return the root GDALGroup of this dataset.
Definition gdaldataset.cpp:8948
GDALDataset::GetRelationshipNames
virtual std::vector< std::string > GetRelationshipNames(CSLConstList papszOptions=nullptr) const
Returns a list of the names of all relationships stored in the dataset.
Definition gdaldataset.cpp:9355
GDALDataset::DeleteLayer
virtual OGRErr DeleteLayer(int iLayer)
Delete the indicated layer from the datasource.
Definition gdaldataset.cpp:5978
GDALDataset::CommitTransaction
virtual OGRErr CommitTransaction()
For datasources which support transactions, CommitTransaction commits a transaction.
Definition gdaldataset.cpp:8053
GDALDataset::TestCapability
virtual int TestCapability(const char *)
Test if capability is available.
Definition gdaldataset.cpp:7855
GDALDataset::GetFieldDomainNames
virtual std::vector< std::string > GetFieldDomainNames(CSLConstList papszOptions=nullptr) const
Returns a list of the names of all field domains stored in the dataset.
Definition gdaldataset.cpp:9032
GDALDataset::DeleteFieldDomain
virtual bool DeleteFieldDomain(const std::string &name, std::string &failureReason)
Removes a field domain from the dataset.
Definition gdaldataset.cpp:9217
GDALDataset::CopyLayer
virtual OGRLayer * CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions=nullptr)
Duplicate an existing layer.
Definition gdaldataset.cpp:5639
GDALMajorObject::GetMetadataItem
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition gdalmajorobject.cpp:341
GDALRelationship
Definition of a table relationship.
Definition gdal_priv.h:3813
OGRDataSource
LEGACY class.
Definition ogrsf_frmts.h:518
OGRFieldDomain
Definition of a field domain.
Definition ogr_feature.h:1627
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:346
OGRGeometry
Abstract base class for all geometry classes.
Definition ogr_geometry.h:377
OGRLayer
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:74
OGRStyleTable
This class represents a style table.
Definition ogr_featurestyle.h:86
CPLErr
CPLErr
Error category.
Definition cpl_error.h:53
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:1042
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1183
OGRErr
int OGRErr
Type for a OGR error.
Definition ogr_core.h:387
ogrsf_frmts.h
Classes related to registration of format support, and opening datasets.