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.

199 lines
4.8 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved
  3. Module Name:
  4. Wsbcltn.h
  5. Abstract:
  6. These classes provide support for collections (lists) of "collectable"
  7. objects.
  8. Author:
  9. Chuck Bardeen [cbardeen] 29-Oct-1996
  10. Revision History:
  11. --*/
  12. #include "resource.h"
  13. #include "Wsbpstbl.h"
  14. #ifndef _WSBCLTN_
  15. #define _WSBCLTN_
  16. /*++
  17. Class Name:
  18. CWsbCollection
  19. Class Description:
  20. A collection of objects.
  21. --*/
  22. class CWsbCollection :
  23. public CWsbPersistStream,
  24. public IWsbCollection,
  25. public IWsbTestable
  26. {
  27. // CComObjectRoot
  28. public:
  29. STDMETHOD(FinalConstruct)(void);
  30. void FinalRelease(void);
  31. // IWsbCollection
  32. public:
  33. STDMETHOD(Contains)(IUnknown* pCollectable);
  34. STDMETHOD(GetEntries)(ULONG* pEntries);
  35. STDMETHOD(Find)(IUnknown* pCollectable, REFIID riid, void** ppElement);
  36. STDMETHOD(IsEmpty)(void);
  37. STDMETHOD(IsLocked)(void);
  38. STDMETHOD(Lock)(void);
  39. STDMETHOD(OccurencesOf)(IUnknown* pCollectable, ULONG* occurences);
  40. STDMETHOD(RemoveAndRelease)(IUnknown* pCollectable);
  41. STDMETHOD(Unlock)(void);
  42. // IWsbTestable
  43. public:
  44. STDMETHOD(Test)(USHORT *passed, USHORT *failed);
  45. protected:
  46. ULONG m_entries;
  47. CRITICAL_SECTION m_CritSec;
  48. };
  49. #define WSB_FROM_CWSBCOLLECTION \
  50. STDMETHOD(Contains)(IUnknown* pCollectable) \
  51. {return(CWsbCollection::Contains(pCollectable));}; \
  52. STDMETHOD(GetEntries)(ULONG* pEntries) \
  53. {return(CWsbCollection::GetEntries(pEntries));}; \
  54. STDMETHOD(Find)(IUnknown* pCollectable, REFIID riid, void** ppElement) \
  55. {return(CWsbCollection::Find(pCollectable, riid, ppElement));}; \
  56. STDMETHOD(IsEmpty)(void) \
  57. {return(CWsbCollection::IsEmpty());}; \
  58. STDMETHOD(IsLocked)(void) \
  59. {return(CWsbCollection::IsLocked());}; \
  60. STDMETHOD(Lock)(void) \
  61. {return(CWsbCollection::Lock());}; \
  62. STDMETHOD(OccurencesOf)(IUnknown* pCollectable, ULONG* occurences) \
  63. {return(CWsbCollection::OccurencesOf(pCollectable, occurences));}; \
  64. STDMETHOD(RemoveAndRelease)(IUnknown* pCollectable) \
  65. {return(CWsbCollection::RemoveAndRelease(pCollectable));}; \
  66. STDMETHOD(Unlock)(void) \
  67. {return(CWsbCollection::Unlock());}; \
  68. /*++
  69. Class Name:
  70. CWsbIndexedCollection
  71. Class Description:
  72. A indexed collection of objects.
  73. --*/
  74. class CWsbIndexedCollection :
  75. public IWsbIndexedCollection,
  76. public CWsbCollection
  77. {
  78. // IWsbCollection
  79. public:
  80. WSB_FROM_CWSBCOLLECTION;
  81. // IWsbIndexedCollection
  82. public:
  83. STDMETHOD(Add)(IUnknown* pCollectable);
  84. STDMETHOD(Append)(IUnknown* pCollectable);
  85. STDMETHOD(First)(REFIID riid, void** ppElement);
  86. STDMETHOD(Index)(IUnknown* pCollectable, ULONG* index);
  87. STDMETHOD(Last)(REFIID riid, void** ppElement);
  88. STDMETHOD(Prepend)(IUnknown* pCollectable);
  89. STDMETHOD(Remove)(IUnknown* pCollectable, REFIID riid, void** ppElement);
  90. STDMETHOD(RemoveAllAndRelease)(void);
  91. STDMETHOD(Enum)(IWsbEnum** ppEnum);
  92. STDMETHOD(EnumUnknown)(IEnumUnknown** ppEnum);
  93. // IWsbTestable
  94. public:
  95. STDMETHOD(Test)(USHORT *passed, USHORT *failed);
  96. };
  97. /*++
  98. Class Name:
  99. CWsbOrderedCollection
  100. Class Description:
  101. An ordered collection of objects.
  102. --*/
  103. class CWsbOrderedCollection :
  104. public CWsbIndexedCollection,
  105. public CComCoClass<CWsbOrderedCollection,&CLSID_CWsbOrderedCollection>
  106. {
  107. public:
  108. CWsbOrderedCollection() {}
  109. BEGIN_COM_MAP(CWsbOrderedCollection)
  110. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  111. COM_INTERFACE_ENTRY(IPersistStream)
  112. COM_INTERFACE_ENTRY2(IWsbCollection, IWsbIndexedCollection)
  113. COM_INTERFACE_ENTRY(IWsbIndexedCollection)
  114. COM_INTERFACE_ENTRY(IWsbPersistStream)
  115. COM_INTERFACE_ENTRY(IWsbTestable)
  116. END_COM_MAP()
  117. DECLARE_REGISTRY_RESOURCEID(IDR_CWsbOrderedCollection)
  118. // CComObjectRoot
  119. public:
  120. STDMETHOD(FinalConstruct)(void);
  121. void FinalRelease(void);
  122. // IWsbIndexedCollection
  123. STDMETHOD(AddAt)(IUnknown* pCollectable, ULONG index);
  124. STDMETHOD(At)(ULONG index, REFIID riid, void** ppElement);
  125. STDMETHOD(Copy)(ULONG start, ULONG stop, REFIID riid, void** rgElement, ULONG* pElementFetched);
  126. STDMETHOD(CopyIfMatches)(ULONG start, ULONG stop, IUnknown* pCollectable, ULONG element, REFIID riid, void** rgElement, ULONG* pElementFetched, ULONG* pStoppedAt);
  127. STDMETHOD(RemoveAt)(ULONG index, REFIID riid, void** ppElement);
  128. // IPersist
  129. public:
  130. STDMETHOD(GetClassID)(LPCLSID pclsid);
  131. // IPersistStream
  132. public:
  133. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pSize);
  134. STDMETHOD(Load)(IStream* pStream);
  135. STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
  136. // IWsbTestable
  137. public:
  138. STDMETHOD(Test)(USHORT *passed, USHORT *failed) {
  139. return(CWsbIndexedCollection::Test(passed, failed));
  140. };
  141. protected:
  142. ULONG m_maxEntries;
  143. ULONG m_growBy;
  144. IWsbCollectable** m_pCollectable;
  145. };
  146. #endif // _WSBCLTN_