convert line ends
[canaan.git] / prj / tech / libsrc / namedres / resbase.h
blob4aba37a8a1b8e265046e413e04f1698f1f19d3a1
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // $Header: x:/prj/tech/libsrc/namedres/RCS/resbase.h 1.11 1970/01/01 00:00:00 TOML Exp $
4 //
5 // Template for creating resource types from.
6 //
8 #ifndef __RESBASE_H
9 #define __RESBASE_H
11 #pragma once
13 #include <resapi.h>
14 #include <reshelp.h>
15 #include <reshack.h>
16 #include <resthred.h>
18 #pragma pack(4)
20 //////////////////////////////////////////////////////////////////////////
22 // @NOTE: It is *essential* that INTERFACE be IRes or a descendent thereof.
23 // Strange and mysterious things may happen otherwise...
26 #undef INTERFACE
28 template <class INTERFACE, const GUID * pIID_INTERFACE>
29 class cResourceBase : public IResHack,
30 public IResControl,
31 public INTERFACE
33 public:
34 cResourceBase(IStore *pStore,
35 const char *pName,
36 IResType *pType);
37 virtual ~cResourceBase();
39 virtual void OnFinalRelease()
43 STDMETHODIMP_(ULONG) AddRef()
45 return __m_ulRefs.AddRef();
48 STDMETHODIMP_(ULONG) Release()
50 if (__m_ulRefs.Release())
51 return __m_ulRefs;
53 OnFinalRelease();
55 delete this;
57 return 0;
60 STDMETHOD (QueryInterface)(REFIID id, void ** ppI);
62 //////////
64 // IRes methods
66 STDMETHOD_(void *, Lock) ();
67 STDMETHOD_(void, Unlock) ();
68 STDMETHOD_(unsigned, GetLockCount)();
70 STDMETHOD_(IResType *, GetType) ();
71 STDMETHOD_(const char *, GetName) ();
72 STDMETHOD_(void, GetCanonPath) (char **ppPath);
73 STDMETHOD_(void, GetCanonPathName) (char **ppPathname);
74 STDMETHOD_(IStore *, GetCanonStore) ();
75 STDMETHOD_(void, GetVariant) (char **ppVariantPath);
76 STDMETHOD_(void, GetStreamName) (BOOL bFullpath, char **ppPathname);
78 STDMETHOD_(void *, DataPeek) ();
79 STDMETHOD_(BOOL, Drop) ();
80 STDMETHOD_(long, GetSize) ();
81 STDMETHOD_(void *, Extract) (void *pBuf);
82 STDMETHOD_(void *, PreLoad) ();
83 // Grab data from file; no memory management. Return number of bytes read.
84 STDMETHOD_(int, ExtractPartial) (const long nStart,
85 const long nEnd,
86 void *pBuf);
87 STDMETHOD_(void, ExtractBlocks) (void *pBuf,
88 const long nSize,
89 tResBlockCallback,
90 void *pCallbackData);
92 STDMETHOD_(BOOL, AsyncLock) (const int nPriority);
93 STDMETHOD_(BOOL, AsyncExtract) (const int nPriority,
94 void *pBuf,
95 const long bufSize);
96 STDMETHOD_(BOOL, AsyncPreload) ();
97 STDMETHOD_(BOOL, IsAsyncFulfilled) ();
98 STDMETHOD(AsyncKill) ();
99 STDMETHOD(GetAsyncResult) (void **ppResult);
101 STDMETHOD_(void, SetAppData) (DWORD AppData);
102 STDMETHOD_(DWORD, GetAppData) ();
104 //////////
106 // IResHack methods
108 STDMETHOD_(void, SetData) (void *pNewData);
109 STDMETHOD_(BOOL, HasSetData) ();
111 //////////
113 // IResControl methods
115 STDMETHOD_(BOOL, SetStore) (IStore *pStore);
116 STDMETHOD_(IStore *, GetStore) ();
117 STDMETHOD_(void, SetName) (const char *pNewName);
118 STDMETHOD_(void, AllowStorageReset) (BOOL);
119 STDMETHOD_(void, SetCanonStore) (IStore *pCanonStore);
121 STDMETHOD_(void *, LoadData) (ulong * pSize,
122 ulong * pTimestamp,
123 IResMemOverride * pResMem);
124 STDMETHOD_(BOOL, FreeData) (void *pData,
125 ulong nSize,
126 IResMemOverride *pResMem);
127 STDMETHOD_(IStoreStream *, OpenStream) ();
129 STDMETHOD_(char **, GetTranslatableTypes)(/* OUT */ int *pnTypes);
130 STDMETHOD_(void *, LoadTranslation)(void *pOldData,
131 long nOldSize,
132 const char *pOldTypeName,
133 /* OUT */ BOOL *pAllocated,
134 /* OUT */ ulong *pSize,
135 IResMemOverride *pResMem);
137 STDMETHOD_(void, SetManData) (DWORD ManData);
138 STDMETHOD_(DWORD, GetManData) ();
140 protected:
141 //////////
143 // Data members
145 unsigned long m_ulRefs;
147 // @TBD (toml 04-21-98): should these be ordered so most commonly used is first for efficiency?
148 // @TBD (toml 04-21-98): again, probably better served by consolodating all flags into an unsigned "flags" field
149 BOOL m_bAllowStorageReset;
151 IResManHelper *m_pResMan;// @TBD (toml 04-21-98): this could be a static?
152 IStore * m_pStore;
153 IStore * m_pCanonStore;
155 BOOL m_bDoingAsynch;
157 char * m_pName;
158 char * m_pExt;
160 IResType * m_pType;
162 // Set by the application, if desired.
163 DWORD m_AppData;
165 // Set by the Resource Manager, if desired.
166 DWORD m_ManData;
168 // Used for multiple calls to ExtractPartial so that streams don't have to
169 // be reopened each time.
170 IStoreStream *m_pStream;
172 // @HACK:
173 // This is set only when the app told the resource to replace its real
174 // data with something app-controlled:
175 void * m_pAssignedData;
176 int m_nAssignedCount;
178 private:
179 cCTRefCount __m_ulRefs;
182 ///////////////////////////////////////////////////////////////////////////////
184 #pragma pack()
186 #endif /* !__RESBASE_H */