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.

275 lines
5.5 KiB

  1. #ifdef _DEBUG
  2. #define new DEBUG_NEW
  3. #endif
  4. //////////////////////////////////////////////////////////////////////
  5. // Operations
  6. //////////////////////////////////////////////////////////////////////
  7. inline void CEventContainer::AddEvents(EventArray& Events)
  8. {
  9. for( int i = 0; i < Events.GetSize(); i++ )
  10. {
  11. CEvent* pEvent = Events[i];
  12. AddEvent(pEvent);
  13. }
  14. }
  15. inline void CEventContainer::AddEvent(CEvent* pEvent)
  16. {
  17. if( !pEvent || ! GfxCheckObjPtr((CObject*)pEvent,CEvent) )
  18. {
  19. ASSERT(FALSE);
  20. return;
  21. }
  22. // by default, add the event to the container's event collection
  23. // only if another event with the same statusguid is not already there
  24. if( GetEventByGuid(pEvent->m_sStatusGuid) )
  25. {
  26. return;
  27. }
  28. m_Events.Add(pEvent);
  29. // determine if this container has a config object connected to it
  30. // if a config object is connected then
  31. // if the config object is the selected object then
  32. // add a results pane item to the results view for this event
  33. CHMObject* pObject = GetObjectPtr();
  34. if( pObject )
  35. {
  36. CScopePaneItem* pItem = pObject->IsSelected();
  37. if( pItem && GfxCheckObjPtr(pItem,CScopePaneItem) )
  38. {
  39. CResultsPaneView* pView = pItem->GetResultsPaneView();
  40. pView->AddItem(pEvent->CreateResultsPaneItem(pView));
  41. }
  42. }
  43. }
  44. inline CEvent* CEventContainer::GetEventByGuid(const CString& sGuid)
  45. {
  46. for( int i = 0; i < m_Events.GetSize(); i++ )
  47. {
  48. CEvent* pEvent = m_Events[i];
  49. if( pEvent && GfxCheckObjPtr((CObject*)pEvent,CEvent) )
  50. {
  51. if( pEvent->m_sStatusGuid == sGuid )
  52. {
  53. return pEvent;
  54. }
  55. }
  56. }
  57. return NULL;
  58. }
  59. inline void CEventContainer::DeleteEvent(int iIndex)
  60. {
  61. m_Events.RemoveAt(iIndex);
  62. }
  63. inline void CEventContainer::DeleteEvent(const CString& sStatusGuid)
  64. {
  65. for( int i = (int)m_Events.GetSize() - 1; i >= 0; i-- )
  66. {
  67. CEvent* pEvent = m_Events[i];
  68. if( pEvent && GfxCheckObjPtr((CObject*)pEvent,CEvent) )
  69. {
  70. if( ! pEvent->m_sStatusGuid.IsEmpty() && pEvent->m_sStatusGuid == sStatusGuid )
  71. {
  72. DeleteEvent(i);
  73. }
  74. }
  75. }
  76. }
  77. inline void CEventContainer::DeleteEvents()
  78. {
  79. for( int i = (int)m_Events.GetSize() - 1; i >= 0; i-- )
  80. {
  81. DeleteEvent(i);
  82. }
  83. }
  84. inline void CEventContainer::DeleteSystemEvents(const CString& sSystemName)
  85. {
  86. for( int i = (int)m_Events.GetSize() - 1; i >= 0; i-- )
  87. {
  88. CEvent* pEvent = m_Events[i];
  89. if( pEvent && GfxCheckObjPtr((CObject*)pEvent,CEvent) )
  90. {
  91. if( LPCTSTR(pEvent->m_sSystemName) )
  92. {
  93. if( pEvent->m_sSystemName.GetLength() && pEvent->m_sSystemName == sSystemName )
  94. {
  95. DeleteEvent(i);
  96. }
  97. }
  98. else
  99. {
  100. ASSERT(FALSE);
  101. }
  102. }
  103. }
  104. }
  105. inline int CEventContainer::GetEventCount()
  106. {
  107. return (int)m_Events.GetSize();
  108. }
  109. inline CEvent* CEventContainer::GetEvent(int iIndex)
  110. {
  111. if( iIndex < 0 )
  112. {
  113. return NULL;
  114. }
  115. if( iIndex > m_Events.GetUpperBound() )
  116. {
  117. return NULL;
  118. }
  119. return m_Events[iIndex];
  120. }
  121. inline CString CEventContainer::GetLastEventDTime()
  122. {
  123. CEvent* pEvent = GetEvent(GetEventCount()-1);
  124. if( ! pEvent )
  125. {
  126. return _T("");
  127. }
  128. return pEvent->GetEventLocalTime();
  129. }
  130. //////////////////////////////////////////////////////////////////////
  131. // Statistics Members
  132. //////////////////////////////////////////////////////////////////////
  133. inline void CEventContainer::AddStatistic(CStatistics* pStatistic)
  134. {
  135. if( ! pStatistic || ! GfxCheckObjPtr((CObject*)pStatistic,CStatistics) )
  136. {
  137. ASSERT(FALSE);
  138. return;
  139. }
  140. for( int i = 0; i < m_Statistics.GetSize(); i++ )
  141. {
  142. if( pStatistic->CompareTo(m_Statistics[i]) )
  143. {
  144. delete pStatistic;
  145. return;
  146. }
  147. }
  148. if( m_Statistics.GetSize() > 50 )
  149. {
  150. delete m_Statistics[0];
  151. m_Statistics.RemoveAt(0);
  152. }
  153. m_Statistics.Add(pStatistic);
  154. // determine if this container has a config object connected to it
  155. // if a config object is connected then
  156. // if the config object is the selected object then
  157. // add a results pane item to the results view for this event
  158. CHMObject* pObject = GetObjectPtr();
  159. if( pObject )
  160. {
  161. CHMScopeItem* pItem = (CHMScopeItem*)pObject->IsSelected();
  162. if( pItem && GfxCheckObjPtr(pItem,CHMScopeItem) )
  163. {
  164. CSplitPaneResultsView* pView = (CSplitPaneResultsView*)pItem->GetResultsPaneView();
  165. if( ! GfxCheckObjPtr(pView,CSplitPaneResultsView) )
  166. {
  167. ASSERT(FALSE);
  168. return;
  169. }
  170. pView->AddStatistic(this,pStatistic);
  171. }
  172. }
  173. }
  174. inline void CEventContainer::AddStatistics(StatsArray& Statistics)
  175. {
  176. for( int i = 0; i < Statistics.GetSize(); i++ )
  177. {
  178. AddStatistic(Statistics[i]);
  179. }
  180. }
  181. inline void CEventContainer::DeleteStatistics()
  182. {
  183. for( int i = (int)m_Statistics.GetSize()-1; i >= 0; i-- )
  184. {
  185. if( m_Statistics[i] && GfxCheckObjPtr((CObject*)m_Statistics[i],CStatistics) )
  186. {
  187. delete m_Statistics[i];
  188. m_Statistics.RemoveAt(i);
  189. }
  190. }
  191. }
  192. inline int CEventContainer::GetStatisticsCount()
  193. {
  194. return (int)m_Statistics.GetSize();
  195. }
  196. inline CStatistics* CEventContainer::GetStatistic(int iIndex)
  197. {
  198. if( iIndex < 0 )
  199. {
  200. return NULL;
  201. }
  202. if( iIndex > m_Statistics.GetUpperBound() )
  203. {
  204. return NULL;
  205. }
  206. return m_Statistics[iIndex];
  207. }
  208. //////////////////////////////////////////////////////////////////////
  209. // Configuration Association Members
  210. //////////////////////////////////////////////////////////////////////
  211. inline CHMObject* CEventContainer::GetObjectPtr()
  212. {
  213. if( ! m_pObject )
  214. {
  215. return NULL;
  216. }
  217. if( ! GfxCheckObjPtr(m_pObject,CHMObject) )
  218. {
  219. return NULL;
  220. }
  221. return m_pObject;
  222. }
  223. inline void CEventContainer::SetObjectPtr(CHMObject* pObject)
  224. {
  225. if( ! pObject )
  226. {
  227. m_pObject = NULL;
  228. return;
  229. }
  230. if( ! GfxCheckObjPtr(pObject,CHMObject) )
  231. {
  232. m_pObject = NULL;
  233. return;
  234. }
  235. m_pObject = pObject;
  236. }