statinfo.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:23k
源码类别:

Symbian

开发平台:

Visual C++

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