/src/gdal/frmts/pcidsk/sdk/blockdir/blocktilelayer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Purpose: Block directory API. |
4 | | * |
5 | | ****************************************************************************** |
6 | | * Copyright (c) 2011 |
7 | | * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada. |
8 | | * |
9 | | * SPDX-License-Identifier: MIT |
10 | | ****************************************************************************/ |
11 | | |
12 | | #ifndef PCIDSK_BLOCK_TILE_LAYER_H |
13 | | #define PCIDSK_BLOCK_TILE_LAYER_H |
14 | | |
15 | | #include "blockdir/blocklayer.h" |
16 | | #include "blockdir/blocktiledir.h" |
17 | | #include "pcidsk_mutex.h" |
18 | | #include <string> |
19 | | |
20 | | namespace PCIDSK |
21 | | { |
22 | | |
23 | | /************************************************************************/ |
24 | | /* class BlockTileLayer */ |
25 | | /************************************************************************/ |
26 | | |
27 | | /** |
28 | | * Class used as the base class for all block tile layers. |
29 | | * |
30 | | * @see BlockLayer |
31 | | */ |
32 | | class PCIDSK_DLL BlockTileLayer : public BlockLayer |
33 | | { |
34 | | protected: |
35 | | #pragma pack(push, 1) |
36 | | |
37 | | /// The block tile info structure. |
38 | | struct BlockTileInfo |
39 | | { |
40 | | uint64 nOffset; |
41 | | uint32 nSize; |
42 | | }; |
43 | | |
44 | | #pragma pack(pop) |
45 | | |
46 | | /// The block info list type. |
47 | | typedef std::vector<BlockTileInfo> BlockTileInfoList; |
48 | | |
49 | | /// The block layer info type. |
50 | | typedef BlockTileDir::BlockLayerInfo BlockLayerInfo; |
51 | | |
52 | | /// The tile layer info type. |
53 | | typedef BlockTileDir::TileLayerInfo TileLayerInfo; |
54 | | |
55 | | /// The block layer info. |
56 | | BlockLayerInfo * mpsBlockLayer; |
57 | | |
58 | | /// The tile layer info. |
59 | | TileLayerInfo * mpsTileLayer; |
60 | | |
61 | | /// The block tile info list. |
62 | | BlockTileInfoList moTileList; |
63 | | |
64 | | /// The tile list mutex. |
65 | | Mutex * mpoTileListMutex; |
66 | | |
67 | | /// If the block tile layer is modified. |
68 | | bool mbModified; |
69 | | |
70 | | mutable char mszDataType[5]; |
71 | | mutable char mszCompress[9]; |
72 | | |
73 | | /** |
74 | | * Sets the type of the layer. |
75 | | * |
76 | | * @param nLayerType The type of the layer. |
77 | | */ |
78 | | virtual void _SetLayerType(uint16 nLayerType) override |
79 | 0 | { |
80 | 0 | mpsBlockLayer->nLayerType = nLayerType; |
81 | 0 | } |
82 | | |
83 | | /** |
84 | | * Sets the number of blocks in the block layer. |
85 | | * |
86 | | * @param nBlockCount The number of blocks in the block layer. |
87 | | */ |
88 | | virtual void _SetBlockCount(uint32 nBlockCount) override |
89 | 0 | { |
90 | 0 | mpsBlockLayer->nBlockCount = nBlockCount; |
91 | 0 | } |
92 | | |
93 | | /** |
94 | | * Sets the size in bytes of the layer. |
95 | | * |
96 | | * @param nLayerSize The size in bytes of the layer. |
97 | | */ |
98 | | virtual void _SetLayerSize(uint64 nLayerSize) override |
99 | 0 | { |
100 | 0 | mpsBlockLayer->nLayerSize = nLayerSize; |
101 | 0 | } |
102 | | |
103 | | /** |
104 | | * Writes the tile list to disk. |
105 | | */ |
106 | | virtual void WriteTileList(void) = 0; |
107 | | |
108 | | /** |
109 | | * Reads the tile list from disk. |
110 | | */ |
111 | | virtual void ReadTileList(void) = 0; |
112 | | |
113 | | BlockTileInfo * GetTileInfo(uint32 nCol, uint32 nRow); |
114 | | |
115 | | public: |
116 | | BlockTileLayer(BlockDir * poBlockDir, uint32 nLayer, |
117 | | BlockLayerInfo * psBlockLayer, |
118 | | TileLayerInfo * psTileLayer); |
119 | | |
120 | | virtual ~BlockTileLayer(void); |
121 | | |
122 | | void Sync(void); |
123 | | |
124 | | bool IsCorrupted(void) const; |
125 | | |
126 | | uint32 GetTileCount(void) const; |
127 | | uint32 GetTilePerRow(void) const; |
128 | | uint32 GetTilePerCol(void) const; |
129 | | |
130 | | uint32 GetTileSize(void) const; |
131 | | |
132 | | uint32 GetDataTypeSize(void) const; |
133 | | |
134 | | bool IsTileValid(uint32 nCol, uint32 nRow); |
135 | | |
136 | | uint32 GetTileDataSize(uint32 nCol, uint32 nRow); |
137 | | |
138 | | bool WriteSparseTile(const void * pData, |
139 | | uint32 nCol, uint32 nRow); |
140 | | |
141 | | void WriteTile(const void * pData, |
142 | | uint32 nCol, uint32 nRow, uint32 nSize = 0); |
143 | | |
144 | | bool ReadSparseTile(void * pData, |
145 | | uint32 nCol, uint32 nRow); |
146 | | |
147 | | uint32 ReadTile(void * pData, uint32 nCol, uint32 nRow, uint32 nSize); |
148 | | |
149 | | bool ReadPartialSparseTile(void * pData, |
150 | | uint32 nCol, uint32 nRow, |
151 | | uint32 nOffset, uint32 nSize); |
152 | | |
153 | | bool ReadPartialTile(void * pData, |
154 | | uint32 nCol, uint32 nRow, |
155 | | uint32 nOffset, uint32 nSize); |
156 | | |
157 | | void SetTileLayerInfo(uint32 nXSize, uint32 nYSize, |
158 | | uint32 nTileXSize, uint32 nTileYSize, |
159 | | const std::string & oDataType, |
160 | | const std::string & oCompress, |
161 | | bool bNoDataValid = false, |
162 | | double dfNoDataValue = 0.0); |
163 | | |
164 | | /** |
165 | | * Gets the type of the layer. |
166 | | * |
167 | | * @return The type of the layer. |
168 | | */ |
169 | | virtual uint16 GetLayerType(void) const override |
170 | 3.21k | { |
171 | 3.21k | return mpsBlockLayer->nLayerType; |
172 | 3.21k | } |
173 | | |
174 | | /** |
175 | | * Gets the number of blocks in the block layer. |
176 | | * |
177 | | * @return The number of blocks in the block layer. |
178 | | */ |
179 | | virtual uint32 GetBlockCount(void) const override |
180 | 1.17k | { |
181 | 1.17k | return mpsBlockLayer->nBlockCount; |
182 | 1.17k | } |
183 | | |
184 | | /** |
185 | | * Gets the size in bytes of the layer. |
186 | | * |
187 | | * @return The size in bytes of the layer. |
188 | | */ |
189 | | virtual uint64 GetLayerSize(void) const override |
190 | 791 | { |
191 | 791 | return mpsBlockLayer->nLayerSize; |
192 | 791 | } |
193 | | |
194 | | /** |
195 | | * Gets the width of the tile layer. |
196 | | * |
197 | | * @return The width of the tile layer. |
198 | | */ |
199 | | uint32 GetXSize(void) const |
200 | 2.12k | { |
201 | 2.12k | return mpsTileLayer->nXSize; |
202 | 2.12k | } |
203 | | |
204 | | /** |
205 | | * Gets the height of the tile layer. |
206 | | * |
207 | | * @return The height of the tile layer. |
208 | | */ |
209 | | uint32 GetYSize(void) const |
210 | 678 | { |
211 | 678 | return mpsTileLayer->nYSize; |
212 | 678 | } |
213 | | |
214 | | /** |
215 | | * Gets the width of a tile. |
216 | | * |
217 | | * @return The width of a tile. |
218 | | */ |
219 | | uint32 GetTileXSize(void) const |
220 | 3.64k | { |
221 | 3.64k | return mpsTileLayer->nTileXSize; |
222 | 3.64k | } |
223 | | |
224 | | /** |
225 | | * Gets the height of a tile. |
226 | | * |
227 | | * @return The height of a tile. |
228 | | */ |
229 | | uint32 GetTileYSize(void) const |
230 | 2.21k | { |
231 | 2.21k | return mpsTileLayer->nTileYSize; |
232 | 2.21k | } |
233 | | |
234 | | const char * GetDataType(void) const; |
235 | | |
236 | | const char * GetCompressType(void) const; |
237 | | |
238 | | /** |
239 | | * Checks if the NoData value is valid. |
240 | | * |
241 | | * @return If the NoData value is valid. |
242 | | */ |
243 | | bool IsNoDataValid(void) const |
244 | 0 | { |
245 | 0 | return mpsTileLayer->bNoDataValid != 0; |
246 | 0 | } |
247 | | |
248 | | /** |
249 | | * Gets the NoData value of the tile layer. |
250 | | * |
251 | | * @return The NoData value of the tile layer. |
252 | | */ |
253 | | double GetNoDataValue(void) const |
254 | 0 | { |
255 | 0 | return mpsTileLayer->dfNoDataValue; |
256 | 0 | } |
257 | | }; |
258 | | |
259 | | } // namespace PCIDSK |
260 | | |
261 | | #endif |