GDAL

ogrmutexeddatasource.h
1/******************************************************************************
2 *
3 * Project: OpenGIS Simple Features Reference Implementation
4 * Purpose: Defines OGRLMutexedDataSource class
5 * Author: Even Rouault, even dot rouault at spatialys.com
6 *
7 ******************************************************************************
8 * Copyright (c) 2013, Even Rouault <even dot rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
14#define OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
15
16#ifndef DOXYGEN_SKIP
17
18#include "ogrsf_frmts.h"
19#include "cpl_multiproc.h"
20#include "ogrmutexedlayer.h"
21#include <map>
22
30 class CPL_DLL OGRMutexedDataSource final : public GDALDataset
31{
32 CPL_DISALLOW_COPY_ASSIGN(OGRMutexedDataSource)
33
34 protected:
35 GDALDataset *m_poBaseDataSource = nullptr;
36 int m_bHasOwnership = false;
37 CPLMutex *m_hGlobalMutex = nullptr;
38 int m_bWrapLayersInMutexedLayer = false;
39 std::map<OGRLayer *, OGRMutexedLayer *> m_oMapLayers{};
40 std::map<OGRMutexedLayer *, OGRLayer *> m_oReverseMapLayers{};
41
42 OGRLayer *WrapLayerIfNecessary(OGRLayer *poLayer);
43
44 public:
45 /* The construction of the object isn't protected by the mutex */
46 OGRMutexedDataSource(GDALDataset *poBaseDataSource, int bTakeOwnership,
47 CPLMutex *hMutexIn, int bWrapLayersInMutexedLayer);
48
49 /* The destruction of the object isn't protected by the mutex */
50 ~OGRMutexedDataSource() override;
51
52 GDALDataset *GetBaseDataSource()
53 {
54 return m_poBaseDataSource;
55 }
56
57 int GetLayerCount() const override;
58 using GDALDataset::GetLayer;
59 const OGRLayer *GetLayer(int) const override;
60 OGRLayer *GetLayerByName(const char *) override;
61 OGRErr DeleteLayer(int) override;
62 bool IsLayerPrivate(int iLayer) const override;
63
64 int TestCapability(const char *) const 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 OGRStyleTable *GetStyleTable() override;
73 void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override;
74
75 void SetStyleTable(OGRStyleTable *poStyleTable) override;
76
77 OGRLayer *ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter,
78 const char *pszDialect) override;
79 void ReleaseResultSet(OGRLayer *poResultsSet) override;
80
81 CPLErr FlushCache(bool bAtClosing) override;
82
83 OGRErr StartTransaction(int bForce = FALSE) override;
84 OGRErr CommitTransaction() override;
85 OGRErr RollbackTransaction() override;
86
87 char **GetMetadata(const char *pszDomain = "") override;
88 CPLErr SetMetadata(char **papszMetadata,
89 const char *pszDomain = "") override;
90 virtual const char *GetMetadataItem(const char *pszName,
91 const char *pszDomain = "") override;
92 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
93 const char *pszDomain = "") override;
94
95 virtual std::vector<std::string>
96 GetFieldDomainNames(CSLConstList papszOptions = nullptr) const override;
97 virtual const OGRFieldDomain *
98 GetFieldDomain(const std::string &name) const override;
99
100 virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
101 std::string &failureReason) override;
102 virtual bool DeleteFieldDomain(const std::string &name,
103 std::string &failureReason) override;
104 virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
105 std::string &failureReason) override;
106
107 std::vector<std::string>
108 GetRelationshipNames(CSLConstList papszOptions = nullptr) const override;
109
110 const GDALRelationship *
111 GetRelationship(const std::string &name) const override;
112
113 std::shared_ptr<GDALGroup> GetRootGroup() const override;
114};
115
116#endif /* #ifndef DOXYGEN_SKIP */
117
118#endif // OGRMUTEXEDDATASOURCELAYER_H_INCLUDED
GDALDataset
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:76
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:7906
GDALDataset::SetStyleTableDirectly
virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition gdaldataset.cpp:7770
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:10079
GDALDataset::GetLayer
virtual const OGRLayer * GetLayer(int iLayer) const
Fetch a layer by index.
Definition gdaldataset.cpp:7864
GDALDataset::GetStyleTable
virtual OGRStyleTable * GetStyleTable()
Returns dataset style table.
Definition gdaldataset.cpp:7749
GDALDataset::StartTransaction
virtual OGRErr StartTransaction(int bForce=FALSE)
For datasources which support transactions, StartTransaction creates a `transaction.
Definition gdaldataset.cpp:8362
GDALDataset::GetRelationship
virtual const GDALRelationship * GetRelationship(const std::string &name) const
Get a relationship from its name.
Definition gdaldataset.cpp:10191
GDALDataset::GetLayerByName
virtual OGRLayer * GetLayerByName(const char *)
Fetch a layer by name.
Definition gdaldataset.cpp:6382
GDALDataset::SetStyleTable
virtual void SetStyleTable(OGRStyleTable *poStyleTable)
Set dataset style table.
Definition gdaldataset.cpp:7794
GDALDataset::ExecuteSQL
virtual OGRLayer * ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect)
Execute an SQL statement against the data store.
Definition gdaldataset.cpp:7139
GDALDataset::GetFieldDomain
virtual const OGRFieldDomain * GetFieldDomain(const std::string &name) const
Get a field domain from its name.
Definition gdaldataset.cpp:9874
GDALDataset::RollbackTransaction
virtual OGRErr RollbackTransaction()
For datasources which support transactions, RollbackTransaction will roll back a datasource to its st...
Definition gdaldataset.cpp:8503
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:5978
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:600
GDALDataset::ReleaseResultSet
virtual void ReleaseResultSet(OGRLayer *poResultsSet)
Release results of ExecuteSQL().
Definition gdaldataset.cpp:7729
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:9930
GDALDataset::GetMetadata
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition gdaldataset.cpp:4951
GDALDataset::TestCapability
virtual int TestCapability(const char *) const
Test if capability is available.
Definition gdaldataset.cpp:8241
GDALDataset::GetLayerCount
virtual int GetLayerCount() const
Get the number of layers in this dataset.
Definition gdaldataset.cpp:7831
GDALDataset::GetRootGroup
virtual std::shared_ptr< GDALGroup > GetRootGroup() const
Return the root GDALGroup of this dataset.
Definition gdaldataset.cpp:9740
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:10147
GDALDataset::DeleteLayer
virtual OGRErr DeleteLayer(int iLayer)
Delete the indicated layer from the datasource.
Definition gdaldataset.cpp:6355
GDALDataset::CommitTransaction
virtual OGRErr CommitTransaction()
For datasources which support transactions, CommitTransaction commits a transaction.
Definition gdaldataset.cpp:8450
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:9824
GDALDataset::DeleteFieldDomain
virtual bool DeleteFieldDomain(const std::string &name, std::string &failureReason)
Removes a field domain from the dataset.
Definition gdaldataset.cpp:10009
GDALDataset::CopyLayer
virtual OGRLayer * CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions=nullptr)
Duplicate an existing layer.
Definition gdaldataset.cpp:6018
GDALMajorObject::GetMetadataItem
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition gdalmajorobject.cpp:322
GDALRelationship
Definition of a table relationship.
Definition gdal_relationship.h:38
OGRFieldDomain
Definition of a field domain.
Definition ogr_feature.h:1661
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:332
OGRGeometry
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
OGRLayer
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
OGRStyleTable
This class represents a style table.
Definition ogr_featurestyle.h:69
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:936
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
OGRErr
int OGRErr
Type for a OGR error.
Definition ogr_core.h:370
ogrsf_frmts.h
Classes related to registration of format support, and opening datasets.