gooderp18绿色标准版
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

194 Zeilen
7.2KB

  1. /******************************************************************************
  2. * $Id: rawdataset.h 818f06b5bc60efa562497297e60d066a2ed9c0c3 2019-04-17 21:45:17 +0200 Even Rouault $
  3. *
  4. * Project: Raw Translator
  5. * Purpose: Implementation of RawDataset class. Intended to be subclassed
  6. * by other raw formats.
  7. * Author: Frank Warmerdam, warmerdam@pobox.com
  8. *
  9. ******************************************************************************
  10. * Copyright (c) 1999, Frank Warmerdam
  11. * Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
  12. *
  13. * Permission is hereby granted, free of charge, to any person obtaining a
  14. * copy of this software and associated documentation files (the "Software"),
  15. * to deal in the Software without restriction, including without limitation
  16. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  17. * and/or sell copies of the Software, and to permit persons to whom the
  18. * Software is furnished to do so, subject to the following conditions:
  19. *
  20. * The above copyright notice and this permission notice shall be included
  21. * in all copies or substantial portions of the Software.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  26. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  28. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  29. * DEALINGS IN THE SOFTWARE.
  30. ****************************************************************************/
  31. #ifndef GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED
  32. #define GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED
  33. #include "gdal_pam.h"
  34. /************************************************************************/
  35. /* ==================================================================== */
  36. /* RawDataset */
  37. /* ==================================================================== */
  38. /************************************************************************/
  39. class RawRasterBand;
  40. /**
  41. * \brief Abstract Base Class dedicated to define new raw dataset types.
  42. */
  43. class CPL_DLL RawDataset : public GDALPamDataset
  44. {
  45. friend class RawRasterBand;
  46. protected:
  47. CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  48. void *, int, int, GDALDataType,
  49. int, int *,
  50. GSpacing nPixelSpace, GSpacing nLineSpace,
  51. GSpacing nBandSpace,
  52. GDALRasterIOExtraArg* psExtraArg ) override;
  53. public:
  54. RawDataset();
  55. virtual ~RawDataset() = 0;
  56. private:
  57. CPL_DISALLOW_COPY_ASSIGN(RawDataset)
  58. };
  59. /************************************************************************/
  60. /* ==================================================================== */
  61. /* RawRasterBand */
  62. /* ==================================================================== */
  63. /************************************************************************/
  64. /**
  65. * \brief Abstract Base Class dedicated to define raw datasets.
  66. * \note It is not defined an Abstract Base Class, but it is advised to
  67. * consider it as such and not use it directly in client's code.
  68. */
  69. class CPL_DLL RawRasterBand : public GDALPamRasterBand
  70. {
  71. protected:
  72. friend class RawDataset;
  73. VSILFILE *fpRawL{};
  74. vsi_l_offset nImgOffset{};
  75. int nPixelOffset{};
  76. int nLineOffset{};
  77. int nLineSize{};
  78. int bNativeOrder{};
  79. int nLoadedScanline{};
  80. void *pLineBuffer{};
  81. void *pLineStart{};
  82. int bDirty{};
  83. GDALColorTable *poCT{};
  84. GDALColorInterp eInterp{};
  85. char **papszCategoryNames{};
  86. int bOwnsFP{};
  87. int Seek( vsi_l_offset, int );
  88. size_t Read( void *, size_t, size_t );
  89. size_t Write( void *, size_t, size_t );
  90. CPLErr AccessBlock( vsi_l_offset nBlockOff, size_t nBlockSize,
  91. void * pData );
  92. int IsSignificantNumberOfLinesLoaded( int nLineOff, int nLines );
  93. void Initialize();
  94. CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
  95. void *, int, int, GDALDataType,
  96. GSpacing nPixelSpace, GSpacing nLineSpace,
  97. GDALRasterIOExtraArg* psExtraArg ) override;
  98. int CanUseDirectIO(int nXOff, int nYOff, int nXSize, int nYSize,
  99. GDALDataType eBufType,
  100. GDALRasterIOExtraArg* psExtraArg);
  101. public:
  102. enum class OwnFP
  103. {
  104. NO,
  105. YES
  106. };
  107. RawRasterBand( GDALDataset *poDS, int nBand, VSILFILE* fpRaw,
  108. vsi_l_offset nImgOffset, int nPixelOffset,
  109. int nLineOffset,
  110. GDALDataType eDataType, int bNativeOrder,
  111. OwnFP bOwnsFP );
  112. RawRasterBand( VSILFILE* fpRaw,
  113. vsi_l_offset nImgOffset, int nPixelOffset,
  114. int nLineOffset,
  115. GDALDataType eDataType, int bNativeOrder,
  116. int nXSize, int nYSize,
  117. OwnFP bOwnsFP );
  118. virtual ~RawRasterBand() /* = 0 */ ;
  119. CPLErr IReadBlock( int, int, void * ) override;
  120. CPLErr IWriteBlock( int, int, void * ) override;
  121. GDALColorTable *GetColorTable() override;
  122. GDALColorInterp GetColorInterpretation() override;
  123. CPLErr SetColorTable( GDALColorTable * ) override;
  124. CPLErr SetColorInterpretation( GDALColorInterp ) override;
  125. char **GetCategoryNames() override;
  126. CPLErr SetCategoryNames( char ** ) override;
  127. CPLErr FlushCache() override;
  128. CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
  129. int *pnPixelSpace,
  130. GIntBig *pnLineSpace,
  131. char **papszOptions ) override;
  132. CPLErr AccessLine( int iLine );
  133. void SetAccess( GDALAccess eAccess );
  134. // this is deprecated.
  135. void StoreNoDataValue( double );
  136. // Query methods for internal data.
  137. vsi_l_offset GetImgOffset() const { return nImgOffset; }
  138. int GetPixelOffset() const { return nPixelOffset; }
  139. int GetLineOffset() const { return nLineOffset; }
  140. int GetNativeOrder() const { return bNativeOrder; }
  141. VSILFILE *GetFPL() const { return fpRawL; }
  142. int GetOwnsFP() const { return bOwnsFP; }
  143. private:
  144. CPL_DISALLOW_COPY_ASSIGN(RawRasterBand)
  145. };
  146. #ifdef GDAL_COMPILATION
  147. bool RAWDatasetCheckMemoryUsage(int nXSize, int nYSize, int nBands,
  148. int nDTSize,
  149. int nPixelOffset,
  150. int nLineOffset,
  151. vsi_l_offset nHeaderSize,
  152. vsi_l_offset nBandOffset,
  153. VSILFILE* fp);
  154. #endif
  155. #endif // GDAL_FRMTS_RAW_RAWDATASET_H_INCLUDED
上海开阖软件有限公司 沪ICP备12045867号-1