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.

200 lines
5.1 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. BOOL m_bCritSecCreated;
  49. };
  50. #define WSB_FROM_CWSBCOLLECTION \
  51. STDMETHOD(Contains)(IUnknown* pCollectable) \
  52. {return(CWsbCollection::Contains(pCollectable));}; \
  53. STDMETHOD(GetEntries)(ULONG* pEntries) \
  54. {return(CWsbCollection::GetEntries(pEntries));}; \
  55. STDMETHOD(Find)(IUnknown* pCollectable, REFIID riid, void** ppElement) \
  56. {return(CWsbCollection::Find(pCollectable, riid, ppElement));}; \
  57. STDMETHOD(IsEmpty)(void) \
  58. {return(CWsbCollection::IsEmpty());}; \
  59. STDMETHOD(IsLocked)(void) \
  60. {return(CWsbCollection::IsLocked());}; \
  61. STDMETHOD(Lock)(void) \
  62. {return(CWsbCollection::Lock());}; \
  63. STDMETHOD(OccurencesOf)(IUnknown* pCollectable, ULONG* occurences) \
  64. {return(CWsbCollection::OccurencesOf(pCollectable, occurences));}; \
  65. STDMETHOD(RemoveAndRelease)(IUnknown* pCollectable) \
  66. {return(CWsbCollection::RemoveAndRelease(pCollectable));}; \
  67. STDMETHOD(Unlock)(void) \
  68. {return(CWsbCollection::Unlock());}; \
  69. /*++
  70. Class Name:
  71. CWsbIndexedCollection
  72. Class Description:
  73. A indexed collection of objects.
  74. --*/
  75. class CWsbIndexedCollection :
  76. public IWsbIndexedCollection,
  77. public CWsbCollection
  78. {
  79. // IWsbCollection
  80. public:
  81. WSB_FROM_CWSBCOLLECTION;
  82. // IWsbIndexedCollection
  83. public:
  84. STDMETHOD(Add)(IUnknown* pCollectable);
  85. STDMETHOD(Append)(IUnknown* pCollectable);
  86. STDMETHOD(First)(REFIID riid, void** ppElement);
  87. STDMETHOD(Index)(IUnknown* pCollectable, ULONG* index);
  88. STDMETHOD(Last)(REFIID riid, void** ppElement);
  89. STDMETHOD(Prepend)(IUnknown* pCollectable);
  90. STDMETHOD(Remove)(IUnknown* pCollectable, REFIID riid, void** ppElement);
  91. STDMETHOD(RemoveAllAndRelease)(void);
  92. STDMETHOD(Enum)(IWsbEnum** ppEnum);
  93. STDMETHOD(EnumUnknown)(IEnumUnknown** ppEnum);
  94. // IWsbTestable
  95. public:
  96. STDMETHOD(Test)(USHORT *passed, USHORT *failed);
  97. };
  98. /*++
  99. Class Name:
  100. CWsbOrderedCollection
  101. Class Description:
  102. An ordered collection of objects.
  103. --*/
  104. class CWsbOrderedCollection :
  105. public CWsbIndexedCollection,
  106. public CComCoClass<CWsbOrderedCollection,&CLSID_CWsbOrderedCollection>
  107. {
  108. public:
  109. CWsbOrderedCollection() {}
  110. BEGIN_COM_MAP(CWsbOrderedCollection)
  111. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  112. COM_INTERFACE_ENTRY(IPersistStream)
  113. COM_INTERFACE_ENTRY2(IWsbCollection, IWsbIndexedCollection)
  114. COM_INTERFACE_ENTRY(IWsbIndexedCollection)
  115. COM_INTERFACE_ENTRY(IWsbPersistStream)
  116. COM_INTERFACE_ENTRY(IWsbTestable)
  117. END_COM_MAP()
  118. DECLARE_REGISTRY_RESOURCEID(IDR_CWsbOrderedCollection)
  119. // CComObjectRoot
  120. public:
  121. STDMETHOD(FinalConstruct)(void);
  122. void FinalRelease(void);
  123. // IWsbIndexedCollection
  124. STDMETHOD(AddAt)(IUnknown* pCollectable, ULONG index);
  125. STDMETHOD(At)(ULONG index, REFIID riid, void** ppElement);
  126. STDMETHOD(Copy)(ULONG start, ULONG stop, REFIID riid, void** rgElement, ULONG* pElementFetched);
  127. STDMETHOD(CopyIfMatches)(ULONG start, ULONG stop, IUnknown* pCollectable, ULONG element, REFIID riid, void** rgElement, ULONG* pElementFetched, ULONG* pStoppedAt);
  128. STDMETHOD(RemoveAt)(ULONG index, REFIID riid, void** ppElement);
  129. // IPersist
  130. public:
  131. STDMETHOD(GetClassID)(LPCLSID pclsid);
  132. // IPersistStream
  133. public:
  134. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pSize);
  135. STDMETHOD(Load)(IStream* pStream);
  136. STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
  137. // IWsbTestable
  138. public:
  139. STDMETHOD(Test)(USHORT *passed, USHORT *failed) {
  140. return(CWsbIndexedCollection::Test(passed, failed));
  141. };
  142. protected:
  143. ULONG m_maxEntries;
  144. ULONG m_growBy;
  145. IWsbCollectable** m_pCollectable;
  146. };
  147. #endif // _WSBCLTN_