statinfo.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:22k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #include "safestring.h"
  36. #include "hxtypes.h"
  37. #include "hxresult.h"
  38. #include "hxcom.h"
  39. #include "hxcomm.h"
  40. #include "hxbuffer.h"
  41. #include "hxmon.h"
  42. #include "hxstrutl.h"
  43. #include "watchlst.h"
  44. #include "statinfo.h"
  45. #include "hxheap.h"
  46. #ifdef _DEBUG
  47. #undef HX_THIS_FILE
  48. static const char HX_THIS_FILE[] = __FILE__;
  49. #endif
  50. CStatisticEntry::CStatisticEntry(IHXRegistry*    pRegistry,
  51.  char*     pszRegKey,
  52.  UINT32     ulType)
  53.     : m_bAddKey(FALSE)
  54.     , m_ulRegistryID(0)
  55.     , m_pRegistry(NULL)
  56.     , m_ulType(REG_TYPE_UNKNOWN)
  57. {
  58.     if (pRegistry)
  59.     {
  60. m_pRegistry = pRegistry;
  61. m_pRegistry->AddRef();
  62. m_ulType = ulType;
  63. /*
  64.  * Check to see if this Registry ID already exists
  65.          */
  66. m_ulRegistryID = m_pRegistry->GetId(pszRegKey);
  67. if (!m_ulRegistryID)
  68. {
  69.     m_bAddKey = TRUE;
  70.     if (REG_TYPE_STRING == ulType)
  71.     {
  72. m_ulRegistryID = m_pRegistry->AddStr(pszRegKey, NULL);
  73.     }
  74.     else if (REG_TYPE_NUMBER == ulType)
  75.     {
  76. m_ulRegistryID = m_pRegistry->AddInt(pszRegKey, 0);
  77.     }
  78.     else if (REG_TYPE_COMPOSITE == ulType)
  79.     {
  80. m_ulRegistryID = m_pRegistry->AddComp(pszRegKey);
  81.     }     
  82.     else
  83.     {
  84. m_ulType = REG_TYPE_UNKNOWN;
  85. m_ulRegistryID = 0;
  86.     }
  87. }
  88.     }
  89.     else
  90.     {
  91. m_pRegistry = NULL;
  92. m_ulRegistryID = 0;
  93.     }
  94. }
  95. CStatisticEntry::~CStatisticEntry(void)
  96. {
  97.     if (m_pRegistry)
  98.     {
  99. if (m_ulRegistryID && m_bAddKey)
  100. {
  101.     m_pRegistry->DeleteById(m_ulRegistryID);
  102.     m_ulRegistryID = 0;
  103. }
  104. m_pRegistry->Release();
  105. m_pRegistry = NULL;
  106.     }
  107. }
  108. HX_RESULT
  109. CStatisticEntry::SetInt(INT32 lValue)
  110. {    
  111.     HX_RESULT theErr = HXR_OK;
  112.     if (!m_pRegistry || !m_ulRegistryID ||
  113. (REG_TYPE_NUMBER != m_ulType))
  114.     {
  115. theErr = HXR_FAILED;
  116. goto cleanup;
  117.     }
  118.     theErr = m_pRegistry->SetIntById(m_ulRegistryID, lValue);
  119. cleanup:
  120.     
  121.     return theErr;
  122. }
  123. HX_RESULT
  124. CStatisticEntry::SetStr(char* pszValue)
  125. {    
  126.     IHXBuffer* pValue = NULL;
  127.     HX_RESULT theErr = HXR_OK;
  128.     if (!m_pRegistry || !m_ulRegistryID ||
  129. (REG_TYPE_STRING != m_ulType))
  130.     {
  131. theErr = HXR_FAILED;
  132. goto cleanup;
  133.     }
  134.     if (NULL == pszValue)
  135.     {
  136. theErr = m_pRegistry->SetStrById(m_ulRegistryID, NULL);
  137.     }
  138.     else
  139.     {
  140. if (!(pValue = new CHXBuffer()))
  141. {
  142.     theErr = HXR_OUTOFMEMORY;
  143.     goto cleanup;
  144. }
  145. pValue->AddRef();
  146. pValue->Set((const UCHAR*)pszValue, strlen(pszValue)+1);
  147. theErr = m_pRegistry->SetStrById(m_ulRegistryID, pValue);
  148. pValue->Release();
  149.     }
  150. cleanup:
  151.     
  152.     return theErr;
  153. }
  154. INT32
  155. CStatisticEntry::GetInt(void)
  156. {
  157.     INT32 lValue = 0;
  158.     if (!m_pRegistry || !m_ulRegistryID || (REG_TYPE_NUMBER != m_ulType))
  159.     {
  160. goto cleanup;
  161.     }
  162.     m_pRegistry->GetIntById(m_ulRegistryID, lValue);
  163.    
  164. cleanup:
  165.     return lValue;
  166. }
  167. char*
  168. CStatisticEntry::GetStr(void)
  169. {
  170.     HX_RESULT theErr = HXR_OK;
  171.     IHXBuffer* pValue = NULL;
  172.     char*       pszValue = new char[MAX_DISPLAY_NAME];
  173.     if (!pszValue || !m_pRegistry || !m_ulRegistryID || (REG_TYPE_STRING != m_ulType))
  174.     {
  175. theErr = HXR_UNEXPECTED;
  176. goto cleanup;
  177.     }
  178.     if (HXR_OK != m_pRegistry->GetStrById(m_ulRegistryID, pValue) || !pValue)
  179.     {
  180. theErr = HXR_UNEXPECTED;
  181. goto cleanup;
  182.     }
  183.     SafeStrCpy(pszValue, (const char*)pValue->GetBuffer(), MAX_DISPLAY_NAME);
  184.     
  185. cleanup:
  186.     HX_RELEASE(pValue);
  187.     if (HXR_OK != theErr)
  188.     {
  189. if (pszValue) delete [] pszValue;
  190. pszValue = NULL;
  191. return NULL;
  192.     }
  193.     return pszValue;
  194. }
  195. STATS::STATS(IHXRegistry* /*IN*/  pRegistry,
  196.      UINT32      /*IN*/  ulRegistryID)
  197.     : m_pRegistry(NULL)
  198.     , m_ulRegistryID(0)
  199.     , m_bInitialized(FALSE)
  200.     , m_lastError(HXR_OK)
  201.     , m_pNormal(0)
  202.     , m_pRecovered(0)
  203.     , m_pReceived(0)
  204.     , m_pOutOfOrder(0)
  205.     , m_pLost(0)
  206.     , m_pLate(0)
  207.     , m_pDuplicate(0)
  208.     , m_pTotal(0)
  209.     , m_pLost30(0)
  210.     , m_pTotal30(0)
  211.     , m_pResendRequested(0)
  212.     , m_pResendReceived(0)
  213.     , m_pClipBandwidth(0)
  214.     , m_pAvgBandwidth(0)
  215.     , m_pCurBandwidth(0)
  216.     , m_pHighLatency(0)
  217.     , m_pLowLatency(0)
  218.     , m_pAvgLatency(0)
  219. {
  220.     HX_RESULT theErr = HXR_OK;
  221.     IHXBuffer* pszParentName = NULL;
  222.     char szRegKeyName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */
  223.     if (!pRegistry)
  224.     {
  225. goto cleanup;
  226.     }
  227.     
  228.     m_pRegistry = pRegistry;
  229.     m_pRegistry->AddRef();
  230.  
  231.     m_ulRegistryID = ulRegistryID;
  232.     if (HXR_OK == m_pRegistry->GetPropName(m_ulRegistryID, pszParentName))
  233.     {
  234. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Normal", pszParentName->GetBuffer());
  235. if (!(m_pNormal = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  236. {
  237.     theErr = HXR_OUTOFMEMORY;
  238.     goto cleanup;
  239. }
  240. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Recovered", pszParentName->GetBuffer());
  241. if (!(m_pRecovered = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  242. {
  243.     theErr = HXR_OUTOFMEMORY;
  244.     goto cleanup;
  245. }
  246. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Received", pszParentName->GetBuffer());
  247. if (!(m_pReceived = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  248. {
  249.     theErr = HXR_OUTOFMEMORY;
  250.     goto cleanup;
  251. }
  252. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.OutOfOrder", pszParentName->GetBuffer());
  253. if (!(m_pOutOfOrder = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  254. {
  255.     theErr = HXR_OUTOFMEMORY;
  256.     goto cleanup;
  257. }
  258. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Lost", pszParentName->GetBuffer());
  259. if (!(m_pLost = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  260. {
  261.     theErr = HXR_OUTOFMEMORY;
  262.     goto cleanup;
  263. }
  264. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Late", pszParentName->GetBuffer());
  265. if (!(m_pLate = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  266. {
  267.     theErr = HXR_OUTOFMEMORY;
  268.     goto cleanup;
  269. }
  270. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Duplicate", pszParentName->GetBuffer());
  271. if (!(m_pDuplicate = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  272. {
  273.     theErr = HXR_OUTOFMEMORY;
  274.     goto cleanup;
  275. }
  276. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Total", pszParentName->GetBuffer());
  277. if (!(m_pTotal = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  278. {
  279.     theErr = HXR_OUTOFMEMORY;
  280.     goto cleanup;
  281. }
  282. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Lost30", pszParentName->GetBuffer());
  283. if (!(m_pLost30 = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  284. {
  285.     theErr = HXR_OUTOFMEMORY;
  286.     goto cleanup;
  287. }
  288. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Total30", pszParentName->GetBuffer());
  289. if (!(m_pTotal30 = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  290. {
  291.     theErr = HXR_OUTOFMEMORY;
  292.     goto cleanup;
  293. }
  294. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.ResendRequested", pszParentName->GetBuffer());
  295. if (!(m_pResendRequested = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  296. {
  297.     theErr = HXR_OUTOFMEMORY;
  298.     goto cleanup;
  299. }
  300. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.ResendReceived", pszParentName->GetBuffer());
  301. if (!(m_pResendReceived = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  302. {
  303.     theErr = HXR_OUTOFMEMORY;
  304.     goto cleanup;
  305. }
  306. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.ClipBandwidth", pszParentName->GetBuffer());
  307. if (!(m_pClipBandwidth = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  308. {
  309.     theErr = HXR_OUTOFMEMORY;
  310.     goto cleanup;
  311. }
  312. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.AverageBandwidth", pszParentName->GetBuffer());
  313. if (!(m_pAvgBandwidth = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  314. {
  315.     theErr = HXR_OUTOFMEMORY;
  316.     goto cleanup;
  317. }
  318. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.CurrentBandwidth", pszParentName->GetBuffer());
  319. if (!(m_pCurBandwidth = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  320. {
  321.     theErr = HXR_OUTOFMEMORY;
  322.     goto cleanup;
  323. }
  324. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.HighLatency", pszParentName->GetBuffer());
  325. if (!(m_pHighLatency = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  326. {
  327.     theErr = HXR_OUTOFMEMORY;
  328.     goto cleanup;
  329. }
  330. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.LowLatency", pszParentName->GetBuffer());
  331. if (!(m_pLowLatency = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  332. {
  333.     theErr = HXR_OUTOFMEMORY;
  334.     goto cleanup;
  335. }
  336. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.AverageLatency", pszParentName->GetBuffer());
  337. if (!(m_pAvgLatency = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  338. {
  339.     theErr = HXR_OUTOFMEMORY;
  340.     goto cleanup;
  341. }
  342.     }
  343.   
  344. cleanup:
  345.     HX_RELEASE(pszParentName);
  346.     if (HXR_OK == theErr)
  347.     {
  348. m_lastError = HXR_OK;
  349. m_bInitialized = TRUE;
  350.     }
  351.     else
  352.     {
  353. m_lastError = theErr;
  354. m_bInitialized = FALSE;
  355.     }
  356. }
  357. STATS::~STATS()
  358. {
  359.     HX_RELEASE(m_pRegistry);
  360.     HX_DELETE(m_pNormal);
  361.     HX_DELETE(m_pRecovered);
  362.     HX_DELETE(m_pReceived);
  363.     HX_DELETE(m_pOutOfOrder);
  364.     HX_DELETE(m_pLost);
  365.     HX_DELETE(m_pLate);
  366.     HX_DELETE(m_pDuplicate);
  367.     HX_DELETE(m_pTotal);
  368.     HX_DELETE(m_pLost30);
  369.     HX_DELETE(m_pTotal30);
  370.     HX_DELETE(m_pClipBandwidth);
  371.     HX_DELETE(m_pResendRequested);
  372.     HX_DELETE(m_pResendReceived);
  373.     HX_DELETE(m_pAvgBandwidth);
  374.     HX_DELETE(m_pCurBandwidth);
  375.     HX_DELETE(m_pHighLatency);
  376.     HX_DELETE(m_pLowLatency);
  377.     HX_DELETE(m_pAvgLatency);
  378. }
  379. STATS& STATS::operator=(const STATS& rhs )
  380. {
  381.     if( this != &rhs )
  382.     {
  383.         m_pNormal->SetInt( rhs.m_pNormal->GetInt());
  384.         m_pRecovered->SetInt( rhs.m_pRecovered->GetInt());
  385.         m_pReceived->SetInt( rhs.m_pReceived->GetInt());
  386.         m_pOutOfOrder->SetInt( rhs.m_pOutOfOrder->GetInt());
  387.         m_pLost->SetInt( rhs.m_pLost->GetInt());
  388.         m_pLate->SetInt( rhs.m_pLate->GetInt());
  389. m_pDuplicate->SetInt( rhs.m_pDuplicate->GetInt());
  390.         m_pTotal->SetInt( rhs.m_pTotal->GetInt());
  391.         m_pLost30->SetInt( rhs.m_pLost30->GetInt());
  392.         m_pTotal30->SetInt( rhs.m_pTotal30->GetInt());
  393.         m_pClipBandwidth->SetInt( rhs.m_pClipBandwidth->GetInt());
  394.         m_pResendRequested->SetInt( rhs.m_pResendRequested->GetInt());
  395.         m_pResendReceived->SetInt( rhs.m_pResendReceived->GetInt());
  396.         m_pAvgBandwidth->SetInt( rhs.m_pAvgBandwidth->GetInt());
  397.         m_pCurBandwidth->SetInt( rhs.m_pCurBandwidth->GetInt());
  398.         m_pHighLatency->SetInt( rhs.m_pHighLatency->GetInt());
  399.         m_pLowLatency->SetInt( rhs.m_pLowLatency->GetInt());
  400.         m_pAvgLatency->SetInt( rhs.m_pAvgLatency->GetInt());
  401.     }
  402.     
  403.     return *this;
  404. }
  405. void
  406. STATS::Reset()
  407. {
  408.     if (m_bInitialized)
  409.     {
  410. m_pNormal->SetInt(0);
  411. m_pRecovered->SetInt(0);
  412. m_pReceived->SetInt(0);
  413. m_pOutOfOrder->SetInt(0);
  414. m_pLost->SetInt(0);
  415. m_pLate->SetInt(0);
  416. m_pDuplicate->SetInt(0);
  417. m_pTotal->SetInt(0);
  418. m_pLost30->SetInt(0);
  419. m_pTotal30->SetInt(0);
  420. m_pClipBandwidth->SetInt(0);
  421. m_pResendRequested->SetInt(0);
  422. m_pResendReceived->SetInt(0);
  423. m_pAvgBandwidth->SetInt(0);
  424. m_pCurBandwidth->SetInt(0);
  425. m_pHighLatency->SetInt(0);
  426. m_pLowLatency->SetInt(0);
  427. m_pAvgLatency->SetInt(0);
  428.     }
  429. }
  430. PLAYER_STATS::PLAYER_STATS(IHXRegistry*   /*IN*/  pRegistry, 
  431.    UINT32      /*IN*/  ulRegistryID) 
  432.      :STATS(pRegistry, ulRegistryID)
  433.      ,m_pBufferingMode(NULL)
  434. {
  435.     HX_RESULT theErr = HXR_OK;
  436.     IHXBuffer* pszParentName = NULL;
  437.     char szRegKeyName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */
  438.     if (!pRegistry)
  439.     {
  440. goto cleanup;
  441.     }
  442.     if (HXR_OK == m_pRegistry->GetPropName(m_ulRegistryID, pszParentName))
  443.     {
  444. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.BufferingMode", pszParentName->GetBuffer());
  445. if (!(m_pBufferingMode = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  446. {
  447.     theErr = HXR_OUTOFMEMORY;
  448.     goto cleanup;
  449. }
  450.     }
  451. cleanup:
  452.     HX_RELEASE(pszParentName);
  453.     if (HXR_OK == theErr)
  454.     {
  455. m_lastError = HXR_OK;
  456. m_bInitialized = TRUE;
  457.     }
  458.     else
  459.     {
  460. m_lastError = theErr;
  461. m_bInitialized = FALSE;
  462.     }
  463. }
  464. PLAYER_STATS::~PLAYER_STATS()
  465. {
  466.     HX_DELETE(m_pBufferingMode);
  467. }
  468. PLAYER_STATS& PLAYER_STATS::operator=(const PLAYER_STATS& rhs )
  469. {
  470.     if( this != &rhs )
  471.     {
  472.         STATS::operator=(rhs);
  473.         m_pBufferingMode->SetInt( rhs.m_pBufferingMode->GetInt() );
  474.     }
  475.     
  476.     return *this;
  477. }
  478. void
  479. PLAYER_STATS::Reset()
  480. {
  481.     if (m_bInitialized)
  482.     {
  483. m_pBufferingMode->SetInt(0);
  484. STATS::Reset();
  485.     }
  486. }
  487. SOURCE_STATS::SOURCE_STATS(IHXRegistry*   /*IN*/  pRegistry,
  488.    UINT32      /*IN*/  ulRegistryID)
  489.      :STATS(pRegistry, ulRegistryID)
  490. {
  491.     HX_RESULT theErr = HXR_OK;
  492.     IHXBuffer* pszParentName = NULL;
  493.     char szRegKeyName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */
  494.     m_pTransportMode = NULL;
  495.     m_pBufferingMode = NULL;
  496.     m_pTitle = NULL;
  497.     m_pAuthor = NULL;
  498.     m_pCopyright = NULL;
  499.     m_pAbstract = NULL;
  500.     m_pDescription = NULL;
  501.     m_pKeywords = NULL;
  502.     m_pSourceName = NULL;
  503.     m_pServerInfo = NULL;
  504.     m_pProtocolVersion = NULL;
  505.     m_pProtocol = NULL;
  506.     if (!pRegistry)
  507.     {
  508. goto cleanup;
  509.     }
  510.    
  511.     if (HXR_OK == m_pRegistry->GetPropName(m_ulRegistryID, pszParentName))
  512.     {
  513. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.TransportMode", pszParentName->GetBuffer());
  514. if (!(m_pTransportMode = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  515. {
  516.     theErr = HXR_OUTOFMEMORY;
  517.     goto cleanup;
  518. }
  519. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.BufferingMode", pszParentName->GetBuffer());
  520. if (!(m_pBufferingMode = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  521. {
  522.     theErr = HXR_OUTOFMEMORY;
  523.     goto cleanup;
  524. }
  525. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.SourceName", pszParentName->GetBuffer());
  526. if (!(m_pSourceName = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  527. {
  528.     theErr = HXR_OUTOFMEMORY;
  529.     goto cleanup;
  530. }
  531. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.ServerInfo", pszParentName->GetBuffer());
  532. if (!(m_pServerInfo = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  533. {
  534.     theErr = HXR_OUTOFMEMORY;
  535.     goto cleanup;
  536. }
  537. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.ProtocolVersion", pszParentName->GetBuffer());
  538. if (!(m_pProtocolVersion = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_NUMBER)))
  539. {
  540.     theErr = HXR_OUTOFMEMORY;
  541.     goto cleanup;
  542. }
  543. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Protocol", pszParentName->GetBuffer());
  544. if (!(m_pProtocol = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  545. {
  546.     theErr = HXR_OUTOFMEMORY;
  547.     goto cleanup;
  548. }
  549. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Title", pszParentName->GetBuffer());
  550. if (!(m_pTitle = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  551. {
  552.     theErr = HXR_OUTOFMEMORY;
  553.     goto cleanup;
  554. }
  555. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Author", pszParentName->GetBuffer());
  556. if (!(m_pAuthor = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  557. {
  558.     theErr = HXR_OUTOFMEMORY;
  559.     goto cleanup;
  560. }
  561. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Copyright", pszParentName->GetBuffer());
  562. if (!(m_pCopyright = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  563. {
  564.     theErr = HXR_OUTOFMEMORY;
  565.     goto cleanup;
  566. }
  567. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Abstract", pszParentName->GetBuffer());
  568. if (!(m_pAbstract = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  569. {
  570.     theErr = HXR_OUTOFMEMORY;
  571.     goto cleanup;
  572. }
  573.     
  574. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Description", pszParentName->GetBuffer());
  575. if (!(m_pDescription = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  576. {
  577.     theErr = HXR_OUTOFMEMORY;
  578.     goto cleanup;
  579. }
  580. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Keywords", pszParentName->GetBuffer());
  581. if (!(m_pKeywords = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  582. {
  583.     theErr = HXR_OUTOFMEMORY;
  584.     goto cleanup;
  585. }
  586.     }
  587. cleanup:
  588.     HX_RELEASE(pszParentName);
  589.     if (HXR_OK == theErr)
  590.     {
  591. m_lastError = HXR_OK;
  592. m_bInitialized = TRUE;
  593.     }
  594.     else
  595.     {
  596. m_lastError = theErr;
  597. m_bInitialized = FALSE;
  598.     }
  599. }
  600. SOURCE_STATS::~SOURCE_STATS()
  601. {
  602.     HX_DELETE(m_pTransportMode);
  603.     HX_DELETE(m_pBufferingMode);
  604.     HX_DELETE(m_pSourceName);
  605.     HX_DELETE(m_pServerInfo);
  606.     HX_DELETE(m_pProtocolVersion);
  607.     HX_DELETE(m_pProtocol);
  608.     HX_DELETE(m_pTitle);
  609.     HX_DELETE(m_pAuthor);
  610.     HX_DELETE(m_pCopyright);
  611.     HX_DELETE(m_pAbstract);
  612.     HX_DELETE(m_pDescription);
  613.     HX_DELETE(m_pKeywords);
  614. }
  615. SOURCE_STATS& SOURCE_STATS::operator=(const SOURCE_STATS& rhs )
  616. {
  617.     if( this != &rhs )
  618.     {
  619.         STATS::operator=(rhs);
  620.         HX_ASSERT( m_bInitialized );
  621.         if (m_bInitialized)
  622.         {
  623.             m_pTransportMode->SetStr(rhs.m_pTransportMode->GetStr());
  624.             m_pBufferingMode->SetInt(rhs.m_pBufferingMode->GetInt());
  625.             m_pSourceName->SetStr(rhs.m_pSourceName->GetStr());
  626.             m_pServerInfo->SetStr(rhs.m_pServerInfo->GetStr());
  627.             m_pProtocolVersion->SetInt(rhs.m_pProtocolVersion->GetInt());
  628.             m_pProtocol->SetStr(rhs.m_pProtocol->GetStr());
  629.             m_pTitle->SetStr(rhs.m_pTitle->GetStr());
  630.             m_pAuthor->SetStr(rhs.m_pAuthor->GetStr());
  631.             m_pCopyright->SetStr(rhs.m_pCopyright->GetStr());
  632.             m_pAbstract->SetStr(rhs.m_pAbstract->GetStr());
  633.             m_pDescription->SetStr(rhs.m_pDescription->GetStr());
  634.             m_pKeywords->SetStr(rhs.m_pKeywords->GetStr());
  635.         }
  636.     }
  637.     
  638.     return *this;
  639. }
  640. void
  641. SOURCE_STATS::Reset()
  642. {
  643.     if (m_bInitialized)
  644.     {
  645. m_pTransportMode->SetStr(NULL);
  646. m_pBufferingMode->SetInt(0);
  647. m_pSourceName->SetStr(NULL);
  648. m_pServerInfo->SetStr(NULL);
  649. m_pProtocolVersion->SetInt(0);
  650. m_pProtocol->SetStr(NULL);
  651. m_pTitle->SetStr(NULL);
  652. m_pAuthor->SetStr(NULL);
  653. m_pCopyright->SetStr(NULL);
  654. m_pAbstract->SetStr(NULL);
  655. m_pDescription->SetStr(NULL);
  656. m_pKeywords->SetStr(NULL);
  657. STATS::Reset();
  658.     }
  659. }
  660. STREAM_STATS::STREAM_STATS(IHXRegistry*   /*IN*/  pRegistry,
  661.    UINT32      /*IN*/  ulRegistryID)
  662.      :STATS(pRegistry, ulRegistryID)
  663. {
  664.     HX_RESULT theErr = HXR_OK;
  665.     IHXBuffer* pszParentName = NULL;
  666.     char szRegKeyName[MAX_DISPLAY_NAME] = {0}; /* Flawfinder: ignore */
  667.     
  668.     m_pRenderer = NULL;
  669.     m_pMimeType = NULL;
  670.     if (!pRegistry)
  671.     {
  672. goto cleanup;
  673.     }
  674.     
  675.     if (HXR_OK == m_pRegistry->GetPropName(m_ulRegistryID, pszParentName))
  676.     {
  677. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.Renderer", pszParentName->GetBuffer());
  678. if (!(m_pRenderer = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_COMPOSITE)))
  679. {
  680.     theErr = HXR_OUTOFMEMORY;
  681.     goto cleanup;
  682. }
  683. SafeSprintf(szRegKeyName, MAX_DISPLAY_NAME, "%s.MimeType", pszParentName->GetBuffer());
  684. if (!(m_pMimeType = new CStatisticEntry(m_pRegistry, szRegKeyName, REG_TYPE_STRING)))
  685. {
  686.     theErr = HXR_OUTOFMEMORY;
  687.     goto cleanup;
  688. }
  689.     }
  690.         
  691. cleanup:
  692.     HX_RELEASE(pszParentName);
  693.     if (HXR_OK == theErr)
  694.     {
  695. m_lastError = HXR_OK;
  696. m_bInitialized = TRUE;
  697.     }
  698.     else
  699.     {
  700. m_lastError = theErr;
  701. m_bInitialized = FALSE;
  702.     }
  703. }
  704. STREAM_STATS::~STREAM_STATS()
  705. {
  706.     HX_DELETE(m_pRenderer);
  707.     HX_DELETE(m_pMimeType);
  708. }
  709. STREAM_STATS& STREAM_STATS::operator=(const STREAM_STATS& rhs )
  710. {
  711.     if( this != &rhs )
  712.     {
  713.         HX_ASSERT( m_bInitialized );
  714.         if (m_bInitialized)
  715.         {
  716.     STATS::operator=(rhs);
  717.             m_pMimeType->SetStr( rhs.m_pMimeType->GetStr() );
  718.         }
  719.     }
  720.     
  721.     return *this;
  722. }
  723. void
  724. STREAM_STATS::Reset()
  725. {
  726.     if (m_bInitialized)
  727.     {
  728. m_pMimeType->SetStr(NULL);
  729. STATS::Reset();
  730.     }
  731. }
  732. BOOL SetIntIfNecessary(CStatisticEntry* pEntry, INT32 lValue)
  733. {
  734.     BOOL bResult = FALSE;
  735.     if (!pEntry)
  736.     {
  737. goto cleanup;
  738.     }
  739.     if (pEntry->GetInt() != lValue)
  740.     {
  741. pEntry->SetInt(lValue);
  742. bResult = TRUE;
  743.     }
  744. cleanup:
  745.     return bResult;
  746. }