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.

261 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1994-95 Microsoft Corporation
  3. Module Name:
  4. sstobj.cpp
  5. Abstract:
  6. Server statistic object implementation.
  7. Author:
  8. Don Ryan (donryan) 03-Mar-1995
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. --*/
  13. #include "stdafx.h"
  14. #include "llsmgr.h"
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char BASED_CODE THIS_FILE[] = __FILE__;
  18. #endif
  19. IMPLEMENT_DYNCREATE(CServerStatistic, CCmdTarget)
  20. BEGIN_MESSAGE_MAP(CServerStatistic, CCmdTarget)
  21. //{{AFX_MSG_MAP(CServerStatistic)
  22. // NOTE - the ClassWizard will add and remove mapping macros here.
  23. //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25. BEGIN_DISPATCH_MAP(CServerStatistic, CCmdTarget)
  26. //{{AFX_DISPATCH_MAP(CServerStatistic)
  27. DISP_PROPERTY_EX(CServerStatistic, "Application", GetApplication, SetNotSupported, VT_DISPATCH)
  28. DISP_PROPERTY_EX(CServerStatistic, "Parent", GetParent, SetNotSupported, VT_DISPATCH)
  29. DISP_PROPERTY_EX(CServerStatistic, "ServerName", GetServerName, SetNotSupported, VT_BSTR)
  30. DISP_PROPERTY_EX(CServerStatistic, "MaxUses", GetMaxUses, SetNotSupported, VT_I4)
  31. DISP_PROPERTY_EX(CServerStatistic, "HighMark", GetHighMark, SetNotSupported, VT_I4)
  32. //}}AFX_DISPATCH_MAP
  33. END_DISPATCH_MAP()
  34. CServerStatistic::CServerStatistic(
  35. CCmdTarget* pParent,
  36. LPCTSTR pEntry,
  37. DWORD dwFlags,
  38. long lMaxUses,
  39. long lHighMark
  40. )
  41. /*++
  42. Routine Description:
  43. Constructor for statistic object.
  44. Arguments:
  45. pParent - creator of object.
  46. pEntry - user or server product.
  47. dwFlags - details...
  48. lMaxUses - maximum number of uses on server.
  49. lHighMark - high water mark thus far.
  50. Return Values:
  51. None.
  52. --*/
  53. {
  54. EnableAutomation();
  55. #ifdef ENABLE_PARENT_CHECK
  56. ASSERT(pParent && pParent->IsKindOf(RUNTIME_CLASS(CProduct)));
  57. #endif // ENABLE_PARENT_CHECK
  58. m_pParent = pParent;
  59. ASSERT(pEntry && *pEntry);
  60. m_strEntry = pEntry;
  61. m_lMaxUses = lMaxUses;
  62. m_lHighMark = lHighMark;
  63. m_bIsPerServer = (dwFlags & LLS_FLAG_PRODUCT_PERSEAT) ? FALSE : TRUE;
  64. }
  65. CServerStatistic::~CServerStatistic()
  66. /*++
  67. Routine Description:
  68. Destructor for statistic object.
  69. Arguments:
  70. None.
  71. Return Values:
  72. None.
  73. --*/
  74. {
  75. //
  76. // Nothing to do here.
  77. //
  78. }
  79. void CServerStatistic::OnFinalRelease()
  80. /*++
  81. Routine Description:
  82. When the last reference for an automation object is released
  83. OnFinalRelease is called. This implementation deletes object.
  84. Arguments:
  85. None.
  86. Return Values:
  87. None.
  88. --*/
  89. {
  90. delete this;
  91. }
  92. LPDISPATCH CServerStatistic::GetApplication()
  93. /*++
  94. Routine Description:
  95. Returns the application object.
  96. Arguments:
  97. None.
  98. Return Values:
  99. VT_DISPATCH.
  100. --*/
  101. {
  102. return theApp.GetAppIDispatch();
  103. }
  104. long CServerStatistic::GetHighMark()
  105. /*++
  106. Routine Description:
  107. Returns number of accesses thus far.
  108. Arguments:
  109. None.
  110. Return Values:
  111. VT_I4.
  112. --*/
  113. {
  114. return m_lHighMark;
  115. }
  116. long CServerStatistic::GetMaxUses()
  117. /*++
  118. Routine Description:
  119. Returns number of accesses available.
  120. Arguments:
  121. None.
  122. Return Values:
  123. VT_I4.
  124. --*/
  125. {
  126. return m_lMaxUses;
  127. }
  128. LPDISPATCH CServerStatistic::GetParent()
  129. /*++
  130. Routine Description:
  131. Returns the parent of the object.
  132. Arguments:
  133. None.
  134. Return Values:
  135. VT_DISPATCH.
  136. --*/
  137. {
  138. return m_pParent ? m_pParent->GetIDispatch(TRUE) : NULL;
  139. }
  140. BSTR CServerStatistic::GetServerName()
  141. /*++
  142. Routine Description:
  143. Returns the name of server.
  144. Arguments:
  145. None.
  146. Return Values:
  147. VT_BSTR.
  148. --*/
  149. {
  150. return m_strEntry.AllocSysString();
  151. }