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.

102 lines
2.4 KiB

  1. // COUNTERS.H
  2. //
  3. // Global performance counters for the nac
  4. //
  5. // Created 13-Nov-96 [JonT]
  6. #ifndef _COUNTERS_H
  7. #define _COUNTER_H
  8. #include <objbase.h>
  9. #include "icounter.h"
  10. // Interface pointer to counter manager object.
  11. // If this pointer is NULL, stats are not around (or not initialized)
  12. extern ICounterMgr* g_pCtrMgr;
  13. // Counter pointers. All available counters should be listed here
  14. extern ICounter* g_pctrVideoSend;
  15. extern ICounter* g_pctrVideoReceive;
  16. extern ICounter* g_pctrVideoSendBytes;
  17. extern ICounter* g_pctrVideoReceiveBytes;
  18. extern ICounter* g_pctrVideoSendLost;
  19. extern ICounter* g_pctrAudioSendBytes;
  20. extern ICounter* g_pctrAudioReceiveBytes;
  21. extern ICounter* g_pctrAudioSendLost;
  22. extern ICounter* g_pctrVideoCPUuse;
  23. extern ICounter* g_pctrVideoBWuse;
  24. extern ICounter* g_pctrAudioJBDelay;
  25. extern IReport* g_prptCallParameters;
  26. extern IReport* g_prptSystemSettings;
  27. // Helper function prototypes (COUNTER.CPP)
  28. extern "C" BOOL WINAPI InitCountersAndReports(void);
  29. extern "C" void WINAPI DoneCountersAndReports(void);
  30. // Function helpers (better than using macros)
  31. void __inline DEFINE_COUNTER(ICounter** ppctr, char* szName, DWORD dwFlags)
  32. {
  33. if (g_pCtrMgr->CreateCounter(ppctr) == S_OK)
  34. (*ppctr)->Initialize(szName, dwFlags);
  35. }
  36. void __inline DELETE_COUNTER(ICounter** ppctr)
  37. {
  38. ICounter* pctrT;
  39. if (*ppctr)
  40. {
  41. pctrT = *ppctr;
  42. *ppctr = NULL;
  43. pctrT->Release();
  44. }
  45. }
  46. void __inline UPDATE_COUNTER(ICounter* pctr, int nValue)
  47. {
  48. if (pctr)
  49. pctr->Update(nValue);
  50. }
  51. void __inline INIT_COUNTER_MAX(ICounter* pctr, int nMaxValue)
  52. {
  53. if (pctr)
  54. pctr->InitMax(nMaxValue);
  55. }
  56. void __inline DEFINE_REPORT(IReport** pprpt, char* szName, DWORD dwFlags)
  57. {
  58. if (g_pCtrMgr->CreateReport(pprpt) == S_OK)
  59. (*pprpt)->Initialize(szName, dwFlags);
  60. }
  61. void __inline DELETE_REPORT(IReport** pprpt)
  62. {
  63. IReport* prptT;
  64. if (*pprpt)
  65. {
  66. prptT = *pprpt;
  67. *pprpt = NULL;
  68. prptT->Release();
  69. }
  70. }
  71. void __inline DEFINE_REPORT_ENTRY(IReport* prpt, char* szName, DWORD dwIndex)
  72. {
  73. if (prpt)
  74. prpt->CreateEntry(szName, dwIndex);
  75. }
  76. void __inline UPDATE_REPORT_ENTRY(IReport* prpt, int nValue, DWORD dwIndex)
  77. {
  78. if (prpt)
  79. prpt->Update(nValue, dwIndex);
  80. }
  81. #endif // #ifndef _COUNTERS_H