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.

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