00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef DATAREQUEST_H 00011 #define DATAREQUEST_H 00012 00013 #include "DimensionDescriptor.h" 00014 #include "TypesFile.h" 00015 00016 class RasterDataDescriptor; 00017 00018 /** 00019 * DataRequest is a class used to specify how to get access to data 00020 * through a DataAccessor. 00021 * 00022 * To use, create an instance with the ObjectFactory or a FactoryResource. 00023 * Set the fields for which the defaults are insufficient. Pass in the 00024 * instance to RasterElement::getDataAccessor. 00025 * 00026 * @see RasterElement, RasterDataDescriptor, DataAccessor 00027 */ 00028 class DataRequest 00029 { 00030 public: 00031 /** 00032 * Creates and returns a copy of the object. 00033 * 00034 * @return A new DataRequest, which is a copy of the existing one. 00035 * The caller is responsible for ensuring deletion of the 00036 * returned object. 00037 */ 00038 virtual DataRequest *copy() const = 0; 00039 00040 /** 00041 * Determine whether the DataRequest is valid for the given 00042 * RasterDataDescriptor. 00043 * 00044 * The validation will most likely fail if the DataRequest has not 00045 * had polish() called on it. 00046 * 00047 * Plug-ins generally do not need to call this function. 00048 * 00049 * @param pDescriptor 00050 * The descriptor to validate against. 00051 * 00052 * @return True if the DataRequest is a valid request for the 00053 * descriptor, false otherwise. 00054 */ 00055 virtual bool validate(const RasterDataDescriptor *pDescriptor) const = 0; 00056 00057 /** 00058 * Polish the DataRequest for the given RasterDataDescriptor. 00059 * 00060 * This function will apply any defaults to the actual value as 00061 * appropriate for the given descriptor. This function should be called 00062 * before validate(). 00063 * 00064 * The return values of accessor functions are not valid 00065 * until this function has been called. 00066 * 00067 * Plug-ins generally do not need to call this function, as the core 00068 * will call it when appropriate. 00069 * 00070 * @param pDescriptor 00071 * The descriptor from which to apply defaults. 00072 * 00073 * @return True if the operation succeeded, false otherwise. 00074 */ 00075 virtual bool polish(const RasterDataDescriptor *pDescriptor) = 0; 00076 00077 /** 00078 * Get the version required to support this request. 00079 * 00080 * @param pDescriptor 00081 * The descriptor to use to determine required version. 00082 * 00083 * @return The smallest version number which can properly use this 00084 * DataRequest. Currently always returns 1. 00085 * 00086 * @see RasterPager::getSupportedRequestVersion() 00087 */ 00088 virtual int getRequestVersion(const RasterDataDescriptor *pDescriptor) const = 0; 00089 00090 /** 00091 * Get the requested interleave. 00092 * 00093 * This defaults to the interleave of the associated RasterElement. 00094 * 00095 * @return The requested interleave. If the interleave has not been set, 00096 * either with polish() or setInterleaveFormat(), the return 00097 * value is undefined. 00098 */ 00099 virtual InterleaveFormatType getInterleaveFormat() const = 0; 00100 00101 /** 00102 * Set the requested interleave. 00103 * 00104 * @param interleave 00105 * The requested interleave. 00106 */ 00107 virtual void setInterleaveFormat(InterleaveFormatType interleave) = 0; 00108 00109 /** 00110 * Get the requested start row. 00111 * 00112 * This defaults to the first row in the RasterElement. 00113 * 00114 * @return The requested start row. 00115 * 00116 * @see setRows() 00117 */ 00118 virtual DimensionDescriptor getStartRow() const = 0; 00119 00120 /** 00121 * Get the requested stop row. 00122 * 00123 * This defaults to the last row in the RasterElement. 00124 * 00125 * @return The requested stop row. 00126 * 00127 * @see setRows() 00128 */ 00129 virtual DimensionDescriptor getStopRow() const = 0; 00130 00131 /** 00132 * Get the request concurrent rows. 00133 * 00134 * This defaults to 1. 00135 * 00136 * @return The requested number of concurrent rows. 00137 * 00138 * @see setRows() 00139 */ 00140 virtual unsigned int getConcurrentRows() const = 0; 00141 00142 /** 00143 * Set the start, stop, and concurrent rows. 00144 * 00145 * @param startRow 00146 * The requested start row. This may be an invalid DimensionDescriptor 00147 * to apply the default. 00148 * @param stopRow 00149 * The requested stop row. This may be an invalid DimensionDescriptor 00150 * to apply the default. 00151 * @param concurrentRows 00152 * The requested number of concurrent rows. This may be 0 to apply 00153 * the default. 00154 * 00155 * @see getStartRow(), getStopRow(), getConcurrentRows() 00156 */ 00157 virtual void setRows(DimensionDescriptor startRow, DimensionDescriptor stopRow, unsigned int concurrentRows = 0) = 0; 00158 00159 /** 00160 * Get the requested start column. 00161 * 00162 * This defaults to the first column in the RasterElement. 00163 * 00164 * @return The requested start column. 00165 * 00166 * @see setColumns() 00167 */ 00168 virtual DimensionDescriptor getStartColumn() const = 0; 00169 00170 /** 00171 * Get the requested stop column. 00172 * 00173 * This defaults to the last column in the RasterElement. 00174 * 00175 * @return The requested stop column. 00176 * 00177 * @see setColumn() 00178 */ 00179 virtual DimensionDescriptor getStopColumn() const = 0; 00180 00181 /** 00182 * Get the request concurrent columns. 00183 * 00184 * This defaults to the number of columns between start and stop. 00185 * 00186 * @return The requested number of concurrent column. 00187 * 00188 * @see setColumn() 00189 */ 00190 virtual unsigned int getConcurrentColumns() const = 0; 00191 00192 /** 00193 * Set the start, stop, and concurrent column. 00194 * 00195 * @param startColumn 00196 * The requested start column. This may be an invalid DimensionDescriptor 00197 * to apply the default. 00198 * @param stopColumn 00199 * The requested stop column. This may be an invalid DimensionDescriptor 00200 * to apply the default. 00201 * @param concurrentColumns 00202 * The requested number of concurrent columns. This may be 0 to apply 00203 * the default. 00204 * 00205 * @see getStartColumn(), getStopColumn(), getConcurrentColumns() 00206 */ 00207 virtual void setColumns(DimensionDescriptor startColumn, DimensionDescriptor stopColumn, unsigned int concurrentColumns = 0) = 0; 00208 00209 /** 00210 * Get the requested start band. 00211 * 00212 * This defaults to the first band in the RasterElement. 00213 * 00214 * @return The requested start band. 00215 * 00216 * @see setBands() 00217 */ 00218 virtual DimensionDescriptor getStartBand() const = 0; 00219 00220 /** 00221 * Get the requested stop band. 00222 * 00223 * This defaults to the last band in the RasterElement for BIP and BIL data, or 00224 * the requested start band for BSQ data. 00225 * 00226 * @return The requested stop band. 00227 * 00228 * @see setBands() 00229 */ 00230 virtual DimensionDescriptor getStopBand() const = 0; 00231 00232 /** 00233 * Get the request concurrent bands. 00234 * 00235 * This defaults to the number of bands between the start and stop. 00236 * 00237 * @return The requested number of concurrent bands. 00238 * 00239 * @see setBands() 00240 */ 00241 virtual unsigned int getConcurrentBands() const = 0; 00242 00243 /** 00244 * Set the start, stop, and concurrent bands. 00245 * 00246 * @param startBand 00247 * The requested start band. This may be an invalid DimensionDescriptor 00248 * to apply the default. 00249 * @param stopBand 00250 * The requested stop band. This may be an invalid DimensionDescriptor 00251 * to apply the default. 00252 * @param concurrentBands 00253 * The requested number of concurrent bands. This may be 0 to apply 00254 * the default. 00255 * 00256 * @warning BSQ only supports accessing a single band at a time. 00257 * 00258 * @see getStartBand(), getStopBand(), getConcurrentBands() 00259 */ 00260 virtual void setBands(DimensionDescriptor startBand, DimensionDescriptor stopBand, unsigned int concurrentBands = 0) = 0; 00261 00262 /** 00263 * Get whether the request is for writable data. 00264 * 00265 * This defaults to false. 00266 * 00267 * @return True if the request is for writable data, false otherwise. 00268 * 00269 * @see setWritable() 00270 */ 00271 virtual bool getWritable() const = 0; 00272 00273 /** 00274 * Set whether the request is for writable data. 00275 * 00276 * It is undefined what will happen if data is written 00277 * from a DataAccessor requested with an unwritable DataRequest. 00278 * Depending on the circumstances, it may apply the written data, 00279 * ignore the written data, crash, or lead to other undesirable results. 00280 * \b Always set the request to writable if you want to write to a RasterElement. 00281 * 00282 * @param writable 00283 * True if the request is for writable data, false otherwise. 00284 * 00285 * @see getWritable(), RasterElement::updateData() 00286 */ 00287 virtual void setWritable(bool writable) = 0; 00288 00289 protected: 00290 /** 00291 * This should be destroyed by calling ObjectFactory::destroyObject. 00292 */ 00293 virtual ~DataRequest() {} 00294 }; 00295 00296 #endif