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.

199 lines
4.9 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 1997-1998 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: sdocoremgr.h
  6. //
  7. // Project: Everest
  8. //
  9. // Description: IAS Core Manager
  10. //
  11. // Log:
  12. //
  13. // When Who What
  14. // ---- --- ----
  15. // 6/08/98 TLP Initial Version
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18. #ifndef __INC_IAS_SDO_CORE_MGR_H
  19. #define __INC_IAS_SDO_CORE_MGR_H
  20. #include "sdobasedefs.h"
  21. #include "sdocomponentmgr.h"
  22. #include "sdopipemgr.h"
  23. ///////////////////////////////////////////////////////////////////
  24. // IAS Service Status
  25. typedef enum IAS_SERVICE_STATUS
  26. {
  27. IAS_SERVICE_STATUS_STARTED = 0x100,
  28. IAS_SERVICE_STATUS_STOPPED = 0x200
  29. } IAS_SERVICE_STATUS;
  30. ///////////////////////////////////////////////////////////////////
  31. // IAS Core Manager
  32. class CCoreMgr
  33. {
  34. friend CCoreMgr& GetCoreManager(void);
  35. private:
  36. ///////////////////////////////////////////////////////////////////
  37. // Start of nested Class - Service Status
  38. //
  39. class CServiceStatus
  40. {
  41. enum _MAX_SERVICES { MAX_SERVICES = 16 };
  42. typedef struct _SERVICEINFO
  43. {
  44. IAS_SERVICE_STATUS eStatus;
  45. SERVICE_TYPE eType;
  46. } SERVICEINFO;
  47. #define DEFINE_IAS_SERVICES() \
  48. DWORD i = 0; \
  49. memset(&m_ServiceInfo, 0, sizeof(SERVICEINFO) * MAX_SERVICES);
  50. #define INIT_IAS_SERVICE(Type) \
  51. _ASSERT( i < MAX_SERVICES ); \
  52. m_ServiceInfo[i].eStatus = IAS_SERVICE_STATUS_STOPPED; \
  53. m_ServiceInfo[i].eType = Type; \
  54. i++;
  55. public:
  56. //////////////////////////////////////////////////////////////////////
  57. void SetServiceStatus(SERVICE_TYPE eType, IAS_SERVICE_STATUS eStatus)
  58. {
  59. DWORD i;
  60. for ( i = 0; i < MAX_SERVICES; i++ )
  61. {
  62. if ( m_ServiceInfo[i].eType == eType )
  63. {
  64. m_ServiceInfo[i].eStatus = eStatus;
  65. return;
  66. }
  67. }
  68. _ASSERT(FALSE);
  69. }
  70. //////////////////////////////////////////////////////////////////////
  71. bool IsServiceStarted(SERVICE_TYPE eType) const
  72. {
  73. DWORD i;
  74. for ( i = 0; i < MAX_SERVICES; i++ )
  75. {
  76. if ( m_ServiceInfo[i].eType == eType )
  77. {
  78. return ( m_ServiceInfo[i].eStatus == IAS_SERVICE_STATUS_STARTED ? true : false );
  79. }
  80. }
  81. return false;
  82. }
  83. //////////////////////////////////////////////////////////////////////
  84. bool IsAnyServiceStarted()
  85. {
  86. DWORD i;
  87. for ( i = 0; i < MAX_SERVICES; i++ )
  88. {
  89. if ( m_ServiceInfo[i].eStatus == IAS_SERVICE_STATUS_STARTED )
  90. return true;
  91. }
  92. return false;
  93. }
  94. private:
  95. // Constructed by the core manager
  96. //
  97. friend class CCoreMgr;
  98. CServiceStatus()
  99. {
  100. // Initialize the IAS service information
  101. //
  102. DEFINE_IAS_SERVICES();
  103. INIT_IAS_SERVICE(SERVICE_TYPE_IAS);
  104. INIT_IAS_SERVICE(SERVICE_TYPE_RAS);
  105. // New Service Here...
  106. }
  107. SERVICEINFO m_ServiceInfo[MAX_SERVICES];
  108. }; // End of nested class CServiceStatus
  109. public:
  110. CCoreMgr();
  111. CCoreMgr(CCoreMgr& theCore);
  112. CCoreMgr& operator = (CCoreMgr& theCore);
  113. HRESULT StartService(SERVICE_TYPE ServiceType);
  114. HRESULT StopService(SERVICE_TYPE ServiceType);
  115. HRESULT UpdateConfiguration(void);
  116. private:
  117. IASDATASTORE GetDataStore(void);
  118. HRESULT InitializeComponents(void);
  119. void ShutdownComponents(void);
  120. HRESULT InitializeAuditors(ISdo* pSdoService);
  121. HRESULT ConfigureAuditors(ISdo* pSdoService);
  122. void ShutdownAuditors(void);
  123. HRESULT InitializeProtocols(ISdo* pSdoService);
  124. HRESULT ConfigureProtocols(ISdo* pSdoService);
  125. void ShutdownProtocols(void);
  126. bool AddComponent(LONG Id, ComponentPtr& cp, ComponentMap& damap)
  127. {
  128. try
  129. {
  130. pair<ComponentMapIterator, bool> thePair;
  131. thePair = damap.insert(ComponentMap::value_type(Id, cp));
  132. return thePair.second;
  133. }
  134. catch(...)
  135. {
  136. }
  137. return false;
  138. }
  139. ////////////////////////////////////////
  140. typedef enum _CORESTATE
  141. {
  142. CORE_STATE_SHUTDOWN,
  143. CORE_STATE_INITIALIZED
  144. } CORESTATE;
  145. CORESTATE m_eCoreState;
  146. PipelineMgr m_PipelineMgr;
  147. ComponentMap m_Auditors;
  148. ComponentMap m_Protocols;
  149. CServiceStatus m_ServiceStatus;
  150. };
  151. ////////////////////////
  152. // Core manager accessor
  153. CCoreMgr& GetCoreManager(void);
  154. #endif // __INC_IAS_SDO_CORE_MGR_H