OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
appdesc.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectComponents
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4/// \file
5/// TAppDescriptor - OLE application descriptor definitions
6//----------------------------------------------------------------------------
7
8#if !defined(OCF_APPDESC_H)
9#define OCF_APPDESC_H
10
11#include <owl/private/defs.h>
12#if defined(BI_HAS_PRAGMA_ONCE)
13# pragma once
14#endif
15
16#include <ocf/autodefs.h>
17
18namespace owl {class _OWLCLASS TRegLink;};
19namespace owl {class _OWLCLASS TModule;};
20namespace owl {class _OWLCLASS TRegList;};
21
22namespace ocf {
23
24//----------------------------------------------------------------------------
25// TAppDescriptor - application registration and browsing facilities
26//
27
32
33// Factory routine which creates OLE object
34//
35typedef IUnknown* (*TComponentFactory)(IUnknown* outer, owl::uint32 options, owl::uint32 id);
36
37//
38// license key support
39//
40// User defined class callback
41//
43 virtual HRESULT _IFUNC GetLicInfo( LICINFO* licInfo) = 0;
44 virtual HRESULT _IFUNC RequestLicKey(BSTR* retKey) = 0;
45 virtual HRESULT _IFUNC QueryLicKey(BSTR key) = 0;
46};
47
48//
49// class TAppDescriptor
50// ~~~~~ ~~~~~~~~~~~~~~
51//
52class _ICLASS TAppDescriptor : public IClassFactory2 {
53 public:
55 owl::tstring& cmdLine, owl::TModule* module = & owl::GetGlobalModule(),
56 const owl::TRegLink* regLink = 0, owl::uint32 preselectedOptions = 0);
58 TLicenseKeyFactory* factory, owl::tstring& cmdLine,
59 owl::TModule* module = & owl::GetGlobalModule(), const owl::TRegLink* regLink = 0,
60 owl::uint32 preselectedOptions = 0);
62
63 operator IUnknown*() {return this;}
64 bool IsAutomated() const {return ClassCount > 0;}
65 TComponentFactory GetFactory() const {return FactoryCallback;}
66 const owl::TRegLink* GetRegLinkHead() const {return LinkHead;}
67 const TLicenseKeyFactory* GetLicKeyFactory() const {return LicKeyFactoryCallback;}
68
69 // Command line options accessors
70 //
71 void ProcessCmdLine(owl::tstring& cmdLine);
72 void SetLangId(owl::TLangId prevLang, LPCTSTR langIdStr);
73 bool IsOptionSet(owl::uint32 option) const {return (Options & option) != 0;}
74 owl::uint32 GetOptions() const {return Options;}
75 void SetOption(owl::uint32 bit, bool state)
76 {
77 if (state)
78 Options |= bit;
79 else
80 Options &= ~bit;
81 }
82
83 // Registration management functions
84 //
85 void RegisterClass();
86 void UnregisterClass();
87 bool RegisterObject(TObjectDescriptor app);
88 void UnregisterObject();
89 TClassId GetLinkGuid(int index);
90 void RegisterServer(owl::TLangId lang, LPCTSTR regFile = 0);
91 void UnregisterServer(owl::TLangId lang = 0, LPCTSTR str = 0);
92 void MakeTypeLib(owl::TLangId lang, LPCTSTR str = 0);
93
94 // TAutoClass management functions
95 //
96 void MergeAutoClasses();
97
98 // TypeLibrary management functions
99 //
100 ITypeLib* GetTypeLibrary(); //NOTE: Caller MUST do a Release()
101 ITypeInfo* CreateITypeInfo(TAutoClass& cls); //NOTE: Caller MUST do a Release()
102 int GetClassCount() {return ClassCount;}
103 owl::TLangId GetAppLang() {return AppLang;}
104 int GetClassIndex(TAutoClass* cls); // returns -1 if not found
105 bool GetClassId(TAutoClass* cls, GUID& retId);
106 TAutoClass* GetAutoClass(unsigned index);
107 TAutoClass* GetAutoClass(const GUID& clsid);
108 owl::TRegLink* GetRegLink(const GUID& clsid);
109 owl::uint16 GetVersionField(owl::uint field);
110 LPCTSTR GetAppName(owl::TLangId lang) {return AppName->Translate(lang);}
111 LPCTSTR GetAppDoc(owl::TLangId lang) {return AppDoc->Translate(lang);}
112 LPCTSTR GetHelpFile(owl::TLangId lang){return HelpFile->Translate(lang);}
113 void WriteTypeLibrary(owl::TLangId lang, LPCTSTR file);
114
115 // TServedObject management functions
116 //
117 TUnknown* CreateAutoApp(TObjectDescriptor app, owl::uint32 options,
118 IUnknown* outer=0);
119 void ReleaseAutoApp(TObjectDescriptor app);
120 TUnknown* CreateAutoObject(TObjectDescriptor obj, TServedObject& app,
121 IUnknown* outer=0);
122 TUnknown* CreateAutoObject(const void* obj, const std::type_info& objInfo,
123 const void* app, const std::type_info& appInfo,
124 IUnknown* outer=0);
125 TServedObject* FindServed(const void * mostDerivedObj);
126 TServedObject* FindServed(TObjectDescriptor& objDesc);
127 void AddServed(TServedObject& obj);
128 void RemoveServed(TServedObject& obj);
129 void InvalidateObject(const void* obj);
130 void ReleaseObject(const void * obj);
131 bool IsBound() {return static_cast<bool>(ServedList != 0 || LockCount != 0);}
132 bool IsActiveObject(TServedObject* obj) {return ActiveObject == obj;}
133 void FlushServed();
134 void DeleteCreator();
135
137
138 private:
139 void Init(IMalloc* alloc = 0); // called only from constructor
140 TServedObject* ServedList; // List of outstanding IDispatch/ITypeInfo objs
141 TServedObject* ActiveObject; // Currently registered active object
142 TServedObjectCreator* Creator; // Served Object creator class
143 owl::TRegList& RegInfo; // Registration list for application
144 LPCTSTR Version; // Library version, stored as text string
145 owl::TLocaleString* AppProgId; // Progid of application
146 owl::TLocaleString* AppName; // Name of application, localizable
147 owl::TLocaleString* AppDoc; // Description of application, localizable
148 owl::TLocaleString* HelpFile; // Name of help file, localizable
149 TAutoClass::TAutoClassRef*
150 ClassList; // Array of automated class references
151 int ClassCount; // Count of classes, set when first scanned
152 int DebugGuidOffset;// GUID offset for /Debug registration
153 int LibGuidOffset; // GUID offset for the app library
154 int LinkGuidOffset; // GUID offset for the first doc template
155 int LinkGuidCount; // count of GUIDs assigned to doc templates
156 owl::TLangId AppLang; // Language Id for this running instance
157 TTypeLibrary* TypeLib; // Type library, only while referenced
158 const owl::TRegLink* LinkHead; // Reglink list of reglists to register
159 TComponentFactory FactoryCallback; // callback to create/destroy instance
160 TLicenseKeyFactory* LicKeyFactoryCallback; // callback to get/check license info
162 unsigned long RefCnt;
163 unsigned LockCount;
164 unsigned long RegClassHdl; // For unregistration
165 unsigned long RegObjectHdl; // For unregistration
166 owl::uint32 Options; // Command line option bit flags
167
168 // For EXE or DLL component main, provide direct access for destructors
169 // For auxilliary DLLs, a table must be maintained of AppDesc vs. task Id
170 //
171 static TAppDescriptor* This; // set by constructor to component instance
172
173 // IUnknown interface
174 //
175 HRESULT _IFUNC QueryInterface(const IID & iid, void** retIface);
176 unsigned long _IFUNC AddRef();
177 unsigned long _IFUNC Release();
178
179 public:
180
181 // IClassFactory interface
182 //
183 HRESULT _IFUNC CreateInstance(IUnknown* outer, const IID & iid, void** retObject);
184 HRESULT _IFUNC LockServer(int lock);
185
186 // IClassFactory2 interface
187 //
188 HRESULT _IFUNC GetLicInfo( LICINFO* licInfo);
189 HRESULT _IFUNC RequestLicKey(DWORD reserved, BSTR* retKey);
190 HRESULT _IFUNC CreateInstanceLic(IUnknown* outer, IUnknown* reserved,
191 const IID & iid, BSTR key,
192 void** retObject );
193
194 friend class _ICLASS TTypeLibrary;
195 friend class _ICLASS TCoClassInfo;
197};
198
199//
200// For EXE and DLL component main module, provide direct access to descriptor
201// For auxilliary DLLs, must use table of app descriptor vs. task Id
202//
204 return TAppDescriptor::This;
205}
206
207//
208// class TTypeLibrary
209// ~~~~~ ~~~~~~~~~~~~
210//
211class _ICLASS TTypeLibrary : public ITypeLib {
212 public:
215
216// !BB operator IUnknown&() {return *this;} // !CQ compiler doesn't allow this!?!
217
218 // Component typeinfo - NOTE: Caller MUST Release()
219 //
220 ITypeInfo* CreateCoClassInfo();
221
222 private:
223 TAppDescriptor& AppDesc;
224 unsigned long RefCnt;
225 owl::TLangId Lang;
226 owl::uint16 CoClassFlags; // Type flags combined from autoclasses
227 int CoClassImplCount; // Number of interfaces in coclass
228
229 // IUnknown interface
230 //
231 HRESULT _IFUNC QueryInterface(const IID & iid, void** retIface);
232 unsigned long _IFUNC AddRef();
233 unsigned long _IFUNC Release();
234
235 // ITypeLib interface
236 //
237 unsigned int _IFUNC GetTypeInfoCount();
238 HRESULT _IFUNC GetTypeInfo(unsigned index, ITypeInfo** retInfo);
239 HRESULT _IFUNC GetTypeInfoType(unsigned index, TYPEKIND * retKind);
240 HRESULT _IFUNC GetTypeInfoOfGuid(const GUID& guid, ITypeInfo** retInfo);
241 HRESULT _IFUNC GetLibAttr(TLIBATTR** retAttr);
242 HRESULT _IFUNC GetTypeComp(ITypeComp** retComp);
243 HRESULT _IFUNC GetDocumentation(int index, BSTR* retName,
244 BSTR* retDoc,
245 unsigned long* retHelpContext,
246 BSTR* retHelpFile);
247 HRESULT _IFUNC IsName(OLECHAR* nameBuf, unsigned long hashVal,
248 int* retFound);
249 HRESULT _IFUNC FindName(OLECHAR* nameBuf, unsigned long lHashVal,
250 ITypeInfo** retInfo, MEMBERID* retId,
251 unsigned short * inoutCount);
252 void _IFUNC ReleaseTLibAttr(TLIBATTR* attr);
253};
254
255//
256// class TCoClassInfo
257// ~~~~~ ~~~~~~~~~~~~
258//
259class _ICLASS TCoClassInfo : public ITypeInfo {
260 public:
261 TCoClassInfo(TAppDescriptor& appDesc, owl::uint16 typeFlags, int implCount);
263
264// !BB operator IUnknown&() {return *this;} // !CQ compiler doesn't allow this!?!
265
266 private:
267 TAppDescriptor& AppDesc;
268 unsigned long RefCnt;
269 owl::uint16 TypeFlags; // type flags combined from autoclasses
270 int ImplCount; // number of interfaces in coclass
271 unsigned* ImplList; // array of indices to autoclasses
272 int Default; // interface marked as default
273 int DefaultEvent;// event interface marked as default,source
274
275 // IUnknown interface
276 //
277 HRESULT _IFUNC QueryInterface(const IID & iid, void** retIface);
278 unsigned long _IFUNC AddRef();
279 unsigned long _IFUNC Release();
280
281 // ITypeInfo implementation
282 //
283 HRESULT _IFUNC GetTypeAttr(TYPEATTR** pptypeattr);
284 HRESULT _IFUNC GetTypeComp(ITypeComp** pptcomp);
285 HRESULT _IFUNC GetFuncDesc(unsigned int index, FUNCDESC** ppfuncdesc);
286 HRESULT _IFUNC GetVarDesc(unsigned int index, VARDESC * * ppvardesc);
287 HRESULT _IFUNC GetNames(MEMBERID memid, BSTR * rgbstrNames,
288 unsigned int cMaxNames,
289 unsigned int * pcNames);
290 HRESULT _IFUNC GetRefTypeOfImplType(unsigned int index, HREFTYPE * phreftype);
291 HRESULT _IFUNC GetImplTypeFlags(unsigned int index, int * pimpltypeflags);
292 HRESULT _IFUNC GetIDsOfNames(OLECHAR * * rgszNames,
293 unsigned int cNames,
294 MEMBERID * rgmemid);
295 HRESULT _IFUNC Invoke(void * pvInstance, MEMBERID memid,
296 unsigned short wFlags,
297 DISPPARAMS *pdispparams,
298 VARIANT *pvarResult,
299 EXCEPINFO *pexcepinfo,
300 unsigned int *puArgErr);
301 HRESULT _IFUNC GetDocumentation(MEMBERID memid,
302 BSTR * pbstrName,
303 BSTR * pbstrDocString,
304 owl::ulong * pdwHelpContext,
305 BSTR * pbstrHelpFile);
306 HRESULT _IFUNC GetDllEntry(MEMBERID memid, INVOKEKIND invkind,
307 BSTR * pbstrDllName,
308 BSTR * pbstrName,
309 unsigned short * pwOrdinal);
310 HRESULT _IFUNC GetRefTypeInfo(HREFTYPE hreftype,
311 ITypeInfo* * pptinfo);
312 HRESULT _IFUNC AddressOfMember(MEMBERID memid, INVOKEKIND invkind,
313 void * * ppv);
314 HRESULT _IFUNC CreateInstance(IUnknown* punkOuter, const IID & riid,
315 void * * ppvObj);
316 HRESULT _IFUNC GetMops(MEMBERID memid, BSTR * pbstrMops);
317 HRESULT _IFUNC GetContainingTypeLib(ITypeLib* * pptlib,
318 owl::uint * pindex);
319 void _IFUNC ReleaseTypeAttr(TYPEATTR * ptypeattr);
320 void _IFUNC ReleaseFuncDesc(FUNCDESC * pfuncdesc);
321 void _IFUNC ReleaseVarDesc(VARDESC * pvardesc);
322};
323
324//
325// external entry points for DLL servers
326//
327typedef DECLARE_FUNC(HRESULT,STDAPICALLTYPE,*TDllCanUnloadNow)();
328typedef DECLARE_FUNC(HRESULT,STDAPICALLTYPE,*TDllGetClassObject)(const GUID& clsid, const GUID& iid, void** retObj);
329typedef DECLARE_FUNC(HRESULT,STDAPICALLTYPE,*TDllRegisterServer)();
330typedef DECLARE_FUNC(HRESULT,STDAPICALLTYPE,*TDllUnregisterServer)();
331typedef DECLARE_FUNC(HRESULT,STDAPICALLTYPE,*TDllRegisterCommand)(const char* cmdLine);
332
333} // OCF namespace
334
335
336#endif // OCF_APPDESC_H
337
338
OLE Automation Class Definitions.
void SetOption(owl::uint32 bit, bool state)
Definition appdesc.h:75
bool IsActiveObject(TServedObject *obj)
Definition appdesc.h:132
bool IsOptionSet(owl::uint32 option) const
Definition appdesc.h:73
const owl::TRegLink * GetRegLinkHead() const
Definition appdesc.h:66
TComponentFactory GetFactory() const
Definition appdesc.h:65
LPCTSTR GetAppDoc(owl::TLangId lang)
Definition appdesc.h:111
LPCTSTR GetAppName(owl::TLangId lang)
Definition appdesc.h:110
owl::TLangId GetAppLang()
Definition appdesc.h:103
LPCTSTR GetHelpFile(owl::TLangId lang)
Definition appdesc.h:112
bool IsAutomated() const
Definition appdesc.h:64
const TLicenseKeyFactory * GetLicKeyFactory() const
Definition appdesc.h:67
TBaseClassId AppClassId
Definition appdesc.h:136
owl::uint32 GetOptions() const
Definition appdesc.h:74
Base GUID for a components sequence of GUIDs.
Definition oleutil.h:236
GUID/IID/CLSID management.
Definition oleutil.h:171
OLE object exposed for automated access of internal object.
Definition autodefs.h:972
Standard implementation of a controlling IUnknown for an object, to be inherited with other COM inter...
Definition oleutil.h:264
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
A registration parameter table, composed of a list of TRegItems.
Definition registry.h:531
Object Component Framework (COM encapsulation)
Definition appdesc.h:22
const GUID void ** retObj
Definition appdesc.h:328
IUnknown *(* TComponentFactory)(IUnknown *outer, owl::uint32 options, owl::uint32 id)
Definition appdesc.h:35
const GUID & iid
Definition appdesc.h:328
TAppDescriptor * GetAppDescriptor()
Definition appdesc.h:203
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long ulong
Definition number.h:26
unsigned long uint32
Definition number.h:34
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
Definition lclstrng.h:26
TModule * Module
Definition global.cpp:34
unsigned short uint16
Definition number.h:33
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
TModule & GetGlobalModule()
Definition global.cpp:48
#define _IFUNC
Definition oleutil.h:28
#define _ICLASS
Definition oleutil.h:25
#define DECLARE_FUNC(rparm, ctype, fname)
Definition defs.h:345
#define _OWLCLASS
Definition defs.h:338
virtual HRESULT _IFUNC RequestLicKey(BSTR *retKey)=0
virtual HRESULT _IFUNC GetLicInfo(LICINFO *licInfo)=0
virtual HRESULT _IFUNC QueryLicKey(BSTR key)=0
Designed to provide support for localized registration parameters, the TLocaleString Struct defines a...
Definition lclstrng.h:68