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.

151 lines
4.1 KiB

  1. //******************************************************************************
  2. //
  3. // AGGREG.H
  4. //
  5. // Copyright (C) 1996-1999 Microsoft Corporation
  6. //
  7. //******************************************************************************
  8. #ifndef __WBEM_AGGREGATOR__H_
  9. #define __WBEM_AGGREGATOR__H_
  10. #include <stdio.h>
  11. #include <wbemcomn.h>
  12. #include "tss.h"
  13. #include "binding.h"
  14. #include <evaltree.h>
  15. #include "postpone.h"
  16. class CEventAggregator : public COwnedEventSink
  17. {
  18. protected:
  19. long m_lNumProperties; // immutable
  20. CPropertyName* m_aProperties; // immutable
  21. double m_fTolerance; // immutable
  22. CEssNamespace* m_pNamespace; // immutable
  23. CEvalTree* m_pHavingTree; // immutable
  24. CCritSec m_cs;
  25. static IWbemClassObject* mstatic_pClass;
  26. class CBucket
  27. {
  28. protected:
  29. IWbemEvent* m_pRepresentative;
  30. DWORD m_dwCount;
  31. CVarVector* m_pvvData;
  32. public:
  33. CBucket(IWbemEvent* pEvent, CVarVector* pvvData);
  34. ~CBucket();
  35. BOOL CompareTo(CVarVector& vv);
  36. HRESULT AddEvent(IWbemEvent* pEvent);
  37. HRESULT MakeAggregateEvent(IWbemEvent** ppAggEvent) NOCS;
  38. CBucket* Clone();
  39. };
  40. class CBucketInstruction : public CTimerInstruction
  41. {
  42. long m_lRefCount;
  43. CEventAggregator* m_pAggregator;
  44. CBucket* m_pBucket;
  45. CWbemInterval m_Interval;
  46. public:
  47. CBucketInstruction(CEventAggregator* pAggregator, CBucket* pBucket,
  48. double fMsTimeout);
  49. ~CBucketInstruction();
  50. INTERNAL CEventAggregator* GetAggregator() {return m_pAggregator;}
  51. void AddRef();
  52. void Release();
  53. int GetInstructionType();
  54. CWbemTime GetNextFiringTime(CWbemTime LastFiringTime,
  55. OUT long* plFiringCount) const;
  56. CWbemTime GetFirstFiringTime() const;
  57. HRESULT Fire(long lNumTimes, CWbemTime NextFiringTime);
  58. };
  59. class CAggregatorInstructionTest : public CInstructionTest
  60. {
  61. CEventAggregator* m_pAgg;
  62. public:
  63. CAggregatorInstructionTest(CEventAggregator* pAgg) : m_pAgg(pAgg){}
  64. BOOL operator()(CTimerInstruction* pToTest);
  65. };
  66. friend CBucket;
  67. friend CBucketInstruction;
  68. CUniquePointerArray<CBucket> m_apBuckets; // changes
  69. public:
  70. CEventAggregator(CEssNamespace* pNamespace, CAbstractEventSink* pDest);
  71. ~CEventAggregator();
  72. HRESULT Deactivate(bool bFire);
  73. HRESULT SetQueryExpression(CContextMetaData* pMeta,
  74. QL_LEVEL_1_RPN_EXPRESSION* pExpr);
  75. HRESULT CopyStateTo(CEventAggregator* pOther);
  76. HRESULT Indicate(long lNumEvents, IWbemEvent** apEvents,
  77. CEventContext* pContext);
  78. CEventFilter* GetEventFilter() {return m_pOwner->GetEventFilter();}
  79. public:
  80. static HRESULT Initialize(IWbemServices* pNamespace);
  81. static HRESULT Shutdown();
  82. protected:
  83. HRESULT DispatchBucket(CBucket* pBucket);
  84. HRESULT ComputeAggregationVector(IN IWbemEvent* pEvent,
  85. OUT CVarVector& vv);
  86. HRESULT Process(IWbemEvent* pEvent);
  87. HRESULT AddEventToBucket(IWbemEvent* pEvent,
  88. ACQUIRE CVarVector* pvv, CBucket** ppCreatedBucket);
  89. HRESULT PostponeFireAllBuckets();
  90. HRESULT FireEvent(IWbemClassObject* pAggEvent, bool bRightNow);
  91. HRESULT PostponeDispatchFirstBucket();
  92. HRESULT PostponeIndicate(CAbstractEventSink* pDest, IWbemEvent* pEvent);
  93. };
  94. class CPostponedIndicate : public CPostponedRequest
  95. {
  96. protected:
  97. CAbstractEventSink* m_pDest;
  98. IWbemEvent* m_pEvent;
  99. public:
  100. CPostponedIndicate(CAbstractEventSink* pDest, IWbemEvent* pEvent)
  101. : m_pDest(pDest), m_pEvent(pEvent)
  102. {
  103. if(m_pDest)
  104. m_pDest->AddRef();
  105. if(m_pEvent)
  106. m_pEvent->AddRef();
  107. }
  108. ~CPostponedIndicate()
  109. {
  110. if(m_pDest)
  111. m_pDest->Release();
  112. if(m_pEvent)
  113. m_pEvent->Release();
  114. }
  115. HRESULT Execute(CEssNamespace* pNamespace)
  116. {
  117. // BUGBUG: context
  118. if(m_pDest)
  119. return m_pDest->Indicate(1, &m_pEvent, NULL);
  120. else
  121. return WBEM_E_OUT_OF_MEMORY;
  122. }
  123. };
  124. #endif