fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Image / FileIO / OSGDBImageFileType.h
blobb568e7ab62f855871f61e14c62a1172c32d45c38
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGDBIMAGEFILETYPE_H_
40 #define _OSGDBIMAGEFILETYPE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGImageFileIODef.h"
46 #include "OSGImageFileType.h"
48 #include "boost/shared_ptr.hpp"
49 #include "map"
51 OSG_BEGIN_NAMESPACE
53 class DBImageFileType;
55 /*! \ingroup GrpImageFileIODB
56 \nohierarchy
59 class DBHeaderParameter
61 protected:
63 bool _bLastParam;
65 public:
67 DBHeaderParameter(void);
68 virtual ~DBHeaderParameter(void);
70 void setLastParam(void);
71 bool isLastParam (void);
73 virtual void convert(const Char8 *str) = 0;
76 /*! \ingroup GrpImageFileIODB
77 \nohierarchy
80 class DBHeaderIntParameter : public DBHeaderParameter
82 typedef DBHeaderParameter Inherited;
84 protected:
86 UInt32 &_uiParam;
88 public:
90 DBHeaderIntParameter(UInt32 &uiParam);
91 virtual ~DBHeaderIntParameter(void);
93 virtual void convert(const Char8 *str);
96 /*! \ingroup GrpImageFileIODB
97 \nohierarchy
100 class DBHeaderFloatParameter : public DBHeaderParameter
102 typedef DBHeaderParameter Inherited;
104 protected:
106 Real32 &_rParam;
108 public:
110 DBHeaderFloatParameter(Real32 &rParam);
111 virtual ~DBHeaderFloatParameter(void);
113 virtual void convert(const Char8 *str);
116 /*! \ingroup GrpImageFileIODB
117 \nohierarchy
120 struct DBHeader
122 UInt32 uiMagic; //=13048 ::: magic number
123 UInt32 uiXSize; //=%u ::: mandatory width
124 UInt32 uiYSize; //=%u ::: mandatory height for 2+D, 1 for 1D data
125 UInt32 uiZSize; //=%u ::: mandatory depth for 3+D, 1 for 1D and 2D data
126 UInt32 uiTSteps; //=%u ::: mandatory number of time steps for 4D,
127 // 1 for 1D, 2D and 3D data
129 UInt32 uiType; //=%u ::: mandatory cell type: 0 = unsigned byte, 1 =
130 //signed short, 2 = float, 3 = RGB, 4 = RGBA, 5 =
131 //compressed RGB (S3TC DXT1), 6 = compressed RGBA (S3TC
132 //DXT1 with 1-bit alpha)
134 Real32 rSWx; //%g ::: x-component of south west corner (should
135 //%be supplied for tile sets)
136 Real32 rSWy; //=%g ::: y-component of south west corner (should
137 //be supplied for tile sets)
138 Real32 rNWx; //=%g ::: x-component of north west corner (should
139 //be supplied for tile sets)
140 Real32 rNWy; //=%g ::: y-component of north west corner (should
141 //be supplied for tile sets)
143 Real32 rNEx; //=%g ::: x-component of north east corner (should
144 //be supplied for tile sets)
145 Real32 rNEy; //=%g ::: y-component of north east corner (should
146 //be supplied for tile sets)
147 Real32 rSEx; //=%g ::: x-component of south east corner (should
148 //be supplied for tile sets)
149 Real32 rSEy; //=%g ::: y-component of south east corner (should
150 //be supplied for tile sets)
151 Real32 rH0; //=%g ::: base elevation of 3D or 4D data cube
152 Real32 rDh; //=%g ::: height of the 3D or 4D cube
153 Real32 rT0; //=%g ::: starting time of 4D series
154 Real32 rDt; //=%g ::: time step of 4D series
156 Real32 rScaling; //=%g ::: elevation scaling parameter for height fields
157 //(default is 1)
158 Real32 rBias; //=%g ::: elevation bias parameter for height fields
159 //(default is 0)
161 UInt32 uiExtFormat; //=%u ::: external format indicator: a value!=0
162 //triggers conversion hook (default 0, 1 reserved for
163 //JPEG, 2 for PNG)
164 UInt32 uiImplFormat;//implicit format indicator
167 Real32 LLWGS84_rSWx;//%g ::: x-component of south west corner (should
168 //%be supplied for tile sets)
169 Real32 LLWGS84_rSWy;//=%g ::: y-component of south west corner (should
170 //be supplied for tile sets)
171 Real32 LLWGS84_rNWx;//=%g ::: x-component of north west corner (should
172 //be supplied for tile sets)
173 Real32 LLWGS84_rNWy;//=%g ::: y-component of north west corner (should
174 //be supplied for tile sets)
176 Real32 LLWGS84_rNEx;//=%g ::: x-component of north east corner (should
177 //be supplied for tile sets)
178 Real32 LLWGS84_rNEy;//=%g ::: y-component of north east corner (should
179 //be supplied for tile sets)
180 Real32 LLWGS84_rSEx;//=%g ::: x-component of south east corner (should
181 //be supplied for tile sets)
182 Real32 LLWGS84_rSEy;//=%g ::: y-component of south east corner (should
183 //be supplied for tile sets)
185 UInt32 uiBytes; //=%u ::: mandatory byte length of the following
186 //data chunk};
188 typedef std::map<std::string, DBHeaderParameter *> ParameterMap;
190 ParameterMap _mParams;
192 DBHeader(void);
193 ~DBHeader(void);
195 bool read(FILE *pIn);
196 void dump(void ) const;
199 /*! \ingroup GrpImageFileIODB
200 \ingroup GrpLibOSGImageFileIO
203 class OSG_IMGFILEIO_DLLMAPPING DBBlockAccessor : public ImageBlockAccessor
206 /*========================== PUBLIC =================================*/
208 public:
210 typedef ImageBlockAccessor Inherited;
212 /*---------------------------------------------------------------------*/
213 /*! \name Destructor */
214 /*! \{ */
216 virtual ~DBBlockAccessor(void);
218 /*! \} */
219 /*---------------------------------------------------------------------*/
220 /*! \name Read/Write */
221 /*! \{ */
223 virtual bool isOpen(void);
225 /*! \} */
226 /*---------------------------------------------------------------------*/
227 /*! \name Read/Write */
228 /*! \{ */
230 virtual bool readBlockA16(Vec2i vSampleOrigin,
231 Int32 iTextureSize,
232 UInt16 *pTarget,
233 Int32 iTargetSizeBytes);
235 virtual bool readBlockA16(Vec2i vSampleOrigin,
236 Int32 iTextureSize,
237 Int16 *pTarget,
238 Int32 iTargetSizeBytes);
240 /*! \} */
241 /*========================= PROTECTED ===============================*/
243 protected:
245 /*---------------------------------------------------------------------*/
246 /*! \name Default Constructor */
247 /*! \{ */
249 DBBlockAccessor(void);
251 /*! \} */
252 /*---------------------------------------------------------------------*/
253 /*! \name Read/Write */
254 /*! \{ */
256 void open(const Char8 *szFilename);
258 /*! \} */
259 /*---------------------------------------------------------------------*/
260 /*! \name Read/Write */
261 /*! \{ */
263 /*! \} */
264 /*========================== PRIVATE ================================*/
266 private:
268 friend class DBImageFileType;
271 /*! \ingroup GrpImageFileIODB
274 typedef boost::shared_ptr<DBBlockAccessor> DBBlockAccessorPtr;
276 /*! \brief GDAL File Handler. Used to read/write TIFF files.
277 See \ref PageSystemImage for a detailed description.
279 \ingroup GrpImageFileIODB
280 \ingroup GrpLibOSGImageFileIO
283 class OSG_IMGFILEIO_DLLMAPPING DBImageFileType : public ImageFileType
285 /*========================== PUBLIC =================================*/
287 public:
289 /*---------------------------------------------------------------------*/
290 /*! \name Destructor */
291 /*! \{ */
293 virtual ~DBImageFileType(void);
295 /*! \} */
296 /*---------------------------------------------------------------------*/
297 /*! \name Read/Write */
298 /*! \{ */
300 virtual bool read ( Image *pImage,
301 const Char8 *fileName ) ;
303 virtual bool write (const Image *pImage,
304 const Char8 *fileName ) ;
306 virtual bool validateHeader(const Char8 *fileName,
307 bool &implemented);
309 /*! \} */
310 /*---------------------------------------------------------------------*/
311 /*! \name Type */
312 /*! \{ */
314 #if 1
315 virtual ImageBlockAccessorPtr open(const Char8 *fileName);
316 #endif
318 /*! \} */
319 /*========================= PROTECTED ===============================*/
321 protected:
323 /*---------------------------------------------------------------------*/
324 /*! \name Default Constructor */
325 /*! \{ */
327 DBImageFileType (const Char8 *mimeType,
328 const Char8 *suffixArray[],
329 UInt16 suffixByteCount,
330 UInt32 flags );
332 /*! \} */
333 /*---------------------------------------------------------------------*/
334 /*! \name Copy Op */
335 /*! \{ */
337 DBImageFileType (const DBImageFileType &obj);
338 const DBImageFileType &operator =(const DBImageFileType &obj);
340 /*! \} */
341 /*========================== PRIVATE ================================*/
343 private:
345 typedef ImageFileType Inherited;
347 static DBImageFileType _the;
350 typedef DBImageFileType *DBImageFileTypeP;
352 OSG_END_NAMESPACE
354 #endif // _OSGDBIMAGEFILETYPE_H_