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.

168 lines
2.1 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. WMICLASS.CPP
  5. History:
  6. --*/
  7. //
  8. // Implementation file for the WMI MOF parser IClassFactory object.
  9. //
  10. #include "precomp.h"
  11. #include "stdafx.h"
  12. #include "WMIparse.h"
  13. #include "resource.h"
  14. #include "WMIlprs.h"
  15. #include "WMIclass.h"
  16. CWMILocClassFactory::CWMILocClassFactory()
  17. {
  18. m_uiRefCount = 0;
  19. AddRef();
  20. IncrementClassCount();
  21. }
  22. #ifdef _DEBUG
  23. void
  24. CWMILocClassFactory::AssertValid(void)
  25. const
  26. {
  27. CLObject::AssertValid();
  28. }
  29. void
  30. CWMILocClassFactory::Dump(
  31. CDumpContext &dc)
  32. const
  33. {
  34. CLObject::Dump(dc);
  35. }
  36. #endif // _DEBUG
  37. ULONG
  38. CWMILocClassFactory::AddRef(void)
  39. {
  40. return ++m_uiRefCount;
  41. }
  42. ULONG
  43. CWMILocClassFactory::Release(void)
  44. {
  45. LTASSERT(m_uiRefCount != 0);
  46. m_uiRefCount--;
  47. if (m_uiRefCount == 0)
  48. {
  49. delete this;
  50. return 0;
  51. }
  52. return m_uiRefCount;
  53. }
  54. HRESULT
  55. CWMILocClassFactory::QueryInterface(
  56. REFIID iid,
  57. LPVOID *ppvObj)
  58. {
  59. SCODE sc = E_NOINTERFACE;
  60. *ppvObj = NULL;
  61. if (iid == IID_IUnknown)
  62. {
  63. *ppvObj = (IUnknown *)this;
  64. sc = S_OK;
  65. }
  66. else if (iid == IID_IClassFactory)
  67. {
  68. *ppvObj = (IClassFactory *)this;
  69. sc = S_OK;
  70. }
  71. if (sc == S_OK)
  72. {
  73. AddRef();
  74. }
  75. return ResultFromScode(sc);
  76. }
  77. HRESULT
  78. CWMILocClassFactory::CreateInstance(
  79. LPUNKNOWN pUnknown,
  80. REFIID iid,
  81. LPVOID *ppvObj)
  82. {
  83. SCODE sc = E_UNEXPECTED;
  84. *ppvObj = NULL;
  85. if (pUnknown != NULL)
  86. {
  87. sc = CLASS_E_NOAGGREGATION;
  88. }
  89. else
  90. {
  91. try
  92. {
  93. CWMILocParser *pParser;
  94. pParser = new CWMILocParser;
  95. sc = pParser->QueryInterface(iid, ppvObj);
  96. pParser->Release();
  97. }
  98. catch (CMemoryException *pMemoryException)
  99. {
  100. sc = E_OUTOFMEMORY;
  101. pMemoryException->Delete();
  102. }
  103. }
  104. return ResultFromScode(sc);
  105. }
  106. HRESULT
  107. CWMILocClassFactory::LockServer(
  108. BOOL)
  109. {
  110. return E_NOTIMPL;
  111. }
  112. CWMILocClassFactory::~CWMILocClassFactory()
  113. {
  114. LTASSERT(m_uiRefCount == 0);
  115. DEBUGONLY(AssertValid());
  116. DecrementClassCount();
  117. }