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.

169 lines
3.6 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // SITE.CPP
  6. //
  7. // alanbos 28-Jun-98 Created.
  8. //
  9. // Defines the WBEM site implementation
  10. //
  11. //***************************************************************************
  12. #include "precomp.h"
  13. ULONG CWbemSite::AddRef(void)
  14. {
  15. InterlockedIncrement(&m_cRef);
  16. return m_cRef;
  17. }
  18. ULONG CWbemSite::Release(void)
  19. {
  20. InterlockedDecrement(&m_cRef);
  21. if (0L!=m_cRef)
  22. return m_cRef;
  23. delete this;
  24. return 0;
  25. }
  26. //***************************************************************************
  27. //
  28. // CWbemObjectSite::CWbemObjectSite
  29. //
  30. // DESCRIPTION:
  31. //
  32. // Constructor
  33. //
  34. //***************************************************************************
  35. CWbemObjectSite::CWbemObjectSite (ISWbemInternalObject *pObject)
  36. {
  37. m_pSWbemObject = pObject;
  38. if (m_pSWbemObject)
  39. m_pSWbemObject->AddRef ();
  40. }
  41. //***************************************************************************
  42. //
  43. // CWbemObjectSite::~CWbemObjectSite
  44. //
  45. // DESCRIPTION:
  46. //
  47. // Destructor
  48. //
  49. //***************************************************************************
  50. CWbemObjectSite::~CWbemObjectSite ()
  51. {
  52. if (m_pSWbemObject)
  53. m_pSWbemObject->Release ();
  54. }
  55. //***************************************************************************
  56. //
  57. // CWbemObjectSite::Update
  58. //
  59. // DESCRIPTION:
  60. //
  61. // Overriden virtual method to update this site
  62. //
  63. //***************************************************************************
  64. void CWbemObjectSite::Update ()
  65. {
  66. if (m_pSWbemObject)
  67. m_pSWbemObject->UpdateSite ();
  68. }
  69. //***************************************************************************
  70. //
  71. // CWbemPropertySite::CWbemPropertySite
  72. //
  73. // DESCRIPTION:
  74. //
  75. // Constructor
  76. //
  77. //***************************************************************************
  78. CWbemPropertySite::CWbemPropertySite (CSWbemProperty *pProperty,
  79. IWbemClassObject *pSourceObject,
  80. long index)
  81. {
  82. m_pSWbemProperty = pProperty;
  83. m_pIWbemClassObject = pSourceObject;
  84. m_index = index;
  85. if (m_pSWbemProperty)
  86. m_pSWbemProperty->AddRef ();
  87. if (m_pIWbemClassObject)
  88. m_pIWbemClassObject->AddRef ();
  89. }
  90. //***************************************************************************
  91. //
  92. // CWbemPropertySite::~CWbemPropertySite
  93. //
  94. // DESCRIPTION:
  95. //
  96. // Destructor
  97. //
  98. //***************************************************************************
  99. CWbemPropertySite::~CWbemPropertySite ()
  100. {
  101. if (m_pSWbemProperty)
  102. m_pSWbemProperty->Release ();
  103. if (m_pIWbemClassObject)
  104. m_pIWbemClassObject->Release ();
  105. }
  106. //***************************************************************************
  107. //
  108. // CWbemPropertySite::Update
  109. //
  110. // DESCRIPTION:
  111. //
  112. // Overriden virtual method to update this site
  113. //
  114. //***************************************************************************
  115. void CWbemPropertySite::Update ()
  116. {
  117. if (m_pSWbemProperty)
  118. {
  119. if (m_pIWbemClassObject)
  120. {
  121. /*
  122. * Case 1 this property site is for an object;
  123. * we have an embedded object deal. We commit the
  124. * new embedded object value to its owning property
  125. * in the parent object.
  126. */
  127. // Get the current value of the source object into a VARIANT:
  128. VARIANT var;
  129. VariantInit (&var);
  130. var.vt = VT_UNKNOWN;
  131. var.punkVal = m_pIWbemClassObject;
  132. m_pIWbemClassObject->AddRef ();
  133. // Set the value in the parent object
  134. m_pSWbemProperty->UpdateEmbedded (var, m_index);
  135. // Release the value
  136. VariantClear (&var);
  137. }
  138. else
  139. {
  140. // Addressed by a qualifier - nothing to do
  141. }
  142. // Now delegate further to property to update itself.
  143. if (m_pSWbemProperty)
  144. m_pSWbemProperty->UpdateSite ();
  145. }
  146. }