Essential COM
- Brand: Unbranded
Description
lPug *pPug = 0; hr = punk->Querylnterface(llD_PPV-ARG(lPug, &pPug)); This macro closes the hole introduced by the vo; d ** parameter without imposing any runtime costs. works to the C++ programmer's advantage, as C++ can produce code that is potentially more performant than languages that require a runtime layer to deal with COM. Unlike C++ programmers, Visual Basic and Java programmers never see Querylnterface, AddRef, or Release. For these two languages, the details of IUnknown are hidden deep below each language's supporting virtual machine. In Java, Querylnterface simply maps to a type-cast: bool SaveString(IFastString *pfs, const char *pszFN){ bool bResult = false; IPersistentObject *ppo = (IPersistentObject*) pfs->Dynamic_Cast("IPersistentObject"); if (ppo) bResult = ppo->Save(pszFN); return bResult; } include "smartif.h" void TryToSnoreAndIgnoreC/* [in] *1 IUnknown *pUnk) { II copy constructor calls Querylnterface Smartlnterface pPug = pUnk; import "unknwn.idl"; [object, uuid(DF12E151-A29A-l1dO-8C2D-00BOC73925BA)] interface IAnimal : IUnknown { HRESULT Eat(void); }
Essentials for Men FW23 Collection | SSENSE Fear Of God Essentials for Men FW23 Collection | SSENSE
Dynamic versus Static Invocation 350 Bidirectional Interface Contracts 356 Aliasing in IDL 370 Asynchronous Methods 375 Where Are We? 375The first parameter (ri i d) is the physical name of the interface being requested. The second parameter (ppv) points to an interface pointer variable that on successful completion will contain the requested interface pointer. In response to a Querylnterface request, if the object does not support the requested interface type, it must return E_NOINTERFACE after setting *ppv to null. If the object does support the requested interface, it must overwrite *ppv with a pointer of the requested type and return the HRESULT S_OK. Because ppv is an [out] parameter, the implementation of Querylnterface must AddRef the resultant pointer prior to returning control to the caller (see guideline A2 from earlier in this chapter). This AddRef call must be matched by a Re1ease call from the client. The following shows runtime type discovery using C++'s dynami c_cast operator based on the Dog/Cat type hierarchy described earlier in this chapter:
Essential Mod | Home - The Mod You Need For Minecraft Java Essential Mod | Home - The Mod You Need For Minecraft Java
void DestroyPointer(void) { II destroy object when last pointer destroyed if (--m_cPtrs == 0) delete this; }II ifaststring.h IIIIIIIIIII class IFastString { public: virtual int Length(void) canst = 0; virtual int Find(const char *psz) canst class IFastString2 : public IFastString { public: II real version 2.0 virtual int FindN(const char *psz, int n) object, uuid(BDA4A270-A1BA-lldO-8C2C-0080C73925BA)] interface ICalculator : IBaselnterface { HRESULT Clear(void); HRESULT Add([in] long n); HRESULT Sum([out, retval] long *pn); } These 32 hexadecimal digits represent the 128-bit value of the GUID. Naming interfaces and implementations using GUIDs is important for avoiding name collisions across multiple components. To create a new GUID, COM exposes an API function that uses a decentralized uniqueness algorithm to produce a new 128-bit value that will never again occur in nature: HRESULT CoCreateGuid(GUID *pguid); faststring.cpp (part of DLL) IIIIIIIIIII IFastString *CreateFastString (canst char *psz) { return new FastString(psz);
- Fruugo ID: 258392218-563234582
- EAN: 764486781913
-
Sold by: Fruugo