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.

74 lines
3.2 KiB

  1. // --------------------------------------------------------------------------------
  2. // Privunk.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // --------------------------------------------------------------------------------
  5. #ifndef __PRIVUNK_H
  6. #define __PRIVUNK_H
  7. // --------------------------------------------------------------------------------
  8. // CPrivateUnknown
  9. // --------------------------------------------------------------------------------
  10. class CPrivateUnknown : public IUnknown
  11. {
  12. private:
  13. // ----------------------------------------------------------------------------
  14. // Embed default IUnknown handler
  15. // ----------------------------------------------------------------------------
  16. class CUnkInner : public IUnknown
  17. {
  18. private:
  19. LONG m_cRef; // Private Ref Count
  20. public:
  21. // Construction
  22. CUnkInner(void) { m_cRef = 1; }
  23. // IUnknown Members
  24. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  25. virtual STDMETHODIMP_(ULONG) AddRef(void) ;
  26. virtual STDMETHODIMP_(ULONG) Release(void);
  27. };
  28. friend class CUnkInner;
  29. // ----------------------------------------------------------------------------
  30. // Private Data
  31. // ----------------------------------------------------------------------------
  32. CUnkInner m_cUnkInner; // Private Inner
  33. IUnknown *m_pUnkOuter; // points to _cUnkInner or aggregating IUnknown
  34. protected:
  35. // ----------------------------------------------------------------------------
  36. // Construction
  37. // ----------------------------------------------------------------------------
  38. CPrivateUnknown(IUnknown *pUnkOuter);
  39. virtual ~CPrivateUnknown(void) {};
  40. // ----------------------------------------------------------------------------
  41. // This is the QueryInterface the aggregator implements
  42. // ----------------------------------------------------------------------------
  43. virtual HRESULT PrivateQueryInterface(REFIID riid, LPVOID * ppvObj) = 0;
  44. public:
  45. // ----------------------------------------------------------------------------
  46. // This is the IUnknown that subclasses returns from their CreateInstance func
  47. // ----------------------------------------------------------------------------
  48. IUnknown* GetInner() { return &m_cUnkInner; }
  49. // ----------------------------------------------------------------------------
  50. // IUnknown Members
  51. // ----------------------------------------------------------------------------
  52. inline virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj) {
  53. return m_pUnkOuter->QueryInterface(riid, ppvObj); }
  54. inline virtual STDMETHODIMP_(ULONG) AddRef(void) {
  55. return m_pUnkOuter->AddRef(); }
  56. inline virtual STDMETHODIMP_(ULONG) Release(void) {
  57. return m_pUnkOuter->Release(); }
  58. // ----------------------------------------------------------------------------
  59. // Public Utilities
  60. // ----------------------------------------------------------------------------
  61. void SetOuter(IUnknown *pUnkOuter);
  62. };
  63. #endif // __PRIVUNK_H