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.

73 lines
2.1 KiB

  1. #ifndef __VOIDLIST_H
  2. #define __VOIDLIST_H
  3. #include "listintr.h"
  4. struct CNode;
  5. class CVoidPtrList : public IVoidPtrList
  6. {
  7. private:
  8. enum
  9. {
  10. HANDLE_START = 0x00000001,
  11. HANDLE_END = 0xffffffff
  12. };
  13. CNode *m_pEnds[2]; // Head and tail
  14. DWORD m_cCount;
  15. DWORD_PTR m_dwCookie;
  16. LONG m_cRefCount;
  17. IVPL_COMPAREFUNCTYPE m_pCompareFunc;
  18. IVPL_FREEITEMFUNCTYPE m_pFreeItemFunc;
  19. CRITICAL_SECTION m_rCritSect;
  20. bool m_fInited;
  21. void SortedAddItem(CNode *pNode);
  22. void NonSortedAddItem(CNode *pNode);
  23. CNode* GetHead() {return m_pEnds[LD_FORWARD];}
  24. CNode* GetTail() {return m_pEnds[LD_REVERSE];}
  25. void SetHead(CNode* pNode) {m_pEnds[LD_FORWARD] = pNode;}
  26. void SetTail(CNode* pNode) {m_pEnds[LD_REVERSE] = pNode;}
  27. CNode* FindItem(DWORD dwHandle);
  28. DWORD GetNewHandle();
  29. public:
  30. CVoidPtrList();
  31. ~CVoidPtrList();
  32. // IUnknown members
  33. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj) { return E_NOTIMPL;}
  34. virtual STDMETHODIMP_(ULONG) AddRef(void);
  35. virtual STDMETHODIMP_(ULONG) Release(void);
  36. // IVoidPtrList members
  37. virtual HRESULT STDMETHODCALLTYPE Init(
  38. IVPL_COMPAREFUNCTYPE pCompareFunc,
  39. DWORD_PTR dwCookie,
  40. IVPL_FREEITEMFUNCTYPE pFreeItemFunc,
  41. DWORD dwInitSize);
  42. virtual HRESULT STDMETHODCALLTYPE GetCount(DWORD *pdwCount) {
  43. *pdwCount = m_cCount; return S_OK;}
  44. virtual HRESULT STDMETHODCALLTYPE ClearList(void);
  45. virtual HRESULT STDMETHODCALLTYPE AddItem(LPVOID ptr, DWORD *pdwHandle);
  46. virtual HRESULT STDMETHODCALLTYPE RemoveItem(DWORD dwHandle);
  47. virtual HRESULT STDMETHODCALLTYPE GetNext(
  48. LISTDIRECTION bDirection,
  49. LPVOID *pptr,
  50. DWORD *pdwHandle);
  51. virtual HRESULT STDMETHODCALLTYPE SkipNext(LISTDIRECTION bDirection, DWORD *pdwHandle);
  52. virtual HRESULT STDMETHODCALLTYPE Resort(void);
  53. static HRESULT CreateInstance(CVoidPtrList** ppList);
  54. };
  55. #endif