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 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#ifndef OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
15#define OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
16
17#ifndef DOXYGEN_SKIP
18
19#include "ogrsf_frmts.h"
20#include "cpl_multiproc.h"
21#include "ogrmutexedlayer.h"
22#include <map>
23
31 class CPL_DLL OGRMutexedDataSource : public GDALDataset
32{
33 CPL_DISALLOW_COPY_ASSIGN(OGRMutexedDataSource)
34
35 protected:
36 GDALDataset *m_poBaseDataSource;
37 int m_bHasOwnership;
38 CPLMutex *m_hGlobalMutex;
39 int m_bWrapLayersInMutexedLayer;
40 std::map<OGRLayer *, OGRMutexedLayer *> m_oMapLayers{};
41 std::map<OGRMutexedLayer *, OGRLayer *> m_oReverseMapLayers{};
42
43 OGRLayer *WrapLayerIfNecessary(OGRLayer *poLayer);
44
45 public:
46 /* The construction of the object isn't protected by the mutex */
47 OGRMutexedDataSource(GDALDataset *poBaseDataSource, int bTakeOwnership,
48 CPLMutex *hMutexIn, int bWrapLayersInMutexedLayer);
49
50 /* The destruction of the object isn't protected by the mutex */
51 virtual ~OGRMutexedDataSource() override;
52
53 GDALDataset *GetBaseDataSource()
54 {
55 return m_poBaseDataSource;
56 }
57
58 virtual int GetLayerCount() override;
59 virtual OGRLayer *GetLayer(int) override;
60 virtual OGRLayer *GetLayerByName(const char *) override;
61 virtual OGRErr DeleteLayer(int) override;
62 virtual bool IsLayerPrivate(int iLayer) const override;
63
64 virtual int TestCapability(const char *) override;
65
66 virtual OGRLayer *ICreateLayer(const char *pszName,
67 const OGRGeomFieldDefn *poGeomFieldDefn,
68 CSLConstList papszOptions) override;
69 virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName,
70 char **papszOptions = nullptr) override;
71
72 virtual OGRStyleTable *GetStyleTable() override;
73 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override;
74
75 virtual void SetStyleTable(OGRStyleTable *poStyleTable) override;
76
77 virtual OGRLayer *ExecuteSQL(const char *pszStatement,
78 OGRGeometry *poSpatialFilter,
79 const char *pszDialect) override;
80 virtual void ReleaseResultSet(OGRLayer *poResultsSet) override;
81
82 virtual CPLErr FlushCache(bool bAtClosing) override;
83
84 virtual OGRErr StartTransaction(int bForce = FALSE) override;
85 virtual OGRErr CommitTransaction() override;
86 virtual OGRErr RollbackTransaction() override;
87
88 virtual char **GetMetadata(const char *pszDomain = "") override;
89 virtual CPLErr SetMetadata(char **papszMetadata,
90 const char *pszDomain = "") override;
91 virtual const char *GetMetadataItem(const char *pszName,
92 const char *pszDomain = "") override;
93 virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
94 const char *pszDomain = "") override;
95
96 virtual std::vector<std::string>
97 GetFieldDomainNames(CSLConstList papszOptions = nullptr) const override;
98 virtual const OGRFieldDomain *
99 GetFieldDomain(const std::string &name) const override;
100
101 virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
102 std::string &failureReason) override;
103 virtual bool DeleteFieldDomain(const std::string &name,
104 std::string &failureReason) override;
105 virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
106 std::string &failureReason) override;
107
108 std::vector<std::string>
109 GetRelationshipNames(CSLConstList papszOptions = nullptr) const override;
110
111 const GDALRelationship *
112 GetRelationship(const std::string &name) const override;
113
114 virtual std::shared_ptr<GDALGroup> GetRootGroup() const override;
115};
116
117#endif /* #ifndef DOXYGEN_SKIP */
118
119#endif // OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
GDALDataset
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:495
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:7595
GDALDataset::SetStyleTableDirectly
virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition: gdaldataset.cpp:7480
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:9364
GDALDataset::GetLayerCount
virtual int GetLayerCount()
Get the number of layers in this dataset.
Definition: gdaldataset.cpp:7542
GDALDataset::GetStyleTable
virtual OGRStyleTable * GetStyleTable()
Returns dataset style table.
Definition: gdaldataset.cpp:7457
GDALDataset::StartTransaction
virtual OGRErr StartTransaction(int bForce=FALSE)
For datasources which support transactions, StartTransaction creates a `transaction.
Definition: gdaldataset.cpp:8039
GDALDataset::GetRelationship
virtual const GDALRelationship * GetRelationship(const std::string &name) const
Get a relationship from its name.
Definition: gdaldataset.cpp:9476
GDALDataset::GetLayerByName
virtual OGRLayer * GetLayerByName(const char *)
Fetch a layer by name.
Definition: gdaldataset.cpp:6084
GDALDataset::SetStyleTable
virtual void SetStyleTable(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition: gdaldataset.cpp:7506
GDALDataset::ExecuteSQL
virtual OGRLayer * ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect)
Execute an SQL statement against the data store.
Definition: gdaldataset.cpp:6843
GDALDataset::GetFieldDomain
virtual const OGRFieldDomain * GetFieldDomain(const std::string &name) const
Get a field domain from its name.
Definition: gdaldataset.cpp:9159
GDALDataset::RollbackTransaction
virtual OGRErr RollbackTransaction()
For datasources which support transactions, RollbackTransaction will roll back a datasource to its st...
Definition: gdaldataset.cpp:8184
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:5674
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:550
GDALDataset::GetLayer
virtual OGRLayer * GetLayer(int iLayer)
Fetch a layer by index.
Definition: gdaldataset.cpp:7572
GDALDataset::ReleaseResultSet
virtual void ReleaseResultSet(OGRLayer *poResultsSet)
Release results of ExecuteSQL().
Definition: gdaldataset.cpp:7435
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:9215
GDALDataset::GetMetadata
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition: gdaldataset.cpp:4668
GDALDataset::GetRootGroup
virtual std::shared_ptr< GDALGroup > GetRootGroup() const
Return the root GDALGroup of this dataset.
Definition: gdaldataset.cpp:9025
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:9432
GDALDataset::DeleteLayer
virtual OGRErr DeleteLayer(int iLayer)
Delete the indicated layer from the datasource.
Definition: gdaldataset.cpp:6055
GDALDataset::CommitTransaction
virtual OGRErr CommitTransaction()
For datasources which support transactions, CommitTransaction commits a transaction.
Definition: gdaldataset.cpp:8129
GDALDataset::TestCapability
virtual int TestCapability(const char *)
Test if capability is available.
Definition: gdaldataset.cpp:7931
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:9109
GDALDataset::DeleteFieldDomain
virtual bool DeleteFieldDomain(const std::string &name, std::string &failureReason)
Removes a field domain from the dataset.
Definition: gdaldataset.cpp:9294
GDALDataset::CopyLayer
virtual OGRLayer * CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions=nullptr)
Duplicate an existing layer.
Definition: gdaldataset.cpp:5716
GDALMajorObject::GetMetadataItem
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition: gdalmajorobject.cpp:325
GDALRelationship
Definition of a table relationship.
Definition: gdal_priv.h:4002
OGRFieldDomain
Definition of a field domain.
Definition: ogr_feature.h:1611
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:330
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:361
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:58
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:70
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:37
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:1030
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1179
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:371
ogrsf_frmts.h
Classes related to registration of format support, and opening datasets.