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.

358 lines
9.5 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: InstallationUnitProvider.cpp
  4. //
  5. // Synopsis: Defines an InstallationUnitProvider
  6. // An InstallationUnitProvider manages the global
  7. // InstallationUnits for each service that can be
  8. // installed.
  9. //
  10. // History: 02/05/2001 JeffJon Created
  11. #include "pch.h"
  12. #include "InstallationUnitProvider.h"
  13. static InstallationUnitProvider* installationUnitProvider = 0;
  14. InstallationUnitProvider&
  15. InstallationUnitProvider::GetInstance()
  16. {
  17. if (!installationUnitProvider)
  18. {
  19. installationUnitProvider = new InstallationUnitProvider();
  20. installationUnitProvider->Init();
  21. }
  22. ASSERT(installationUnitProvider);
  23. return *installationUnitProvider;
  24. }
  25. InstallationUnitProvider::InstallationUnitProvider() :
  26. currentInstallationUnit(0),
  27. initialized(false)
  28. {
  29. LOG_CTOR(InstallationUnitProvider);
  30. }
  31. InstallationUnitProvider::~InstallationUnitProvider()
  32. {
  33. LOG_DTOR(InstallationUnitProvider);
  34. // Delete all the installation units
  35. for(
  36. InstallationUnitContainerType::iterator itr =
  37. installationUnitContainer.begin();
  38. itr != installationUnitContainer.end();
  39. ++itr)
  40. {
  41. if ((*itr).second)
  42. {
  43. delete (*itr).second;
  44. }
  45. }
  46. installationUnitContainer.clear();
  47. }
  48. void
  49. InstallationUnitProvider::Init()
  50. {
  51. LOG_FUNCTION(InstallationUnitProvider::Init);
  52. if (!initialized)
  53. {
  54. // Create one of each type of installation unit
  55. installationUnitContainer.insert(
  56. std::make_pair(DHCP_INSTALL, new DHCPInstallationUnit()));
  57. installationUnitContainer.insert(
  58. std::make_pair(DNS_INSTALL, new DNSInstallationUnit()));
  59. installationUnitContainer.insert(
  60. std::make_pair(WINS_INSTALL, new WINSInstallationUnit()));
  61. installationUnitContainer.insert(
  62. std::make_pair(RRAS_INSTALL, new RRASInstallationUnit()));
  63. installationUnitContainer.insert(
  64. std::make_pair(NETWORKSERVER_INSTALL, new NetworkServerInstallationUnit()));
  65. installationUnitContainer.insert(
  66. std::make_pair(APPLICATIONSERVER_INSTALL, new ApplicationInstallationUnit()));
  67. installationUnitContainer.insert(
  68. std::make_pair(FILESERVER_INSTALL, new FileInstallationUnit()));
  69. installationUnitContainer.insert(
  70. std::make_pair(PRINTSERVER_INSTALL, new PrintInstallationUnit()));
  71. installationUnitContainer.insert(
  72. std::make_pair(SHAREPOINT_INSTALL, new SharePointInstallationUnit()));
  73. installationUnitContainer.insert(
  74. std::make_pair(MEDIASERVER_INSTALL, new MediaInstallationUnit()));
  75. installationUnitContainer.insert(
  76. std::make_pair(WEBSERVER_INSTALL, new WebInstallationUnit()));
  77. installationUnitContainer.insert(
  78. std::make_pair(EXPRESS_INSTALL, new ExpressInstallationUnit()));
  79. installationUnitContainer.insert(
  80. std::make_pair(DC_INSTALL, new ADInstallationUnit()));
  81. installationUnitContainer.insert(
  82. std::make_pair(CLUSTERSERVER_INSTALL, new ClusterInstallationUnit()));
  83. // Mark as initialized
  84. initialized = true;
  85. }
  86. }
  87. void
  88. InstallationUnitProvider::Destroy()
  89. {
  90. LOG_FUNCTION(InstallationUnitProvider::Destroy);
  91. if (installationUnitProvider)
  92. {
  93. delete installationUnitProvider;
  94. installationUnitProvider = 0;
  95. }
  96. }
  97. void
  98. InstallationUnitProvider::SetCurrentInstallationUnit(
  99. InstallationUnitType installationUnitType)
  100. {
  101. LOG_FUNCTION(InstallationUnitProvider::SetCurrentInstallationUnit);
  102. currentInstallationUnit = (*(installationUnitContainer.find(installationUnitType))).second;
  103. }
  104. InstallationUnit&
  105. InstallationUnitProvider::GetCurrentInstallationUnit()
  106. {
  107. LOG_FUNCTION(InstallationUnitProvider::GetCurrentInstallationUnit);
  108. ASSERT(currentInstallationUnit);
  109. return *currentInstallationUnit;
  110. }
  111. InstallationUnit&
  112. InstallationUnitProvider::GetInstallationUnitForType(
  113. InstallationUnitType installationUnitType)
  114. {
  115. LOG_FUNCTION(InstallationUnitProvider::GetInstallationUnitForType);
  116. InstallationUnit* result = (*(installationUnitContainer.find(installationUnitType))).second;
  117. ASSERT(result);
  118. return *result;
  119. }
  120. DHCPInstallationUnit&
  121. InstallationUnitProvider::GetDHCPInstallationUnit()
  122. {
  123. LOG_FUNCTION(InstallationUnitProvider::GetDHCPInstallationUnit);
  124. DHCPInstallationUnit* dhcpInstallationUnit =
  125. dynamic_cast<DHCPInstallationUnit*>((*(installationUnitContainer.find(DHCP_INSTALL))).second);
  126. ASSERT(dhcpInstallationUnit);
  127. return *dhcpInstallationUnit;
  128. }
  129. DNSInstallationUnit&
  130. InstallationUnitProvider::GetDNSInstallationUnit()
  131. {
  132. LOG_FUNCTION(InstallationUnitProvider::GetDNSInstallationUnit);
  133. DNSInstallationUnit* dnsInstallationUnit =
  134. dynamic_cast<DNSInstallationUnit*>((*(installationUnitContainer.find(DNS_INSTALL))).second);
  135. ASSERT(dnsInstallationUnit);
  136. return *dnsInstallationUnit;
  137. }
  138. WINSInstallationUnit&
  139. InstallationUnitProvider::GetWINSInstallationUnit()
  140. {
  141. LOG_FUNCTION(InstallationUnitProvider::GetWINSInstallationUnit);
  142. WINSInstallationUnit* winsInstallationUnit =
  143. dynamic_cast<WINSInstallationUnit*>((*(installationUnitContainer.find(WINS_INSTALL))).second);
  144. ASSERT(winsInstallationUnit);
  145. return *winsInstallationUnit;
  146. }
  147. RRASInstallationUnit&
  148. InstallationUnitProvider::GetRRASInstallationUnit()
  149. {
  150. LOG_FUNCTION(InstallationUnitProvider::GetRRASInstallationUnit);
  151. RRASInstallationUnit* rrasInstallationUnit =
  152. dynamic_cast<RRASInstallationUnit*>((*(installationUnitContainer.find(RRAS_INSTALL))).second);
  153. ASSERT(rrasInstallationUnit);
  154. return *rrasInstallationUnit;
  155. }
  156. NetworkServerInstallationUnit&
  157. InstallationUnitProvider::GetNetworkServerInstallationUnit()
  158. {
  159. LOG_FUNCTION(InstallationUnitProvider::GetNetworkServerInstallationUnit);
  160. NetworkServerInstallationUnit* networkServerInstallationUnit =
  161. dynamic_cast<NetworkServerInstallationUnit*>(
  162. (*(installationUnitContainer.find(NETWORKSERVER_INSTALL))).second);
  163. ASSERT(networkServerInstallationUnit);
  164. return *networkServerInstallationUnit;
  165. }
  166. ApplicationInstallationUnit&
  167. InstallationUnitProvider::GetApplicationInstallationUnit()
  168. {
  169. LOG_FUNCTION(InstallationUnitProvider::GetApplicationInstallationUnit);
  170. ApplicationInstallationUnit* applicationInstallationUnit =
  171. dynamic_cast<ApplicationInstallationUnit*>(
  172. (*(installationUnitContainer.find(APPLICATIONSERVER_INSTALL))).second);
  173. ASSERT(applicationInstallationUnit);
  174. return *applicationInstallationUnit;
  175. }
  176. FileInstallationUnit&
  177. InstallationUnitProvider::GetFileInstallationUnit()
  178. {
  179. LOG_FUNCTION(InstallationUnitProvider::GetFileInstallationUnit);
  180. FileInstallationUnit* fileInstallationUnit =
  181. dynamic_cast<FileInstallationUnit*>(
  182. (*(installationUnitContainer.find(FILESERVER_INSTALL))).second);
  183. ASSERT(fileInstallationUnit);
  184. return *fileInstallationUnit;
  185. }
  186. PrintInstallationUnit&
  187. InstallationUnitProvider::GetPrintInstallationUnit()
  188. {
  189. LOG_FUNCTION(InstallationUnitProvider::GetPrintInstallationUnit);
  190. PrintInstallationUnit* printInstallationUnit =
  191. dynamic_cast<PrintInstallationUnit*>(
  192. (*(installationUnitContainer.find(PRINTSERVER_INSTALL))).second);
  193. ASSERT(printInstallationUnit);
  194. return *printInstallationUnit;
  195. }
  196. SharePointInstallationUnit&
  197. InstallationUnitProvider::GetSharePointInstallationUnit()
  198. {
  199. LOG_FUNCTION(InstallationUnitProvider::GetSharePointInstallationUnit);
  200. SharePointInstallationUnit* sharePointInstallationUnit =
  201. dynamic_cast<SharePointInstallationUnit*>(
  202. (*(installationUnitContainer.find(SHAREPOINT_INSTALL))).second);
  203. ASSERT(sharePointInstallationUnit);
  204. return *sharePointInstallationUnit;
  205. }
  206. MediaInstallationUnit&
  207. InstallationUnitProvider::GetMediaInstallationUnit()
  208. {
  209. LOG_FUNCTION(InstallationUnitProvider::GetMediaInstallationUnit);
  210. MediaInstallationUnit* mediaInstallationUnit =
  211. dynamic_cast<MediaInstallationUnit*>(
  212. (*(installationUnitContainer.find(MEDIASERVER_INSTALL))).second);
  213. ASSERT(mediaInstallationUnit);
  214. return *mediaInstallationUnit;
  215. }
  216. WebInstallationUnit&
  217. InstallationUnitProvider::GetWebInstallationUnit()
  218. {
  219. LOG_FUNCTION(InstallationUnitProvider::GetWebInstallationUnit);
  220. WebInstallationUnit* webInstallationUnit =
  221. dynamic_cast<WebInstallationUnit*>(
  222. (*(installationUnitContainer.find(WEBSERVER_INSTALL))).second);
  223. ASSERT(webInstallationUnit);
  224. return *webInstallationUnit;
  225. }
  226. ExpressInstallationUnit&
  227. InstallationUnitProvider::GetExpressInstallationUnit()
  228. {
  229. LOG_FUNCTION(InstallationUnitProvider::GetExpressInstallationUnit);
  230. ExpressInstallationUnit* expressInstallationUnit =
  231. dynamic_cast<ExpressInstallationUnit*>(
  232. (*(installationUnitContainer.find(EXPRESS_INSTALL))).second);
  233. ASSERT(expressInstallationUnit);
  234. return *expressInstallationUnit;
  235. }
  236. ADInstallationUnit&
  237. InstallationUnitProvider::GetADInstallationUnit()
  238. {
  239. LOG_FUNCTION(InstallationUnitProvider::GetADInstallationUnit);
  240. ADInstallationUnit* adInstallationUnit =
  241. dynamic_cast<ADInstallationUnit*>(
  242. (*(installationUnitContainer.find(DC_INSTALL))).second);
  243. ASSERT(adInstallationUnit);
  244. return *adInstallationUnit;
  245. }
  246. ClusterInstallationUnit&
  247. InstallationUnitProvider::GetClusterInstallationUnit()
  248. {
  249. LOG_FUNCTION(InstallationUnitProvider::GetClusterInstallationUnit);
  250. ClusterInstallationUnit* clusterInstallationUnit =
  251. dynamic_cast<ClusterInstallationUnit*>(
  252. (*(installationUnitContainer.find(CLUSTERSERVER_INSTALL))).second);
  253. ASSERT(clusterInstallationUnit);
  254. return *clusterInstallationUnit;
  255. }