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.

144 lines
3.8 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. FILTSINK.H
  5. Abstract:
  6. History:
  7. --*/
  8. #include <providl.h>
  9. #include <unk.h>
  10. #include <parmdefs.h>
  11. #include "arrtempl.h"
  12. #include <metadata.h>
  13. class CAnySink
  14. {
  15. public:
  16. virtual RELEASE_ME IHmmFilter* GetFilter() = 0;
  17. virtual HRESULT Send(IHmmClassObject* pObject) = 0;
  18. virtual HRESULT Send(IHmmPropertySource* pSource,
  19. IHmmPropertyList* pList) = 0;
  20. };
  21. class CAnySinkContainer
  22. {
  23. public:
  24. virtual long AddMember(CAnySink* pSink) = 0;
  25. virtual BOOL RemoveMember(long lIndex) = 0;
  26. virtual BOOL RemoveMember(CAnySink* pSink) = 0;
  27. virtual INTERNAL GetMember(long lIndex) = 0;
  28. };
  29. class CAnySinkLocation
  30. {
  31. public:
  32. virtual BOOL RemoveSink(CAnySink* pSink) = 0;
  33. };
  34. class CAnySinkLocations
  35. {
  36. public:
  37. virtual void AddLocation(CAnySinkLocation* pLocation) = 0;
  38. };
  39. class CFilteringSink : public CUnk, public CAnySink, public CAnySinkContainer,
  40. public CAnySinkLocation
  41. {
  42. protected:
  43. class XEventSink : public CImpl<IHmmEventSink, CFilteringSink>
  44. {
  45. public:
  46. XEventSink(CFilteringSink* pObj)
  47. : CImpl<IHmmEventSink, CFilteringSink>(pObj)
  48. {}
  49. STDMETHOD(Indicate)(
  50. long lNumObjects,
  51. IHmmClassObject **apObjects);
  52. STDMETHOD(IndicateRaw)(
  53. long lNumObjects,
  54. IHmmPropertySource **apObjects);
  55. STDMETHOD(IndicateWithHint)(
  56. long lNumObjects,
  57. IHmmClassObject *pObject,
  58. IUnknown *pHint);
  59. STDMETHOD(CheckObject)(
  60. IHmmPropertySource *pSource,
  61. IHmmPropertyList **ppList,
  62. IUnknown **ppHint);
  63. STDMETHOD(GetRequirements)(
  64. IHmmFilter **ppRequirements);
  65. STDMETHOD(SetRequirementChangeSink)(
  66. IHmmRequirementChangeSink *pNewSink,
  67. IHmmRequirementChangeSink **ppOldSink);
  68. STDMETHOD(GetOptimizedSink)(
  69. IHmmFilter *pGuaranteedCondition,
  70. long lFlags,
  71. IHmmEventSink **ppOptimizedSink);
  72. STDMETHOD(GetUsefulSubsink)(
  73. long lIndex,
  74. long lFlags,
  75. IHmmEventSink **ppSubsink);
  76. } m_XEventSink;
  77. friend XEventSink;
  78. protected:
  79. CUniquePointerArray<CAnySink> m_apMembers;
  80. IHmmFilter* m_pFrontFilter;
  81. IHmmFilter* m_pGuaranteedFilter;
  82. IHmmRequirementChangeSink* m_pChangeSink;
  83. CMetaData* m_pMeta;
  84. protected:
  85. inline void NotifyChanged(IHmmEventSink* pOld, IHmmEventSink* pNew){}
  86. inline void NotifyChanged(IHmmFilter* pOld, IHmmFilter* pNew){}
  87. HRESULT CheckAndSend(IHmmPropertySource* pSource, BOOL bSend,
  88. IHmmPropertyList** ppList, IUnknown** ppHint);
  89. public:
  90. CFilteringSink(CMetaData* pMeta, CLifeControl* pControl = NULL,
  91. IUnknown* pOuter = NULL)
  92. : CUnk(pControl, pOuter), m_XEventSink(this), m_pFrontFilter(NULL),
  93. m_pChangeSink(NULL), m_pMeta(pMeta)
  94. {}
  95. ~CFilteringSink();
  96. void* GetInterface(REFIID riid);
  97. // AnySinkContainer methods
  98. BOOL AddMember(CAnySink* pSink, CAnySinkLocations* pLocations);
  99. BOOL RemoveMember(long lIndex);
  100. BOOL RemoveMember(CAnySink* pSink);
  101. CAnySink* GetMember(long lIndex);
  102. void SetFrontFilter(IHmmFilter* pFilter);
  103. void SetGuaranteedFilter(IHmmFilter* pFilter);
  104. // AnySink methods
  105. RELEASE_ME IHmmFilter* GetFilter()
  106. {return NULL;} // TBD
  107. HRESULT Send(IHmmClassObject* pObject)
  108. {return m_XEventSink.Indicate(1, &pObject);}
  109. HRESULT Send(IHmmPropertySource* pSource, IHmmPropertyList* pList)
  110. {return m_XEventSink.IndicateRaw(1, &pSource);}
  111. // AnySinkLocation methods
  112. BOOL RemoveSink(CAnySink* pSink) {return RemoveMember(pSink);}
  113. };