Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
IUnknown.h
Go to the documentation of this file.
1 //
5 //
6 #ifndef _INC_IUnknown_H
7 #define _INC_IUnknown_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "HResult.h"
13 
14 #ifdef _WIN32
15 #include <Unknwn.h> // IUnknown __IUnknown_INTERFACE_DEFINED__ IClassFactory
16 #endif
17 
18 #ifndef DECLSPEC_UUID
19 #define DECLSPEC_UUID(x)
20 #endif
21 
22 #ifdef __GNUC__
23 #define __uuidof(x) IID_##x // IID_IUnknown == __uuidof(IUnknown) . This doesn't work in templates of course.
24 #ifndef MIDL_INTERFACE
25 #define MIDL_INTERFACE(a) interface // assume we get struct DECLSPEC_UUID(x) DECLSPEC_NOVTABLE and will support IUnknown. Similar to DECLARE_INTERFACE
26 #endif
27 #endif
28 
29 // #define GRAY_GUID_POSTFIX_S "-0000-0000-C000-100000000046" // Use this GUID postfix for all but first 4 bytes. (8 hex digits)
30 
31 #ifndef GUID_DEFINED
32 #define GUID_DEFINED
33 typedef struct _GUID
34 {
39 public:
40  inline bool operator == ( const _GUID& other ) const
41  {
42  return ! ::memcmp( this, &other, sizeof(other));
43  }
44 public:
45  UINT32 Data1;
46  WORD Data2;
47  WORD Data3;
48  BYTE Data4[8];
49 } GUID;
50 #endif
51 
52 #ifdef __linux__
53 #define STDMETHOD(method) virtual HRESULT _stdcall method
54 #define STDMETHOD_(type,method) virtual type _stdcall method
55 #define STDMETHODIMP HRESULT _stdcall
56 #define STDMETHODIMP_(type) type _stdcall
57 #define __RPC_FAR // only used for _MSC_VER ?
58 
59 #define DECLSPEC_UUID(x) //__declspec(uuid(x))
60 #endif // __linux__
61 
62 #if ! defined(__IUnknown_INTERFACE_DEFINED__)
63 #define __IUnknown_INTERFACE_DEFINED__
64 
65 typedef GUID IID;
67 
68 MIDL_INTERFACE("00000000-0000-0000-C000-000000000046") IUnknown
69 {
71  STDMETHOD(QueryInterface)( /* [in] */ const IID& riid, /* [iid_is][out] */ void**ppvObject ) = 0;
72  STDMETHOD_(ULONG,AddRef)(void) = 0;
73  STDMETHOD_(ULONG, Release)(void) = 0;
74 };
75 
76 #endif // __IUnknown_INTERFACE_DEFINED__
77 
78 #if 1
79 
84 
85 #define IUNKNOWN_DISAMBIG_R(TYPE) \
86  STDMETHOD_(ULONG,AddRef)(void) override /* disambiguate.*/ \
87  { return TYPE::AddRef(); } \
88  STDMETHOD_(ULONG, Release)(void) override /* disambiguate.*/\
89  { return TYPE::Release(); }
90 
91 // IUNKNOWN_DISAMBIG_R and the QueryInterface() call. use this TYPE.
92 #define IUNKNOWN_DISAMBIG(TYPE) STDMETHOD(QueryInterface)( /* [in] */ const IID& riid, /* [iid_is][out] */ void __RPC_FAR* __RPC_FAR* ppvObject ) override \
93  { return TYPE::QueryInterface(riid,ppvObject); } \
94  IUNKNOWN_DISAMBIG_R(TYPE);
95 
96 #else
97 
98 #define IUNKNOWN_DISAMBIG_R(TYPE)
99 #define IUNKNOWN_DISAMBIG(TYPE)
100 #endif
101 
102 #endif // _INC_IUnknown_H
MIDL_INTERFACE("7ED943DD-52E8-40b5-A8D8-76685C406330") ID3DXBaseMesh
#define GRAYCORE_LINK
Definition: GrayCore.h:47
GUID IID
Definition: IUnknown.h:65
struct _GUID GUID
__DECL_IMPORT GUID IID_IUnknown
Definition: IUnknown.h:68
Definition: IUnknown.h:34
UINT32 Data1
Definition: IUnknown.h:45
WORD Data2
Definition: IUnknown.h:46
WORD Data3
Definition: IUnknown.h:47
bool operator==(const _GUID &other) const
Definition: IUnknown.h:40
BYTE Data4[8]
Definition: IUnknown.h:48