svn-gvsig-desktop / tags / v1_1_2_Build_1043 / libraries / libjni-mrsid / include / support / lt_ioCallbackStream.h @ 43637
History | View | Annotate | Download (4.44 KB)
1 | 662 | igbrotru | /* $Id$ */
|
---|---|---|---|
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_CALLBACK_STREAM_H
|
||
14 | #define LT_IO_CALLBACK_STREAM_H
|
||
15 | |||
16 | #include "lt_ioCallbackStreamTypes.h" |
||
17 | #include "lt_ioStreamInf.h" |
||
18 | |||
19 | #if defined(LT_COMPILER_MS)
|
||
20 | #pragma warning(push,4) |
||
21 | #endif
|
||
22 | |||
23 | LT_BEGIN_NAMESPACE( LizardTech ) |
||
24 | |||
25 | |||
26 | /**
|
||
27 | * Stream driven entirely by user-defined callbacks
|
||
28 | *
|
||
29 | * This class implements a stream whose operations -- read(), write(), open(),
|
||
30 | * close(), etc -- are all defined by functions passed in from the user.
|
||
31 | *
|
||
32 | * This class can be used as an alternative to deriving custom stream classes
|
||
33 | * from LTIOStreamInf. This class also forms the basis for the C-callable
|
||
34 | * stream defined in lt_ioCStream.h.
|
||
35 | */
|
||
36 | class LTIOCallbackStream : public LTIOStreamInf |
||
37 | { |
||
38 | public:
|
||
39 | LTIOCallbackStream(); |
||
40 | |||
41 | virtual ~LTIOCallbackStream(); |
||
42 | |||
43 | /**
|
||
44 | * initialize
|
||
45 | *
|
||
46 | * The parameters to this function are a set of function pointers
|
||
47 | * which implement all the required operations needed to support
|
||
48 | * a stream. Their semantics exactly mirror the semantics of the
|
||
49 | * corresponding member functions in LTIOStreamInf.
|
||
50 | *
|
||
51 | * The \a user parameter is a pointer to a user-defined area
|
||
52 | * containing information about the stream itself, e.g. the
|
||
53 | * filename and a FILE*. This pointer is passed as the first
|
||
54 | * argument to each of the user's stream functions. This class
|
||
55 | * never attempts to interpret this data directly.
|
||
56 | *
|
||
57 | * Note that the implementation of the \a duplicate function
|
||
58 | * is required to create a new copy of this user-defined data by
|
||
59 | * whatever means appropriate. The user retains ownership of the
|
||
60 | * copied user data.
|
||
61 | *
|
||
62 | * @param open pointer to user's open function
|
||
63 | * @param close pointer to user's close function
|
||
64 | * @param read pointer to user's read function
|
||
65 | * @param write pointer to user's write function
|
||
66 | * @param seek pointer to user's seek function
|
||
67 | * @param tell pointer to user's tell function
|
||
68 | * @param isEOF pointer to user's isEOF function
|
||
69 | * @param isOpen pointer to user's isOpen function
|
||
70 | * @param duplicate pointer to user's duplicate function
|
||
71 | * @param user pointer to user-defined stream data
|
||
72 | * @return status code indicating success or failure
|
||
73 | */
|
||
74 | virtual LT_STATUS initialize(LTIOCallbackStream_Open open, |
||
75 | LTIOCallbackStream_Close close, |
||
76 | LTIOCallbackStream_Read read, |
||
77 | LTIOCallbackStream_Write write, |
||
78 | LTIOCallbackStream_Seek seek, |
||
79 | LTIOCallbackStream_Tell tell, |
||
80 | LTIOCallbackStream_IsEOF isEOF, |
||
81 | LTIOCallbackStream_IsOpen isOpen, |
||
82 | LTIOCallbackStream_Duplicate duplicate, |
||
83 | void* user);
|
||
84 | |||
85 | virtual bool isEOF();
|
||
86 | virtual bool isOpen();
|
||
87 | |||
88 | virtual LT_STATUS open(); |
||
89 | virtual LT_STATUS close(); |
||
90 | |||
91 | virtual lt_uint32 read( lt_uint8 *pDest, lt_uint32 numBytes ); |
||
92 | virtual lt_uint32 write( const lt_uint8 *pSrc, lt_uint32 numBytes );
|
||
93 | |||
94 | virtual LT_STATUS seek( lt_int64 offset, LTIOSeekDir origin ); |
||
95 | virtual lt_int64 tell(); |
||
96 | |||
97 | virtual LTIOStreamInf* duplicate(); |
||
98 | virtual LT_STATUS getLastError() const;
|
||
99 | virtual const char* getID() const; |
||
100 | |||
101 | private:
|
||
102 | LTIOCallbackStream_Open m_open; |
||
103 | LTIOCallbackStream_Close m_close; |
||
104 | LTIOCallbackStream_Read m_read; |
||
105 | LTIOCallbackStream_Write m_write; |
||
106 | LTIOCallbackStream_Seek m_seek; |
||
107 | LTIOCallbackStream_Tell m_tell; |
||
108 | LTIOCallbackStream_IsEOF m_isEOF; |
||
109 | LTIOCallbackStream_IsOpen m_isOpen; |
||
110 | LTIOCallbackStream_Duplicate m_duplicate; |
||
111 | |||
112 | void* m_user;
|
||
113 | }; |
||
114 | |||
115 | LT_END_NAMESPACE( LizardTech ) |
||
116 | |||
117 | #if defined(LT_COMPILER_MS)
|
||
118 | #pragma warning(pop)
|
||
119 | #endif
|
||
120 | |||
121 | #endif // LT_IO_CALLBACK_STREAM_H |