1/* 2 * IOFireWireLibIUnknown.h 3 * IOFireWireFamily 4 * 5 * Created by Niels on Thu Feb 27 2003. 6 * Copyright (c) 2003 __MyCompanyName__. All rights reserved. 7 * 8 * $Log: IOFireWireLibIUnknown.h,v $ 9 * Revision 1.2 2003/07/21 06:53:10 niels 10 * merge isoch to TOT 11 * 12 * Revision 1.1.2.1 2003/07/01 20:54:23 niels 13 * isoch merge 14 * 15 */ 16 17#import <CoreFoundation/CFPlugInCOM.h> 18 19 20#define INTERFACEIMP_INTERFACE \ 21 0, \ 22 & IOFireWireIUnknown::SQueryInterface, \ 23 & IOFireWireIUnknown::SAddRef, \ 24 & IOFireWireIUnknown::SRelease 25 26namespace IOFireWireLib { 27 28 class IOFireWireIUnknown: public IUnknown 29 { 30 protected: 31 32 template<class T> 33 class InterfaceMap 34 { 35 public: 36 InterfaceMap( const IUnknownVTbl & vTable, T * inObj ): pseudoVTable(vTable), obj(inObj) {} 37 inline static T * GetThis( void* map ) { return reinterpret_cast<T*>( reinterpret_cast<InterfaceMap*>( map )->obj ) ; } 38 39 private: 40 const IUnknownVTbl & pseudoVTable ; 41 T * obj ; 42 } ; 43 44 private: 45 46 mutable InterfaceMap<IOFireWireIUnknown> mInterface ; 47 48 protected: 49 50 UInt32 mRefCount ; 51 52 public: 53 54 IOFireWireIUnknown( const IUnknownVTbl & interface ) ; 55#if IOFIREWIRELIBDEBUG 56 virtual ~IOFireWireIUnknown() ; 57#else 58 virtual ~IOFireWireIUnknown() {} 59#endif 60 virtual HRESULT QueryInterface( REFIID iid, LPVOID* ppv ) = 0; 61 virtual ULONG AddRef() ; 62 virtual ULONG Release() ; 63 64 InterfaceMap<IOFireWireIUnknown>& GetInterface() const { return mInterface ; } 65 66 static HRESULT STDMETHODCALLTYPE SQueryInterface(void* self, REFIID iid, LPVOID* ppv) ; 67 static ULONG STDMETHODCALLTYPE SAddRef(void* self) ; 68 static ULONG STDMETHODCALLTYPE SRelease(void* self) ; 69 } ; 70 71} // namespace 72