Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.4 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: LUnknown.h
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. //
  8. //
  9. //-----------------------------------------------------------------------------
  10. #if !defined (EspUtil_LUnknown_h)
  11. #define EspUtil_LUnknown_h
  12. ////////////////////////////////////////////////////////////////////////////////
  13. // CLUnknown
  14. //
  15. // A abstract base class that is designed to help when creating child classes
  16. // that depend on a parent class. These classes can not exist by themselves,
  17. // but instead mearly export different interfaces to the parent class.
  18. //
  19. // Rules:
  20. // 1. All classes must have a valid, non-NULL parent pointer.
  21. // 2. The parent class is responsible for AddRef()'ing itself during
  22. // QueryInterface().
  23. //
  24. ////////////////////////////////////////////////////////////////////////////////
  25. class LTAPIENTRY CLUnknown
  26. {
  27. // Construction
  28. public:
  29. CLUnknown(IUnknown * pParent);
  30. protected: // Don't allow stack objects
  31. virtual ~CLUnknown() = 0;
  32. // Data
  33. protected:
  34. ULONG m_ulRef; // Reference count
  35. IUnknown * m_pParent; // Parent of object
  36. // Operations
  37. public:
  38. ULONG AddRef();
  39. ULONG Release();
  40. HRESULT QueryInterface(REFIID iid, LPVOID * ppvObject);
  41. };
  42. ////////////////////////////////////////////////////////////////////////////////
  43. #include "LUnknown.inl"
  44. #if !defined(DECLARE_CLUNKNOWN)
  45. #define DECLARE_CLUNKNOWN() \
  46. public: \
  47. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR*ppvObj); \
  48. STDMETHOD_(ULONG, AddRef)(THIS); \
  49. STDMETHOD_(ULONG, Release)(THIS);
  50. #endif
  51. #if !defined(IMPLEMENT_CLUNKNOWN)
  52. #define IMPLEMENT_CLUNKNOWN_ADDREF(ObjectClass) \
  53. STDMETHODIMP_(ULONG) ObjectClass::AddRef(void) \
  54. { \
  55. return CLUnknown::AddRef(); \
  56. }
  57. #define IMPLEMENT_CLUNKNOWN_RELEASE(ObjectClass) \
  58. STDMETHODIMP_(ULONG) ObjectClass::Release(void) \
  59. { \
  60. return CLUnknown::Release(); \
  61. }
  62. #define IMPLEMENT_CLUNKNOWN_QUERYINTERFACE(ObjectClass) \
  63. STDMETHODIMP ObjectClass::QueryInterface(REFIID riid, LPVOID *ppVoid) \
  64. { \
  65. return (HRESULT) CLUnknown::QueryInterface(riid, ppVoid); \
  66. }
  67. #define IMPLEMENT_CLUNKNOWN(ObjectClass) \
  68. IMPLEMENT_CLUNKNOWN_ADDREF(ObjectClass) \
  69. IMPLEMENT_CLUNKNOWN_RELEASE(ObjectClass) \
  70. IMPLEMENT_CLUNKNOWN_QUERYINTERFACE(ObjectClass)
  71. #endif
  72. #endif