30 | | |
| 30 | == Definition == |
| 31 | |
| 32 | ''Header and dummy class file below'' |
| 33 | |
| 34 | '''GDALAsyncDataset.h''' |
| 35 | |
| 36 | {{{ |
| 37 | /****************************************************************************** |
| 38 | * |
| 39 | * Project: Progressive Renderer Client Driver |
| 40 | * Purpose: Implementation of Dataset and RasterBand classes for JPIP and other |
| 41 | * progressive rendering protocols / formats |
| 42 | ******************************************************************************* |
| 43 | */ |
| 44 | |
| 45 | #include "gdal_pam.h" |
| 46 | |
| 47 | |
| 48 | class GDALAsyncDataset; |
| 49 | class GDALAsyncRasterBand; |
| 50 | class GDALRasterIOContext; |
| 51 | |
| 52 | /** |
| 53 | * status of the asynchronous stream |
| 54 | */ |
| 55 | typedef enum |
| 56 | { |
| 57 | IO_PENDING = 0, |
| 58 | IO_UPDATE = 1, |
| 59 | IO_ERROR = 2, |
| 60 | IO_COMPLETE = 3 |
| 61 | } AsyncStatus; |
| 62 | |
| 63 | /**********************************************************************/ |
| 64 | /* GDALAsyncDataset */ |
| 65 | /**********************************************************************/ |
| 66 | class CPL_DLL GDALAsyncDataset : public GDALPamDataset |
| 67 | { |
| 68 | friend class GDALAsyncRasterBand; |
| 69 | friend class GDALRasterIOContext; |
| 70 | public: |
| 71 | GDALAsyncDataset(void); |
| 72 | virtual ~GDALAsyncDataset(){}; |
| 73 | virtual GDALRasterIOContext *CreateRasterIOContext(GDALRWFlag eRWFlag, |
| 74 | int nDSXOff, int nDSYOff, |
| 75 | int nDSXSize, int nDSYSize, |
| 76 | int nBXSize, int nBYSize, |
| 77 | GDALDataType eBDataType, |
| 78 | int nBandCount, int* panBandMap, |
| 79 | int nPixelSpace, int nLineSpace, int nBandSpace); |
| 80 | |
| 81 | |
| 82 | /* |
| 83 | * GDALAsyncDatasetOpen called with Access.GA_ReadOnly |
| 84 | * Implementations (with the exception of transactional jpip) |
| 85 | * are read only |
| 86 | */ |
| 87 | static GDALDataset *GDALAsyncDatasetOpen(GDALOpenInfo *poOpenInfo); |
| 88 | |
| 89 | }; |
| 90 | |
| 91 | /*********************************************************************/ |
| 92 | /* GDALAsyncRasterBand */ |
| 93 | /*********************************************************************/ |
| 94 | class CPL_DLL GDALAsyncRasterBand : public GDALPamRasterBand { |
| 95 | friend class GDALAsyncDataset; |
| 96 | public: |
| 97 | GDALAsyncRasterBand(GDALAsyncDataset *parent_dataset, int band, double scale); |
| 98 | virtual GDALRasterIOContext *CreateRasterIOContext(GDALRWFlag eRWFlag, |
| 99 | int nDSXOff, int nDSYOff, |
| 100 | int nDSXSize, int nDSYSize, |
| 101 | int nBXSize, int nBYSize, |
| 102 | GDALDataType eBDataType, |
| 103 | int nPixelSpace, int nLineSpace); |
| 104 | virtual ~GDALAsyncRasterBand(){}; |
| 105 | }; |
| 106 | |
| 107 | class CPL_DLL GDALRasterIOContext |
| 108 | { |
| 109 | private: |
| 110 | AsyncStatus status; |
| 111 | |
| 112 | public: |
| 113 | /** |
| 114 | * Returns the current status of the asynchronous process |
| 115 | * This value cannot be modified by the calling function, and |
| 116 | * the value is true at the time of the function being called. |
| 117 | */ |
| 118 | AsyncStatus GetStatus(){return status;} |
| 119 | |
| 120 | virtual CPLErr SetView(int xOff, int yOff, int xSize, int ySize); |
| 121 | virtual CPLErr ReadNextBlock(void *pData, char **papszOptions); |
| 122 | virtual CPLErr RasterIO(void *pData, int nTimeoutMilliseconds = -1, char **papszOptions); |
| 123 | virtual void CancelIO(); |
| 124 | }; |
| 125 | |
| 126 | |
| 127 | }}} |
| 128 | |
| 129 | '''GDALAsyncDataset.cpp''' |
| 130 | {{{ |
| 131 | #include "GDALAsyncDataset.h" |
| 132 | |
| 133 | /************************************************************************/ |
| 134 | /* ==================================================================== */ |
| 135 | /* GDALAsyncDataset */ |
| 136 | /* ==================================================================== */ |
| 137 | /************************************************************************/ |
| 138 | |
| 139 | /** |
| 140 | * \class GDALAsyncDataset "GDALAsyncDataset.h" |
| 141 | * |
| 142 | */ |
| 143 | |
| 144 | /************************************************************************/ |
| 145 | /* CreateRasterIOContext() */ |
| 146 | /************************************************************************/ |
| 147 | |
| 148 | /** |
| 149 | * Create an IOContext for asynchronous operation. The driver will initiate the transfer to the server |
| 150 | * and set the current status for the user to read, @see AsyncStatus |
| 151 | * |
| 152 | * @param eRWFlag Read/Write flag, most format driver implementations will be Access.GA_ReadOnly. |
| 153 | * JPIP transactional services will support GA_Update |
| 154 | * @param nDSXOff request x offset into the server image at resolution 1:1, |
| 155 | top left corner is the image origin |
| 156 | * @param nDSYOff request y offset into the server image at resolution 1:1, |
| 157 | top left corner is the image origin |
| 158 | * @param nDSXSize request width of the server image at resolution 1:1 |
| 159 | * @param nDSYSize request height of the server image at resolution 1:1 |
| 160 | * @param nBXSize Requested frame width, JPIP will select the resolution level that best fits nBXSize, nBYSize |
| 161 | * @param nBYSize Requested frame height, JPIP will select the resolution level that best fits nBXSize, nBYSize |
| 162 | * @param eBDataType |
| 163 | * @param nBandCount |
| 164 | * @param panBandMap |
| 165 | * @param nPixelSpace |
| 166 | * @param nLineSpace |
| 167 | * @param nBandSpace |
| 168 | */ |
| 169 | GDALRasterIOContext *GDALAsyncDataset::CreateRasterIOContext(GDALRWFlag eRWFlag, |
| 170 | int nDSXOff, int nDSYOff, |
| 171 | int nDSXSize, int nDSYSize, |
| 172 | int nBXSize, int nBYSize, |
| 173 | GDALDataType eBDataType, |
| 174 | int nBandCount, int* panBandMap, |
| 175 | int nPixelSpace, int nLineSpace, int nBandSpace) |
| 176 | { |
| 177 | return 0; |
| 178 | } |
| 179 | |
| 180 | /************************************************************************/ |
| 181 | /* ==================================================================== */ |
| 182 | /* GDALAsyncRasterBand */ |
| 183 | /* ==================================================================== */ |
| 184 | /************************************************************************/ |
| 185 | |
| 186 | /** |
| 187 | * \class GDALAsyncRasterBand "GDALAsyncDataset.h" |
| 188 | * |
| 189 | */ |
| 190 | |
| 191 | /************************************************************************/ |
| 192 | /* CreateRasterIOContext() */ |
| 193 | /************************************************************************/ |
| 194 | |
| 195 | /** |
| 196 | * Create an IOContext for asynchronous operation. The driver will initiate the transfer to the server |
| 197 | * and set the current status for the user to read, @see AsyncStatus |
| 198 | * |
| 199 | * @param eRWFlag Read/Write flag, most format driver implementations will be Access.GA_ReadOnly. |
| 200 | * JPIP transactional services will support GA_Update |
| 201 | * @param nDSXOff request x offset into the server image at resolution 1:1, |
| 202 | top left corner is the image origin |
| 203 | * @param nDSYOff request y offset into the server image at resolution 1:1, |
| 204 | top left corner is the image origin |
| 205 | * @param nDSXSize request width of the server image at resolution 1:1 |
| 206 | * @param nDSYSize request height of the server image at resolution 1:1 |
| 207 | * @param nBXSize Requested frame width, JPIP will select the resolution level that best fits nBXSize, nBYSize |
| 208 | * @param nBYSize Requested frame height, JPIP will select the resolution level that best fits nBXSize, nBYSize |
| 209 | * @param eBDataType |
| 210 | * @param nPixelSpace |
| 211 | * @param nLineSpace |
| 212 | */ |
| 213 | GDALRasterIOContext *GDALAsyncRasterBand::CreateRasterIOContext(GDALRWFlag eRWFlag, |
| 214 | int nDSXOff, int nDSYOff, |
| 215 | int nDSXSize, int nDSYSize, |
| 216 | int nBXSize, int nBYSize, |
| 217 | GDALDataType eBDataType, |
| 218 | int nPixelSpace, int nLineSpace) |
| 219 | { |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | /************************************************************************/ |
| 224 | /* ==================================================================== */ |
| 225 | /* GDALRasterIOContext */ |
| 226 | /* ==================================================================== */ |
| 227 | /************************************************************************/ |
| 228 | |
| 229 | /** |
| 230 | * \class GDALRasterIOContext "GDALAsyncDataset.h" |
| 231 | * |
| 232 | */ |
| 233 | |
| 234 | /** |
| 235 | * Set the currently request window into the dataset on the server at 1:1 resolution |
| 236 | * |
| 237 | * @param xOff request x offset into the server image at resolution 1:1, |
| 238 | top left corner is the image origin |
| 239 | * @param yOff request y offset into the server image at resolution 1:1, |
| 240 | top left corner is the image origin |
| 241 | * @param xSize request width of the server image at resolution 1:1 |
| 242 | * @param ySize request height of the server image at resolution 1:1 |
| 243 | */ |
| 244 | CPLErr GDALRasterIOContext::SetView(int xOff, int yOff, int xSize, int ySize) |
| 245 | { |
| 246 | // return a warning, this method should be overridden |
| 247 | return CE_Warning; |
| 248 | } |
| 249 | |
| 250 | /*************************************************************************/ |
| 251 | /* ===================================================================== */ |
| 252 | /* CancelIO() */ |
| 253 | /* ===================================================================== */ |
| 254 | /*************************************************************************/ |
| 255 | |
| 256 | /** |
| 257 | * Cancel the communication channel to the remote server |
| 258 | * |
| 259 | */ |
| 260 | void GDALRasterIOContext::CancelIO() |
| 261 | { |
| 262 | } |
| 263 | |
| 264 | /*************************************************************************/ |
| 265 | /* ===================================================================== */ |
| 266 | /* ReadNextBlock() */ |
| 267 | /* ===================================================================== */ |
| 268 | /*************************************************************************/ |
| 269 | |
| 270 | /** |
| 271 | * Read the next data block from the driver cache to the remote server |
| 272 | * data type is set in @see CreateRasterIOContext() |
| 273 | * @param pData, data buffer to fill, if the data in the driver cache does not contain a value the buffer will be zero filled |
| 274 | * @param papszOptions options for the driver implementation e.g. Quality="Xxx" to specify maximum jpip quality layers |
| 275 | */ |
| 276 | CPLErr GDALRasterIOContext::ReadNextBlock(void *pData, char **papszOptions) |
| 277 | { |
| 278 | // return a warning, this method should be overridden |
| 279 | return CE_Warning; |
| 280 | } |
| 281 | |
| 282 | /*******************************************************************************/ |
| 283 | /* =========================================================================== */ |
| 284 | /* RasterIO() */ |
| 285 | /* =========================================================================== */ |
| 286 | /*******************************************************************************/ |
| 287 | |
| 288 | /** |
| 289 | * Read a view from the remote image on the server |
| 290 | * @param pData buffer to fill |
| 291 | * @param nTimeoutMilliseconds connection timeout |
| 292 | * @papszOptions options for the driver implementation e.g. Quality="Xxx" to specify maximum jpip quality |
| 293 | */ |
| 294 | CPLErr RasterIO(void *pData, int nTimeoutMilliseconds = -1, char **papszOptions) |
| 295 | { |
| 296 | // return a warning, this method should be overridden |
| 297 | return CE_Warning; |
| 298 | } |
| 299 | }}} |