Public Member Functions | Protected Member Functions | Protected Attributes

# OGRMutexedDataSource Class Reference

OGRMutexedDataSource class protects all virtual methods of OGRDataSource with a mutex. More...

`#include <ogrmutexeddatasource.h>`

Inheritance diagram for OGRMutexedDataSource:

List of all members.

## Public Member Functions
| OGRMutexedDataSource (OGRDataSource *poBaseDataSource, int bTakeOwnership, CPLMutex *hMutexIn, int bWrapLayersInMutexedLayer)
OGRDataSource * | GetBaseDataSource ()
virtual const char * | GetName ()
virtual int | GetLayerCount ()
| Get the number of layers in this dataset.
virtual OGRLayer * | GetLayer (int)
virtual OGRLayer * | GetLayerByName (const char *)
| Fetch a layer by name.
virtual OGRErr | DeleteLayer (int)
| Delete the indicated layer from the datasource.
virtual int | TestCapability (const char *)
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.
virtual OGRLayer * | CopyLayer (OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions=NULL)
| Duplicate an existing layer.
virtual OGRStyleTable * | GetStyleTable ()
| Returns dataset style table.
virtual void | SetStyleTableDirectly (OGRStyleTable *poStyleTable)
| Set dataset style table.
virtual void | SetStyleTable (OGRStyleTable *poStyleTable)
| Set dataset style table.
virtual OGRLayer * | ExecuteSQL (const char *pszStatement, OGRGeometry *poSpatialFilter, const char *pszDialect)
| Execute an SQL statement against the data store.
virtual void | ReleaseResultSet (OGRLayer *poResultsSet)
| Release results of ExecuteSQL().
virtual void | FlushCache ()
| Flush all write cached data to disk.
virtual OGRErr | StartTransaction (int bForce=FALSE)
virtual OGRErr | CommitTransaction ()
| For datasources which support transactions, CommitTransaction commits a transaction.
virtual OGRErr | RollbackTransaction ()
| For datasources which support transactions, RollbackTransaction will roll back a datasource to its state before the start of the current transaction.
virtual char ** | GetMetadata (const char *pszDomain="")
| Fetch metadata.
virtual CPLErr | SetMetadata (char **papszMetadata, const char *pszDomain="")
| Set metadata.
virtual const char * | GetMetadataItem (const char *pszName, const char *pszDomain="")
| Fetch single metadata item.
virtual CPLErr | SetMetadataItem (const char *pszName, const char *pszValue, const char *pszDomain="")
| Set single metadata item.
## Protected Member Functions
OGRLayer * | WrapLayerIfNecessary (OGRLayer *poLayer)
## Protected Attributes
OGRDataSource * | m_poBaseDataSource
int | m_bHasOwnership
CPLMutex * | m_hGlobalMutex
int | m_bWrapLayersInMutexedLayer
std::map< OGRLayer *, OGRMutexedLayer * > | m_oMapLayers
std::map< OGRMutexedLayer *, OGRLayer * > | m_oReverseMapLayers

## Detailed Description

OGRMutexedDataSource class protects all virtual methods of OGRDataSource with a mutex.

If the passed mutex is NULL, then no locking will be done.

Note that the constructors and destructors are not explictely protected by the mutex*

## Member Function Documentation

OGRErr OGRMutexedDataSource::CommitTransaction | ( |  | ) | `[virtual]`

For datasources which support transactions, CommitTransaction commits a transaction.

If no transaction is active, or the commit fails, will return OGRERR_FAILURE. Datasources which do not support transactions will always return OGRERR_UNSUPPORTED_OPERATION.

Depending on drivers, this may or may not abort layer sequential readings that are active.

This function is the same as the C function GDALDatasetCommitTransaction().

Returns:
  OGRERR_NONE on success.

Since:
  GDAL 2.0

Reimplemented from GDALDataset.

OGRLayer * OGRMutexedDataSource::CopyLayer | ( | OGRLayer * | poSrcLayer,
|  | const char * | pszNewName,
|  | char ** | papszOptions = `NULL` |
| ) |  |  | `[virtual]`

Duplicate an existing layer.

This method creates a new layer, duplicate the field definitions of the source layer and then duplicate each features of the source layer. The papszOptions argument can be used to control driver specific creation options. These options are normally documented in the format specific documentation. The source layer may come from another dataset.

This method is the same as the C function GDALDatasetCopyLayer() and the deprecated OGR_DS_CopyLayer().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Parameters:

  | poSrcLayer | source layer.
  | pszNewName | the name of the layer to create.
  | papszOptions | a StringList of name=value options. Options are driver specific.

Returns:
  an handle to the layer, or NULL if an error occurs.

Reimplemented from GDALDataset.

OGRErr OGRMutexedDataSource::DeleteLayer | ( | int | iLayer | ) | `[virtual]`

Delete the indicated layer from the datasource.

If this method is supported the ODsCDeleteLayer capability will test TRUE on the GDALDataset.

This method is the same as the C function GDALDatasetDeleteLayer() and the deprecated OGR_DS_DeleteLayer().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Parameters:

  | iLayer | the index of the layer to delete.

Returns:
  OGRERR_NONE on success, or OGRERR_UNSUPPORTED_OPERATION if deleting layers is not supported for this datasource.

Reimplemented from GDALDataset.

OGRLayer * OGRMutexedDataSource::ExecuteSQL | ( | const char * | pszStatement,
|  | OGRGeometry * | poSpatialFilter,
|  | const char * | pszDialect |
| ) |  |  | `[virtual]`

Execute an SQL statement against the data store.

The result of an SQL query is either NULL for statements that are in error, or that have no results set, or an OGRLayer pointer representing a results set from the query. Note that this OGRLayer is in addition to the layers in the data store and must be destroyed with ReleaseResultSet() before the dataset is closed (destroyed).

This method is the same as the C function GDALDatasetExecuteSQL() and the deprecated OGR_DS_ExecuteSQL().

For more information on the SQL dialect supported internally by OGR review the OGR SQL document. Some drivers (ie. Oracle and PostGIS) pass the SQL directly through to the underlying RDBMS.

Starting with OGR 1.10, the SQLITE dialect can also be used.

In GDAL 1.X, this method used to be in the OGRDataSource class.

Parameters:

  | pszStatement | the SQL statement to execute.
  | poSpatialFilter | geometry which represents a spatial filter. Can be NULL.
  | pszDialect | allows control of the statement dialect. If set to NULL, the OGR SQL engine will be used, except for RDBMS drivers that will use their dedicated SQL engine, unless OGRSQL is explicitly passed as the dialect. Starting with OGR 1.10, the SQLITE dialect can also be used.

Returns:
  an OGRLayer containing the results of the query. Deallocate with ReleaseResultSet().

Reimplemented from GDALDataset.

void OGRMutexedDataSource::FlushCache | ( | void |  | ) | `[virtual]`

Flush all write cached data to disk.

Any raster (or other GDAL) data written via GDAL calls, but buffered internally will be written to disk.

The default implementation of this method just calls the FlushCache() method on each of the raster bands and the SyncToDisk() method on each of the layers. Conceptionally, calling FlushCache() on a dataset should include any work that might be accomplished by calling SyncToDisk() on layers in that dataset.

Using this method does not prevent use from calling GDALClose() to properly close a dataset and ensure that important data not addressed by FlushCache() is written in the file.

This method is the same as the C function GDALFlushCache().

Reimplemented from GDALDataset.

OGRLayer * OGRMutexedDataSource::GetLayerByName | ( | const char * | pszName | ) | `[virtual]`

Fetch a layer by name.

The returned layer remains owned by the GDALDataset and should not be deleted by the application.

This method is the same as the C function GDALDatasetGetLayerByName() and the deprecated OGR_DS_GetLayerByName().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Parameters:

  | pszLayerName | the layer name of the layer to fetch.

Returns:
  the layer, or NULL if Layer is not found or an error occurs.

Reimplemented from GDALDataset.

int OGRMutexedDataSource::GetLayerCount | ( |  | ) | `[virtual]`

Get the number of layers in this dataset.

This method is the same as the C function GDALDatasetGetLayerCount(), and the deprecated OGR_DS_GetLayerCount().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Returns:
  layer count.

Reimplemented from GDALDataset.

char ** OGRMutexedDataSource::GetMetadata | ( | const char * | pszDomain = `""` | ) | `[virtual]`

Fetch metadata.

The returned string list is owned by the object, and may change at any time. It is formated as a "Name=value" list with the last pointer value being NULL. Use the the CPL StringList functions such as CSLFetchNameValue() to manipulate it.

Note that relatively few formats return any metadata at this time.

This method does the same thing as the C function GDALGetMetadata().

Parameters:

  | pszDomain | the domain of interest. Use "" or NULL for the default domain.

Returns:
  NULL or a string list.

Reimplemented from GDALMajorObject.

const char * OGRMutexedDataSource::GetMetadataItem | ( | const char * | pszName,
|  | const char * | pszDomain = `""` |
| ) |  |  | `[virtual]`

Fetch single metadata item.

The C function GDALGetMetadataItem() does the same thing as this method.

Parameters:

  | pszName | the key for the metadata item to fetch.
  | pszDomain | the domain to fetch for, use NULL for the default domain.

Returns:
  NULL on failure to find the key, or a pointer to an internal copy of the value string on success.

Reimplemented from GDALMajorObject.

OGRStyleTable * OGRMutexedDataSource::GetStyleTable | ( |  | ) | `[virtual]`

Returns dataset style table.

This method is the same as the C function GDALDatasetGetStyleTable() and the deprecated OGR_DS_GetStyleTable().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Returns:
  pointer to a style table which should not be modified or freed by the caller.

Reimplemented from GDALDataset.

OGRLayer * OGRMutexedDataSource::ICreateLayer | ( | const char * | pszName,
|  | OGRSpatialReference * | poSpatialRef = `NULL`,
|  | OGRwkbGeometryType | eGType = `wkbUnknown`,
|  | char ** | papszOptions = `NULL` |
| ) |  |  | `[virtual]`

This method attempts to create a new layer on the dataset with the indicated name, coordinate system, geometry type.

This method is reserved to implementation by drivers.

The papszOptions argument can be used to control driver specific creation options. These options are normally documented in the format specific documentation.

Parameters:

  | pszName | the name for the new layer. This should ideally not match any existing layer on the datasource.
  | poSpatialRef | the coordinate system to use for the new layer, or NULL if no coordinate system is available.
  | eGType | the geometry type for the layer. Use wkbUnknown if there are no constraints on the types geometry to be written.
  | papszOptions | a StringList of name=value options. Options are driver specific.

Returns:
  NULL is returned on failure, or a new OGRLayer handle on success.

Since:
  GDAL 2.0

Reimplemented from GDALDataset.

void OGRMutexedDataSource::ReleaseResultSet | ( | OGRLayer * | poResultsSet | ) | `[virtual]`

Release results of ExecuteSQL().

This method should only be used to deallocate OGRLayers resulting from an ExecuteSQL() call on the same GDALDataset. Failure to deallocate a results set before destroying the GDALDataset may cause errors.

This method is the same as the C function GDALDatasetReleaseResultSet() and the deprecated OGR_DS_ReleaseResultSet().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Parameters:

  | poResultsSet | the result of a previous ExecuteSQL() call.

Reimplemented from GDALDataset.

OGRErr OGRMutexedDataSource::RollbackTransaction | ( |  | ) | `[virtual]`

For datasources which support transactions, RollbackTransaction will roll back a datasource to its state before the start of the current transaction.

If no transaction is active, or the rollback fails, will return OGRERR_FAILURE. Datasources which do not support transactions will always return OGRERR_UNSUPPORTED_OPERATION.

This function is the same as the C function GDALDatasetRollbackTransaction().

Returns:
  OGRERR_NONE on success.

Since:
  GDAL 2.0

Reimplemented from GDALDataset.

CPLErr OGRMutexedDataSource::SetMetadata | ( | char ** | papszMetadataIn,
|  | const char * | pszDomain = `""` |
| ) |  |  | `[virtual]`

Set metadata.

The C function GDALSetMetadata() does the same thing as this method.

Parameters:

  | papszMetadataIn | the metadata in name=value string list format to apply.
  | pszDomain | the domain of interest. Use "" or NULL for the default domain.

Returns:
  CE_None on success, CE_Failure on failure and CE_Warning if the metadata has been accepted, but is likely not maintained persistently by the underlying object between sessions.

Reimplemented from GDALMajorObject.

CPLErr OGRMutexedDataSource::SetMetadataItem | ( | const char * | pszName,
|  | const char * | pszValue,
|  | const char * | pszDomain = `""` |
| ) |  |  | `[virtual]`

Set single metadata item.

The C function GDALSetMetadataItem() does the same thing as this method.

Parameters:

  | pszName | the key for the metadata item to fetch.
  | pszValue | the value to assign to the key.
  | pszDomain | the domain to set within, use NULL for the default domain.

Returns:
  CE_None on success, or an error code on failure.

Reimplemented from GDALMajorObject.

void OGRMutexedDataSource::SetStyleTable | ( | OGRStyleTable * | poStyleTable | ) | `[virtual]`

Set dataset style table.

This method operate exactly as SetStyleTableDirectly() except that it does not assume ownership of the passed table.

This method is the same as the C function GDALDatasetSetStyleTable() and the deprecated OGR_DS_SetStyleTable().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Parameters:

  | poStyleTable | pointer to style table to set

Reimplemented from GDALDataset.

void OGRMutexedDataSource::SetStyleTableDirectly | ( | OGRStyleTable * | poStyleTable | ) | `[virtual]`

Set dataset style table.

This method operate exactly as SetStyleTable() except that it assumes ownership of the passed table.

This method is the same as the C function GDALDatasetSetStyleTableDirectly() and the deprecated OGR_DS_SetStyleTableDirectly().

In GDAL 1.X, this method used to be in the OGRDataSource class.

Parameters:

  | poStyleTable | pointer to style table to set

Reimplemented from GDALDataset.

The documentation for this class was generated from the following files:

- ogrmutexeddatasource.h
- ogrmutexeddatasource.cpp

Generated for GDAL by 1.7.1.