LCOV - code coverage report
Current view: top level - frmts/mem - memdataset.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 2 2 100.0 %
Date: 2024-04-29 12:21:24 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  Memory Array Translator
       5             :  * Purpose:  Declaration of MEMDataset, and MEMRasterBand.
       6             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2000, Frank Warmerdam
      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 MEMDATASET_H_INCLUDED
      31             : #define MEMDATASET_H_INCLUDED
      32             : 
      33             : #include "gdal_pam.h"
      34             : #include "gdal_priv.h"
      35             : #include "gdal_rat.h"
      36             : 
      37             : #include <memory>
      38             : 
      39             : CPL_C_START
      40             : /* Caution: if changing this prototype, also change in
      41             :    swig/include/gdal_python.i where it is redefined */
      42             : GDALRasterBandH CPL_DLL MEMCreateRasterBand(GDALDataset *, int, GByte *,
      43             :                                             GDALDataType, int, int, int);
      44             : GDALRasterBandH CPL_DLL MEMCreateRasterBandEx(GDALDataset *, int, GByte *,
      45             :                                               GDALDataType, GSpacing, GSpacing,
      46             :                                               int);
      47             : CPL_C_END
      48             : 
      49             : /************************************************************************/
      50             : /*                            MEMDataset                                */
      51             : /************************************************************************/
      52             : 
      53             : class MEMRasterBand;
      54             : 
      55             : class CPL_DLL MEMDataset CPL_NON_FINAL : public GDALDataset
      56             : {
      57             :     CPL_DISALLOW_COPY_ASSIGN(MEMDataset)
      58             : 
      59             :     friend class MEMRasterBand;
      60             : 
      61             :     int bGeoTransformSet;
      62             :     double adfGeoTransform[6];
      63             : 
      64             :     OGRSpatialReference m_oSRS{};
      65             : 
      66             :     std::vector<gdal::GCP> m_aoGCPs{};
      67             :     OGRSpatialReference m_oGCPSRS{};
      68             : 
      69             :     int m_nOverviewDSCount;
      70             :     GDALDataset **m_papoOverviewDS;
      71             : 
      72             :     struct Private;
      73             :     std::unique_ptr<Private> m_poPrivate;
      74             : 
      75             : #if 0
      76             :   protected:
      77             :     virtual int                 EnterReadWrite(GDALRWFlag eRWFlag);
      78             :     virtual void                LeaveReadWrite();
      79             : #endif
      80             : 
      81             :     friend void GDALRegister_MEM();
      82             : 
      83             :     // cppcheck-suppress unusedPrivateFunction
      84             :     static GDALDataset *CreateBase(const char *pszFilename, int nXSize,
      85             :                                    int nYSize, int nBands, GDALDataType eType,
      86             :                                    char **papszParamList);
      87             : 
      88             :   public:
      89             :     MEMDataset();
      90             :     virtual ~MEMDataset();
      91             : 
      92             :     const OGRSpatialReference *GetSpatialRef() const override;
      93             :     CPLErr SetSpatialRef(const OGRSpatialReference *poSRS) override;
      94             : 
      95             :     virtual CPLErr GetGeoTransform(double *) override;
      96             :     virtual CPLErr SetGeoTransform(double *) override;
      97             : 
      98             :     virtual void *GetInternalHandle(const char *) override;
      99             : 
     100             :     virtual int GetGCPCount() override;
     101             :     const OGRSpatialReference *GetGCPSpatialRef() const override;
     102             :     virtual const GDAL_GCP *GetGCPs() override;
     103             :     CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
     104             :                    const OGRSpatialReference *poSRS) override;
     105             :     virtual CPLErr AddBand(GDALDataType eType,
     106             :                            char **papszOptions = nullptr) override;
     107             :     virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
     108             :                              int nXSize, int nYSize, void *pData, int nBufXSize,
     109             :                              int nBufYSize, GDALDataType eBufType,
     110             :                              int nBandCount, int *panBandMap,
     111             :                              GSpacing nPixelSpaceBuf, GSpacing nLineSpaceBuf,
     112             :                              GSpacing nBandSpaceBuf,
     113             :                              GDALRasterIOExtraArg *psExtraArg) override;
     114             :     virtual CPLErr IBuildOverviews(const char *pszResampling, int nOverviews,
     115             :                                    const int *panOverviewList, int nListBands,
     116             :                                    const int *panBandList,
     117             :                                    GDALProgressFunc pfnProgress,
     118             :                                    void *pProgressData,
     119             :                                    CSLConstList papszOptions) override;
     120             : 
     121             :     virtual CPLErr CreateMaskBand(int nFlagsIn) override;
     122             : 
     123             :     std::shared_ptr<GDALGroup> GetRootGroup() const override;
     124             : 
     125             :     void AddMEMBand(GDALRasterBandH hMEMBand);
     126             : 
     127             :     static GDALDataset *Open(GDALOpenInfo *);
     128             :     static MEMDataset *Create(const char *pszFilename, int nXSize, int nYSize,
     129             :                               int nBands, GDALDataType eType,
     130             :                               char **papszParamList);
     131             :     static GDALDataset *
     132             :     CreateMultiDimensional(const char *pszFilename,
     133             :                            CSLConstList papszRootGroupOptions,
     134             :                            CSLConstList papszOptions);
     135             : };
     136             : 
     137             : /************************************************************************/
     138             : /*                            MEMRasterBand                             */
     139             : /************************************************************************/
     140             : 
     141             : class CPL_DLL MEMRasterBand CPL_NON_FINAL : public GDALPamRasterBand
     142             : {
     143             :   private:
     144             :     MEMRasterBand(GByte *pabyDataIn, GDALDataType eTypeIn, int nXSizeIn,
     145             :                   int nYSizeIn);
     146             : 
     147             :     CPL_DISALLOW_COPY_ASSIGN(MEMRasterBand)
     148             : 
     149             :   protected:
     150             :     friend class MEMDataset;
     151             : 
     152             :     GByte *pabyData;
     153             :     GSpacing nPixelOffset;
     154             :     GSpacing nLineOffset;
     155             :     int bOwnData;
     156             : 
     157             :     bool m_bIsMask = false;
     158             : 
     159             :   public:
     160             :     MEMRasterBand(GDALDataset *poDS, int nBand, GByte *pabyData,
     161             :                   GDALDataType eType, GSpacing nPixelOffset,
     162             :                   GSpacing nLineOffset, int bAssumeOwnership,
     163             :                   const char *pszPixelType = nullptr);
     164             :     virtual ~MEMRasterBand();
     165             : 
     166             :     virtual CPLErr IReadBlock(int, int, void *) override;
     167             :     virtual CPLErr IWriteBlock(int, int, void *) override;
     168             :     virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
     169             :                              int nXSize, int nYSize, void *pData, int nBufXSize,
     170             :                              int nBufYSize, GDALDataType eBufType,
     171             :                              GSpacing nPixelSpaceBuf, GSpacing nLineSpaceBuf,
     172             :                              GDALRasterIOExtraArg *psExtraArg) override;
     173             : 
     174             :     virtual int GetOverviewCount() override;
     175             :     virtual GDALRasterBand *GetOverview(int) override;
     176             : 
     177             :     virtual CPLErr CreateMaskBand(int nFlagsIn) override;
     178             :     virtual bool IsMaskBand() const override;
     179             : 
     180             :     // Allow access to MEM driver's private internal memory buffer.
     181          92 :     GByte *GetData() const
     182             :     {
     183          92 :         return (pabyData);
     184             :     }
     185             : };
     186             : 
     187             : #endif /* ndef MEMDATASET_H_INCLUDED */

Generated by: LCOV version 1.14