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.

165 lines
4.0 KiB

  1. //***************************************************************************
  2. //
  3. // BASE.CPP
  4. //
  5. // Module: HEALTHMON SERVER AGENT
  6. //
  7. // Purpose: Abstract base class for CSystem, CDataGroup, CDataCollector, CThreshold and CAction
  8. //
  9. // Copyright (c)1999 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #include "base.h"
  13. extern HMODULE g_hModule;
  14. // STATIC DATA
  15. HRLLIST CBase::mg_hrlList;
  16. ILIST CBase::mg_DGEventList;
  17. ILIST CBase::mg_DCEventList;
  18. ILIST CBase::mg_DCPerInstanceEventList;
  19. ILIST CBase::mg_TEventList;
  20. //ILIST CBase::mg_TIEventList;
  21. ILIST CBase::mg_DCStatsEventList;
  22. ILIST CBase::mg_DCStatsInstList;
  23. TCHAR CBase::m_szDTCurrTime[512];
  24. TCHAR CBase::m_szCurrTime[512];
  25. //STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC
  26. void CBase::CalcCurrTime(void)
  27. {
  28. TCHAR szTemp[512];
  29. SYSTEMTIME st; // system time
  30. // Formatted as follows -> "20000814135809.000000+***"
  31. GetSystemTime(&st);
  32. swprintf(m_szDTCurrTime, L"%04d%02d%02d%02d%02d%02d.000000+000",
  33. st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
  34. // GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SLONGDATE, szTemp, 100);
  35. // GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, szTemp, 100);
  36. m_szCurrTime[0] = '\0';
  37. // GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, szTemp, m_szCurrTime, 100);
  38. GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, m_szCurrTime, 100);
  39. GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, szTemp, 100);
  40. wcscat(m_szCurrTime, L" ");
  41. wcscat(m_szCurrTime, szTemp);
  42. return;
  43. }
  44. //STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC
  45. void CBase::CleanupHRLList(void)
  46. {
  47. HRLSTRUCT *phrl;
  48. int iSize;
  49. int i;
  50. // Since this is a global shared array, we need to do this
  51. // in a static function.
  52. iSize = mg_hrlList.size();
  53. for (i = 0; i < iSize ; i++)
  54. {
  55. MY_ASSERT(i<mg_hrlList.size());
  56. phrl = &mg_hrlList[i];
  57. FreeLibrary(phrl->hResLib);
  58. }
  59. }
  60. void CBase::CleanupEventLists(void)
  61. {
  62. int i, iSize;
  63. IWbemClassObject* pInstance = NULL;
  64. // Since this is a global shared array, we need to do this
  65. // in a static function.
  66. iSize = mg_DGEventList.size();
  67. for (i=0; i < iSize; i++)
  68. {
  69. MY_ASSERT(i<mg_DGEventList.size());
  70. pInstance = mg_DGEventList[i];
  71. pInstance->Release();
  72. pInstance = NULL;
  73. }
  74. mg_DGEventList.clear();
  75. iSize = mg_DCEventList.size();
  76. for (i=0; i < iSize; i++)
  77. {
  78. MY_ASSERT(i<mg_DCEventList.size());
  79. pInstance = mg_DCEventList[i];
  80. pInstance->Release();
  81. pInstance = NULL;
  82. }
  83. mg_DCEventList.clear();
  84. iSize = mg_DCPerInstanceEventList.size();
  85. for (i=0; i < iSize; i++)
  86. {
  87. MY_ASSERT(i<mg_DCPerInstanceEventList.size());
  88. pInstance = mg_DCPerInstanceEventList[i];
  89. pInstance->Release();
  90. pInstance = NULL;
  91. }
  92. mg_DCPerInstanceEventList.clear();
  93. iSize = mg_TEventList.size();
  94. for (i=0; i < iSize; i++)
  95. {
  96. MY_ASSERT(i<mg_TEventList.size());
  97. pInstance = mg_TEventList[i];
  98. pInstance->Release();
  99. pInstance = NULL;
  100. }
  101. mg_TEventList.clear();
  102. #ifdef SAVE
  103. iSize = mg_TIEventList.size();
  104. for (i=0; i < iSize; i++)
  105. {
  106. MY_ASSERT(i<mg_TIEventList.size());
  107. pInstance = mg_TIEventList[i];
  108. pInstance->Release();
  109. pInstance = NULL;
  110. }
  111. mg_TIEventList.clear();
  112. #endif
  113. iSize = mg_DCStatsEventList.size();
  114. for (i=0; i < iSize; i++)
  115. {
  116. MY_ASSERT(i<mg_DCStatsEventList.size());
  117. pInstance = mg_DCStatsEventList[i];
  118. pInstance->Release();
  119. pInstance = NULL;
  120. }
  121. mg_DCStatsEventList.clear();
  122. iSize = mg_DCStatsInstList.size();
  123. for (i=0; i < iSize; i++)
  124. {
  125. MY_ASSERT(i<mg_DCStatsInstList.size());
  126. pInstance = mg_DCStatsInstList[i];
  127. pInstance->Release();
  128. pInstance = NULL;
  129. }
  130. mg_DCStatsInstList.clear();
  131. }
  132. //////////////////////////////////////////////////////////////////////
  133. //////////////////////////////////////////////////////////////////////
  134. // Construction/Destruction
  135. //////////////////////////////////////////////////////////////////////
  136. CBase::CBase()
  137. {
  138. // m_hResLib = NULL;
  139. }
  140. CBase::~CBase()
  141. {
  142. MY_OUTPUT(L"ENTER ***** CBaseDestuctor...", 1);
  143. }