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.

180 lines
5.9 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: ENUMGEN.H
  3. *
  4. * This module contains structure definitions for the enumerator class.
  5. *
  6. * Created: 8-July-1992
  7. *
  8. * Copyright (c) 1985 - 1992 Microsoft Corporation
  9. *
  10. * History:
  11. * Created by TonyKit
  12. *
  13. \***************************************************************************/
  14. #ifndef __ENUMGEN_H__
  15. #define __ENUMGEN_H__
  16. /****** Generic Enumerator Interface ****************************************/
  17. #define LPENUMGENERIC IEnumGeneric FAR*
  18. #undef INTERFACE
  19. #define INTERFACE IEnumGeneric
  20. DECLARE_INTERFACE_(IEnumGeneric, IUnknown)
  21. {
  22. //*** IUnknown methods ***/
  23. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  24. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  25. STDMETHOD_(ULONG,Release) (THIS) PURE;
  26. //*** IEnumerator methods ***/
  27. STDMETHOD(Next) (THIS_ ULONG celt,
  28. LPVOID pArrayObjs,
  29. ULONG FAR* pceltFetched) PURE;
  30. STDMETHOD(Skip) (THIS_ ULONG celt) PURE;
  31. STDMETHOD(Reset) (THIS) PURE;
  32. STDMETHOD(Clone) (THIS_ LPENUMGENERIC FAR* ppenm) PURE;
  33. //*** helper methods ***/
  34. STDMETHOD(UpdateEnumerator)(THIS_ REFIID riid, DWORD dwCurrent,
  35. DWORD dwNew) PURE;
  36. STDMETHOD(SetCurrent) (THIS_ DWORD dwCurrent) PURE;
  37. STDMETHOD(SetNext) (THIS_ LPENUMGENERIC pEnumGenNext) PURE;
  38. STDMETHOD(GetNext) (THIS_ LPENUMGENERIC FAR* ppEnumGenNext) PURE;
  39. STDMETHOD(SetPrev) (THIS_ LPENUMGENERIC pEnumGenPrev) PURE;
  40. STDMETHOD(GetPrev) (THIS_ LPENUMGENERIC FAR* ppEnumGenPrev) PURE;
  41. };
  42. /****** Generic Enumerator Callback Interface *****************************/
  43. #define LPENUMCALLBACK IEnumCallback FAR*
  44. #undef INTERFACE
  45. #define INTERFACE IEnumCallback
  46. DECLARE_INTERFACE_(IEnumCallback, IUnknown)
  47. {
  48. //*** IUnknown methods ***/
  49. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  50. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  51. STDMETHOD_(ULONG,Release) (THIS) PURE;
  52. //*** IEnumCallback methods ***/
  53. STDMETHOD(Next) (THIS_ DWORD FAR* pdwCurrent,DWORD dwInfo,
  54. LPVOID FAR* ppNext) PURE;
  55. STDMETHOD(Skip) (THIS_ DWORD FAR* pdwCurrent,DWORD dwInfo) PURE;
  56. STDMETHOD(Reset) (THIS_ DWORD FAR* pdwCurrent) PURE;
  57. STDMETHOD(Clone) (THIS_ DWORD FAR* pdwCurrent) PURE;
  58. STDMETHOD(Destroy) (THIS_ DWORD dwCurrent) PURE;
  59. };
  60. /****** Generic Enumerator Holder Interface ******************************/
  61. #define LPENUMHOLDER IEnumHolder FAR*
  62. #undef INTERFACE
  63. #define INTERFACE IEnumHolder
  64. DECLARE_INTERFACE_(IEnumHolder, IUnknown)
  65. {
  66. //*** IUnknown methods ***/
  67. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  68. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  69. STDMETHOD_(ULONG,Release) (THIS) PURE;
  70. //*** IEnumHolder methods ***/
  71. STDMETHOD(CreateEnumerator)(THIS_ REFIID riid, DWORD dwInfo,
  72. LPENUMCALLBACK pEnumCallback,
  73. LPVOID FAR* ppGenericEnumerator) PURE;
  74. STDMETHOD(UpdateEnumerators)(THIS_ REFIID riid, DWORD dwCurrent,
  75. DWORD dwNew) PURE;
  76. STDMETHOD(RemoveEnumerator)(THIS_ LPENUMGENERIC pEnumGeneric) PURE;
  77. STDMETHOD(EnumeratorCount)(THIS_ WORD FAR* pwCount) PURE;
  78. };
  79. STDAPI CreateEnumHolder(LPENUMHOLDER FAR* ppEnumHolder);
  80. /****** CEnumList class *************************************/
  81. class FAR CEnumHolder : public IEnumHolder, public CPrivAlloc {
  82. public:
  83. //*** IUnknown methods ***/
  84. STDMETHOD(QueryInterface) (REFIID riid, LPLPVOID ppvObj);
  85. STDMETHOD_(ULONG,AddRef) ();
  86. STDMETHOD_(ULONG,Release) ();
  87. //*** IEnumHolder methods ***/
  88. STDMETHOD(CreateEnumerator)(REFIID riid, DWORD dwInfo,
  89. LPENUMCALLBACK pEnumCallback,
  90. LPLPVOID ppGenericEnumerator);
  91. STDMETHOD(UpdateEnumerators)(REFIID riid, DWORD dwCurrent,
  92. DWORD dwNew);
  93. STDMETHOD(RemoveEnumerator)(LPENUMGENERIC pEnumGeneric);
  94. STDMETHOD(EnumeratorCount)(WORD FAR* pwCount);
  95. STDSTATIC_(CEnumHolder FAR*) Create(void);
  96. ctor_dtor:
  97. CEnumHolder() { GET_A5(); m_nCount = 0; m_refs = 0; m_pFirst = NULL; m_pLast = NULL; }
  98. ~CEnumHolder() {}
  99. private:
  100. ULONG m_refs;
  101. WORD m_nCount;
  102. LPENUMGENERIC m_pFirst;
  103. LPENUMGENERIC m_pLast;
  104. SET_A5;
  105. };
  106. /****** CEnumGeneric class *************************************/
  107. class FAR CEnumGeneric : public IEnumGeneric {
  108. public:
  109. //*** IUnknown methods ***/
  110. STDMETHOD(QueryInterface) (REFIID riid, LPLPVOID ppvObj);
  111. STDMETHOD_(ULONG,AddRef) ();
  112. STDMETHOD_(ULONG,Release) ();
  113. //*** IEnumGeneric methods ***/
  114. STDMETHOD(Next) (ULONG celt, LPVOID pArrayObjs, ULONG FAR* pceltFetched);
  115. STDMETHOD(Skip) (ULONG celt);
  116. STDMETHOD(Reset) ();
  117. STDMETHOD(Clone) (LPENUMGENERIC FAR* ppenm);
  118. //*** helper methods ***/
  119. STDMETHOD(UpdateEnumerator)(REFIID riid, DWORD dwCurrent, DWORD dwNew);
  120. STDMETHOD(SetCurrent) (DWORD dwCurrent);
  121. STDMETHOD(SetNext)(LPENUMGENERIC pNext);
  122. STDMETHOD(GetNext)(LPENUMGENERIC FAR* ppNext);
  123. STDMETHOD(SetPrev)(LPENUMGENERIC pPrev);
  124. STDMETHOD(GetPrev)(LPENUMGENERIC FAR* ppPrev);
  125. STDSTATIC_(CEnumGeneric FAR*) Create(LPENUMHOLDER pEnumHolder, REFIID riid,
  126. DWORD dwInfo, LPENUMCALLBACK pEnumCallback);
  127. ctor_dtor:
  128. CEnumGeneric() { GET_A5(); m_refs = 0; m_dwCurrent = 0; m_pNext = m_pPrev = NULL; }
  129. ~CEnumGeneric() {}
  130. private:
  131. IID m_iid;
  132. ULONG m_refs; // referance count, when 0 this object goes away
  133. DWORD m_dwCurrent;
  134. DWORD m_dwDirection; // extra information for enumerator
  135. LPENUMCALLBACK m_pEnumCallback; // callback proc to get the next element
  136. LPENUMHOLDER m_pParent; // pointer to the list which owns this object
  137. LPENUMGENERIC m_pNext; // pointer to the next guy in the list
  138. LPENUMGENERIC m_pPrev; // pointer to the prev guy in the list
  139. SET_A5;
  140. };
  141. #endif // __ENUMGEN_H__