1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | //***************************************************************************** |
5 | // StgTiggerStream.h |
6 | // |
7 | |
8 | // |
9 | // TiggerStream is the companion to the TiggerStorage CoClass. It handles the |
10 | // streams managed inside of the storage and does the direct file i/o. |
11 | // |
12 | //***************************************************************************** |
13 | #ifndef __StgTiggerStream_h__ |
14 | #define __StgTiggerStream_h__ |
15 | |
16 | |
17 | |
18 | #include "stgtiggerstorage.h" // Data definitions. |
19 | |
20 | enum |
21 | { |
22 | STREAM_DATA_NAME |
23 | }; |
24 | |
25 | |
26 | class TiggerStorage; |
27 | |
28 | |
29 | class TiggerStream : |
30 | public IStream |
31 | { |
32 | public: |
33 | TiggerStream() : |
34 | m_pStorage(0), |
35 | m_cRef(1) |
36 | {} |
37 | |
38 | virtual ~TiggerStream() {} |
39 | |
40 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *pp) |
41 | { return (BadError(E_NOTIMPL)); } |
42 | virtual ULONG STDMETHODCALLTYPE AddRef() |
43 | { return InterlockedIncrement(&m_cRef); } |
44 | virtual ULONG STDMETHODCALLTYPE Release() |
45 | { |
46 | ULONG cRef; |
47 | if ((cRef = InterlockedDecrement(&m_cRef)) == 0) |
48 | delete this; |
49 | return (cRef); |
50 | } |
51 | |
52 | // IStream |
53 | virtual HRESULT STDMETHODCALLTYPE Read( |
54 | void *pv, |
55 | ULONG cb, |
56 | ULONG *pcbRead); |
57 | |
58 | virtual HRESULT STDMETHODCALLTYPE Write( |
59 | const void *pv, |
60 | ULONG cb, |
61 | ULONG *pcbWritten); |
62 | |
63 | virtual HRESULT STDMETHODCALLTYPE Seek( |
64 | LARGE_INTEGER dlibMove, |
65 | DWORD dwOrigin, |
66 | ULARGE_INTEGER *plibNewPosition); |
67 | |
68 | virtual HRESULT STDMETHODCALLTYPE SetSize( |
69 | ULARGE_INTEGER libNewSize); |
70 | |
71 | virtual HRESULT STDMETHODCALLTYPE CopyTo( |
72 | IStream *pstm, |
73 | ULARGE_INTEGER cb, |
74 | ULARGE_INTEGER *pcbRead, |
75 | ULARGE_INTEGER *pcbWritten); |
76 | |
77 | virtual HRESULT STDMETHODCALLTYPE Commit( |
78 | DWORD grfCommitFlags); |
79 | |
80 | virtual HRESULT STDMETHODCALLTYPE Revert( void); |
81 | |
82 | virtual HRESULT STDMETHODCALLTYPE LockRegion( |
83 | ULARGE_INTEGER libOffset, |
84 | ULARGE_INTEGER cb, |
85 | DWORD dwLockType); |
86 | |
87 | virtual HRESULT STDMETHODCALLTYPE UnlockRegion( |
88 | ULARGE_INTEGER libOffset, |
89 | ULARGE_INTEGER cb, |
90 | DWORD dwLockType); |
91 | |
92 | virtual HRESULT STDMETHODCALLTYPE Stat( |
93 | STATSTG *pstatstg, |
94 | DWORD grfStatFlag); |
95 | |
96 | virtual HRESULT STDMETHODCALLTYPE Clone( |
97 | IStream **ppstm); |
98 | |
99 | |
100 | HRESULT Init( // Return code. |
101 | TiggerStorage *pStorage, // Parent storage. |
102 | LPCSTR szStream); // Stream name. |
103 | |
104 | ULONG GetStreamSize(); |
105 | |
106 | private: |
107 | TiggerStorage *m_pStorage; // Our parent storage. |
108 | char m_rcStream[MAXSTREAMNAME]; // Name of the stream. |
109 | LONG m_cRef; // Ref count. |
110 | }; |
111 | |
112 | #endif // __StgTiggerStream_h__ |
113 | |