Source code of Windows XP (NT5)
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.

68 lines
2.4 KiB

  1. // Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  2. // CUnknown.h
  3. #pragma once
  4. /*****************************************************************************/
  5. // Component
  6. /*****************************************************************************/
  7. class CUnknown : public IUnknown
  8. {
  9. public:
  10. // Constructor
  11. CUnknown();
  12. // Destructor
  13. virtual ~CUnknown();
  14. // IDispatch declarartion
  15. STDMETHOD(QueryInterface)(const IID& iid, void** ppv);
  16. STDMETHOD_(ULONG,AddRef)();
  17. STDMETHOD_(ULONG,Release)();
  18. // Initialization
  19. STDMETHOD(Init)();
  20. // Count of currently active components
  21. static long ActiveComponents()
  22. { return s_cActiveComponents ;}
  23. // Notification to derived classes that we are releasing
  24. STDMETHOD_(void,FinalRelease)() ;
  25. protected:
  26. // Event thread status
  27. enum { Pending, Running, PendingStop, Stopped };
  28. int m_eStatus;
  29. HANDLE m_hEventThread;
  30. private:
  31. // Reference count
  32. LONG m_cRef;
  33. // Count of all active instances
  34. static long s_cActiveComponents ;
  35. };
  36. /*****************************************************************************/
  37. // Macro for easy declaration of IUnknown. Derived classes using this must
  38. // still implement QueryInterface (specifying their own interfaces).
  39. /*****************************************************************************/
  40. #define DECLARE_IUNKNOWN \
  41. STDMETHOD(QueryInterface)(const IID& iid, void** ppv); \
  42. STDMETHOD_(ULONG,AddRef)() \
  43. { \
  44. return CUnknown::AddRef(); \
  45. } \
  46. STDMETHOD_(ULONG,Release)() \
  47. { \
  48. return CUnknown::Release(); \
  49. } \
  50. \