svn-gvsig-desktop / tags / v1_1_1_Build_1019 / libraries / libjni-mrsid / include / support / lt_ioBufferedStream.h @ 32257
History | View | Annotate | Download (2.35 KB)
1 |
/* $Id: lt_ioBufferedStream.h 3539 2006-01-09 12:23:20Z nacho $ */
|
---|---|
2 |
/* //////////////////////////////////////////////////////////////////////////
|
3 |
// //
|
4 |
// This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
|
5 |
// Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
|
6 |
// prohibited. Access to and use of this code is permitted only under //
|
7 |
// license from LizardTech, Inc. Portions of the code are protected by //
|
8 |
// US and foreign patents and other filings. All Rights Reserved. //
|
9 |
// //
|
10 |
////////////////////////////////////////////////////////////////////////// */
|
11 |
/* PUBLIC */
|
12 |
|
13 |
#ifndef LT_IO_BUFFERED_STREAM_H
|
14 |
#define LT_IO_BUFFERED_STREAM_H
|
15 |
|
16 |
#include "lt_ioStreamInf.h" |
17 |
|
18 |
LT_BEGIN_NAMESPACE( LizardTech ) |
19 |
|
20 |
class LTIOBufPage; |
21 |
class LTIOBufPageCache; |
22 |
|
23 |
/**
|
24 |
* Stream which wraps an array of bytes in memory.
|
25 |
*
|
26 |
* The buffer is of a fixed size and does not grow or shrink.
|
27 |
*/
|
28 |
class LTIOBufferedStream : public LTIOStreamInf |
29 |
{ |
30 |
public:
|
31 |
LTIOBufferedStream(); |
32 |
virtual ~LTIOBufferedStream(); |
33 |
|
34 |
/**
|
35 |
* Initializes the stream
|
36 |
*
|
37 |
* @param src source stream; this instance takes ownership of it
|
38 |
* @param pageSize size of each page in bytes
|
39 |
* @param numPages number of pages to keep cached in memory
|
40 |
* @param tempDir temp directory to store unused pages; this instance
|
41 |
* does not clean them up
|
42 |
*/
|
43 |
virtual LT_STATUS initialize( LTIOStreamInf* src, |
44 |
lt_uint32 pageSize=1024,
|
45 |
lt_uint32 numPages = 10,
|
46 |
const char* tempDir = 0L); |
47 |
|
48 |
|
49 |
virtual bool isEOF();
|
50 |
virtual bool isOpen();
|
51 |
virtual LT_STATUS open(); |
52 |
virtual LT_STATUS close(); |
53 |
virtual lt_uint32 read( lt_uint8 *pDest, lt_uint32 numBytes ); |
54 |
virtual lt_uint32 write( const lt_uint8 *pSrc, lt_uint32 numBytes );
|
55 |
virtual LT_STATUS seek( lt_int64 offset, LTIOSeekDir origin ); |
56 |
virtual lt_int64 tell(); |
57 |
virtual LTIOStreamInf* duplicate(); |
58 |
virtual LT_STATUS getLastError() const;
|
59 |
virtual const char* getID() const; |
60 |
|
61 |
private:
|
62 |
const LTIOBufPage* getPage( lt_uint64 pageIndex );
|
63 |
|
64 |
protected:
|
65 |
lt_uint32 m_pageSize; |
66 |
lt_uint32 m_numPages; |
67 |
LTIOBufPageCache* m_buffer; |
68 |
LTIOStreamInf* m_src; |
69 |
lt_uint64 m_cur; |
70 |
bool m_eof;
|
71 |
char* m_tempDir;
|
72 |
}; |
73 |
|
74 |
|
75 |
|
76 |
LT_END_NAMESPACE( LizardTech ) |
77 |
|
78 |
|
79 |
#endif // LT_IO_BUFFERED_STREAM_H |