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.

49 lines
1.0 KiB

  1. // File: refcount.h
  2. #ifndef _REFCOUNT_H_
  3. #define _REFCOUNT_H_
  4. // RefCount destructor callback function
  5. typedef void (*OBJECTDESTROYEDPROC)(void);
  6. VOID STDMETHODCALLTYPE DLLObjectDestroyed(void);
  7. VOID DllLock(void);
  8. //////////////////////////////////////////////////////////////////////////
  9. class RefCount
  10. {
  11. protected:
  12. ULONG m_ulcRef;
  13. OBJECTDESTROYEDPROC m_ObjectDestroyed;
  14. #ifdef DEBUG
  15. BOOL m_fTrack;
  16. #endif
  17. public:
  18. RefCount(OBJECTDESTROYEDPROC ObjectDestroyed);
  19. // Virtual destructor defers to destructor of derived class.
  20. virtual ~RefCount(void);
  21. // IUnknown
  22. ULONG STDMETHODCALLTYPE AddRef(void);
  23. ULONG STDMETHODCALLTYPE Release(void);
  24. #ifdef DEBUG
  25. VOID SetTrack(BOOL fTrack) {m_fTrack = fTrack;}
  26. #endif
  27. };
  28. DECLARE_STANDARD_TYPES(RefCount);
  29. // Special version of the above that calls our standard Dll locking functions
  30. class DllRefCount : public RefCount
  31. {
  32. public:
  33. DllRefCount() : RefCount(&DLLObjectDestroyed) {DllLock();}
  34. ~DllRefCount(void) {};
  35. };
  36. #endif /* _REFCOUNT_H_ */