| 1 |
// tiff stream interface class definition |
| 2 |
|
| 3 |
#ifndef _TIFF_STREAM_H_ |
| 4 |
#define _TIFF_STREAM_H_ |
| 5 |
|
| 6 |
#include <iostream.h> |
| 7 |
|
| 8 |
#include "tiffio.h" |
| 9 |
|
| 10 |
class TiffStream |
| 11 |
{ |
| 12 |
|
| 13 |
public: |
| 14 |
// ctor/dtor |
| 15 |
TiffStream(); |
| 16 |
~TiffStream(); |
| 17 |
|
| 18 |
public: |
| 19 |
enum SeekDir |
| 20 |
{ |
| 21 |
beg, |
| 22 |
cur, |
| 23 |
end, |
| 24 |
}; |
| 25 |
|
| 26 |
public: |
| 27 |
// factory methods |
| 28 |
TIFF *makeFileStream(iostream *str); |
| 29 |
TIFF *makeFileStream(istream *str); |
| 30 |
TIFF *makeFileStream(ostream *str); |
| 31 |
|
| 32 |
public: |
| 33 |
// tiff client methods |
| 34 |
static tsize_t read(thandle_t fd, tdata_t buf, tsize_t size); |
| 35 |
static tsize_t write(thandle_t fd, tdata_t buf, tsize_t size); |
| 36 |
static toff_t seek(thandle_t fd, toff_t offset, int origin); |
| 37 |
static toff_t size(thandle_t fd); |
| 38 |
static int close(thandle_t fd); |
| 39 |
static int map(thandle_t fd, tdata_t *phase, toff_t *psize); |
| 40 |
static void unmap(thandle_t fd, tdata_t base, tsize_t size); |
| 41 |
|
| 42 |
public: |
| 43 |
// query method |
| 44 |
TIFF *getTiffHandle() const { return m_tif; } |
| 45 |
unsigned int getStreamLength() { return m_streamLength; } |
| 46 |
|
| 47 |
private: |
| 48 |
// internal methods |
| 49 |
unsigned int getSize(thandle_t fd); |
| 50 |
unsigned int tell(thandle_t fd); |
| 51 |
bool seekInt(thandle_t fd, unsigned int offset, int origin); |
| 52 |
bool isOpen(thandle_t fd); |
| 53 |
|
| 54 |
private: |
| 55 |
thandle_t m_this; |
| 56 |
TIFF *m_tif; |
| 57 |
static const char *m_name; |
| 58 |
istream *m_inStream; |
| 59 |
ostream *m_outStream; |
| 60 |
iostream *m_ioStream; |
| 61 |
int m_streamLength; |
| 62 |
}; |
| 63 |
|
| 64 |
#endif // _TIFF_STREAM_H_ |