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.

184 lines
3.8 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: samplver.cpp
  4. //
  5. // Copyright (C) 1994-1997 Microsoft Corporation All rights reserved.
  6. //
  7. // Implementation of the ILocVersion interface.
  8. //
  9. //-----------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "dllvars.h"
  12. #include "samplver.h"
  13. #include "misc.h"
  14. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  15. //
  16. // Constructor for Version interface. Set up my reference count, and note
  17. // who my parent is. Assume that my parent has already been AddRef()'d.
  18. // Also note that the total class count has gone up.
  19. //
  20. //-----------------------------------------------------------------------------
  21. CLocSamplVersion::CLocSamplVersion(
  22. IUnknown *pParent)
  23. {
  24. m_ulRefCount = 0;
  25. m_pParent = pParent;
  26. AddRef();
  27. IncrementClassCount();
  28. }
  29. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  30. //
  31. // Bump my reference count.
  32. //
  33. //-----------------------------------------------------------------------------
  34. ULONG
  35. CLocSamplVersion::AddRef(void)
  36. {
  37. return ++m_ulRefCount;
  38. }
  39. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  40. //
  41. // Dec. my reference count. If it goes to zero, delete myself AND Release()
  42. // my parent.
  43. //
  44. //-----------------------------------------------------------------------------
  45. ULONG
  46. CLocSamplVersion::Release(void)
  47. {
  48. LTASSERT(m_ulRefCount != 0);
  49. m_ulRefCount--;
  50. if (m_ulRefCount == 0)
  51. {
  52. m_pParent->Release();
  53. delete this;
  54. return 0;
  55. }
  56. return m_ulRefCount;
  57. }
  58. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  59. //
  60. // Return an interface. IID_ILocVersion is me, everything else is handed
  61. // off to my parent ie. this implements delegation.
  62. //
  63. //-----------------------------------------------------------------------------
  64. HRESULT
  65. CLocSamplVersion::QueryInterface(
  66. REFIID iid,
  67. LPVOID *ppvObj)
  68. {
  69. SCODE scResult = E_NOINTERFACE;
  70. *ppvObj = NULL;
  71. if (iid == IID_ILocVersion)
  72. {
  73. *ppvObj = (ILocVersion *)this;
  74. scResult = S_OK;
  75. AddRef();
  76. return ResultFromScode(scResult);
  77. }
  78. else
  79. {
  80. return m_pParent->QueryInterface(iid, ppvObj);
  81. }
  82. }
  83. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  84. //
  85. // Return the parser version number. This is really the version of Esputil
  86. // and PBase that we compiled against ie the version number of the Parser
  87. // SDK.
  88. //
  89. //-----------------------------------------------------------------------------
  90. void
  91. CLocSamplVersion::GetParserVersion(
  92. DWORD &dwMajor,
  93. DWORD &dwMinor,
  94. BOOL &fDebug)
  95. const
  96. {
  97. dwMajor = dwCurrentMajorVersion;
  98. dwMinor = dwCurrentMinorVersion;
  99. fDebug = fCurrentDebugMode;
  100. }
  101. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  102. //
  103. // Debuging interface.
  104. //
  105. //-----------------------------------------------------------------------------
  106. void
  107. CLocSamplVersion::AssertValidInterface(void)
  108. const
  109. {
  110. DEBUGONLY(AssertValid());
  111. }
  112. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  113. //
  114. // Destructor. Simply note that the total class count is lower.
  115. //
  116. //-----------------------------------------------------------------------------
  117. CLocSamplVersion::~CLocSamplVersion()
  118. {
  119. DEBUGONLY(AssertValid());
  120. LTASSERT(m_ulRefCount == 0);
  121. DecrementClassCount();
  122. }
  123. #ifdef _DEBUG
  124. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  125. //
  126. // Debugging methods.
  127. //
  128. //-----------------------------------------------------------------------------
  129. void
  130. CLocSamplVersion::AssertValid(void)
  131. const
  132. {
  133. CLObject::AssertValid();
  134. }
  135. void
  136. CLocSamplVersion::Dump(
  137. CDumpContext &dc)
  138. const
  139. {
  140. CLObject::Dump(dc);
  141. }
  142. #endif // _DEBUG