freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

com接口與對(duì)象-閱讀頁(yè)

2024-10-19 21:52本頁(yè)面
  

【正文】 pDestroyPointer()。 extern C void *CreateString(const char *psz, const char *pszinterface) { void *pret = NULL。 if (NULL!=p) { pret= pDynamic_cast(pszinterface)。 } return pret。 virtual void DuplicatePointer()=0。 }。 WORD Data2。 BYTE Data4[8]。 extern C const GUID CLSID_MYSPELLCHECKER = { 0x54bf6567, 0x1007, 0x11d1, { 0xb0, 0xaa, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} } 。 iid, void **ppv) = 0 。 virtual ULONG __stdcall Release() = 0。 IUnknown接口 (續(xù) ) ?C定義: typedef struct IUnknownVtbl { HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( IUnknown __RPC_FAR * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)。 ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( IUnknown __RPC_FAR * This)。 interface IUnknown { CONST_VTBL struct IUnknownVtbl __RPC_FAR *lpVtbl。 COM接口結(jié)構(gòu) 接口指針 指針 指針函數(shù) 1指針函數(shù) 2指針函數(shù) 3。對(duì)象實(shí)現(xiàn)v t ab l epV t ab l eC語(yǔ)言描述示例 —— IDictionary struct IDictionaryVtbl。 }。 BOOL (*LoadLibrary)( IDictionary * this, String)。 void (*DeleteWord)( IDictionary * this, String)。 BOOL (*RestoreLibrary )( IDictionary * this, String)。 }。 virtual BOOL LoadLibrary(String) = 0。 virtual void DeleteWord(String) = 0。 virtual BOOL RestoreLibrary(String) = 0。 }。 UL ONG Relea se ()。 BO OL In se rtW o rd )( th is * , S tri n g )。 BO OL L o o k u p W o rd (th is * , S tri n g , S tri n g * )。 v o id F ree L ib rary (th is * )。從一個(gè)接口到另一個(gè)接口的訪問(wèn)途徑 ?函數(shù) QueryInterface(iid, ppv) ?用法: –初始得到了一個(gè)接口指針之后,調(diào)用它的QueryInterface函數(shù),獲得另一個(gè)接口指針 ?返回值說(shuō)明了對(duì)象對(duì)接口的支持情況 ?S_OK、 E_NOINTERFACE、E_UNEXPECTED 接口查詢用法示例 // load the dictionary retValue = pIDictionaryLoadLibrary()。 return。 HRESULT result = pIDictionaryQueryInterface(IID_SpellCheck, (void **)amp。 if (result != S_OK) { pIDictionaryRelease()。 } // ...... use interface pISpellCheck // finally, release dictionary object pIDictionaryRelease()。 ...... QueryInterface實(shí)現(xiàn) ?與對(duì)象的定義有關(guān) ?IUnknown必須是個(gè)靜態(tài)接口指針,其他接口指針可以是動(dòng)態(tài)的 ?QueryInterface在返回接口之前,必須調(diào)用新接口的 AddRef函數(shù) QueryInterface實(shí)現(xiàn)舉例 class CDictionary : public IDictionary , public ISpellCheck { public : CDictionary()。 public : // IUnknown member function virtual HRESULT QueryInterface(const IIDamp。 virtual ULONG AddRef() 。 ...... private : int m_Ref 。 IU n k n o w nID ic tio n a ryCD ic tio n a ryIU n k n o w nISp e llCh e c kQueryInterface實(shí)現(xiàn)舉例(續(xù)一) IDictio n a ry 的 v tab le 指針th is 指針I(yè)S p e ll Ch e c k 的 v tab le 指針CDictio n a ry的屬性數(shù)據(jù)Qu e ry In ter f a c eA d d RefRelea se......Qu e ry In ter f a c eA d d RefRelea se......IDictio n a ry成員函數(shù)IS p e ll Ch e c k成員函數(shù)v tab leQueryInterface實(shí)現(xiàn)舉例(續(xù)二) HRESULT CDictionary::QueryInterface(const IIDamp。 ((IDictionary *)(*ppv))AddRef() 。 ((IDictionary *)(*ppv))AddRef() 。 ((ISpellCheck *)(*ppv))AddRef() 。 return E_NOINTERFACE 。 } COM對(duì)象的接口原則 ?IUnknown接口一致性 ?接口對(duì)稱性 ?接口自反性 ?接口傳遞性 ?接口查詢時(shí)間無(wú)關(guān)性 引用計(jì)數(shù) ?目的:是為了控制對(duì)象的生命周期 ?多個(gè)客戶可以獨(dú)立地控制對(duì)象的生存 ?引用計(jì)數(shù)反映了被客戶引用的個(gè)數(shù) – Outstanding references ?引用計(jì)數(shù)是個(gè)整數(shù),從 0開(kāi)始 ?兩個(gè)操作:增一和減一 ?當(dāng)引用計(jì)數(shù)為 0時(shí),表示沒(méi)有客戶在使用對(duì)象或者接口 —— 刪除 實(shí)現(xiàn)引用計(jì)數(shù) ?層次,或者粒度 組件模塊對(duì)象 1IUn k n o w nIS o m e In t f a c e組件引用計(jì)數(shù)IUn k n o w n對(duì)象引用計(jì)數(shù)IUn k n o w n接口引用計(jì)數(shù)對(duì)象 2IUn k n o w nIOt h e rIn t f a c e。 ~CDictionary()。 iid, void **ppv) 。 virtual ULONG Release() 。 virtual BOOL LoadLibrary(String)。 char *m_DictFilename[128]。 }。 // ... initialize } ULONG CDictionary::AddRef () { m_Ref ++。 } ULONG CDictionary::Release () { m_Ref 。 } 引用計(jì)數(shù)用法 ?客戶要引用接口時(shí) —— 增一操作 –調(diào)用 IUnknown::AddRef() ?客戶用完接口時(shí) —— 減一操作 –調(diào)用 IUnknown::Release() ?當(dāng)對(duì)象的引用計(jì)數(shù)為 0時(shí),釋放 ?當(dāng)組件中所有對(duì)象的引用計(jì)數(shù)為 0時(shí),卸載 ?AddRef和 Release的返回值不可靠 引用計(jì)數(shù)使用示例 // load the dictionary BOOL retValue = pIDictionaryLoadLibrary()。 return。 pIDictionaryForWord AddRef()。 pIDictionaryForWord DeleteWord(...)。 ...... // finally, release dictionary object pIDictionaryRelease ( )。 –如果要結(jié)束使用一個(gè)接口指針變量,以后不再用到它了,則調(diào)用 Release函數(shù)。 return (ULONG) m_Ref。 if (m_Ref == 0 ) { delete this。 } return (ULONG) m
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1