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

Symbian

开发平台:

Visual C++

  1. /****************************************************************************
  2.  * 
  3.  *  $Id: bfrag.h,v 1.3 2003/07/31 17:23:44 jbloedow Exp $
  4.  *
  5.  *  Copyright (C) 1995-1999 RealNetworks, Inc. All rights reserved.
  6.  *  
  7.  *  http://www.real.com/devzone
  8.  *
  9.  *  This program contains proprietary 
  10.  *  information of Progressive Networks, Inc, and is licensed
  11.  *  subject to restrictions on use and distribution.
  12.  *
  13.  *
  14.  *  Buffer Fragment Class
  15.  *
  16.  */
  17. #ifndef _BFRAG_H_
  18. #define _BFRAG_H_
  19. /****************************************************************************
  20.  *  Defines
  21.  */
  22. /****************************************************************************
  23.  *  Includes
  24.  */
  25. #include "hxtypes.h"
  26. #include "hxcom.h"
  27. #include "hxcomm.h"
  28. #include "ihxpckts.h"
  29. #include "qtffrefcounter.h"
  30. class CBufferFragmentFactory;
  31. /****************************************************************************
  32.  * 
  33.  *  Class:
  34.  * CBufferFragment
  35.  *
  36.  *  Purpose:
  37.  * Provides for containment of buffer fragments under IHXBuffer API
  38.  *
  39.  */
  40. class CBufferFragment : public IHXBuffer
  41. {
  42. public:
  43.     /*
  44.      * Constructor/Destructor
  45.      */
  46. #ifdef QTCONFIG_BFRAG_FACTORY
  47.     CBufferFragment(void)
  48. : m_pBuffer(NULL)
  49. , m_pData(NULL)
  50. , m_ulSize(0)
  51. , m_lRefCount(0)
  52. , m_pBufferFragmentFactory(NULL)
  53.     {
  54.     }
  55. #else // QTCONFIG_BFRAG_FACTORY
  56.     CBufferFragment(IHXBuffer* pBuffer,
  57.     ULONG32 ulOffset,
  58.     ULONG32 ulSize)
  59. : m_pBuffer(pBuffer)
  60. , m_ulSize(ulSize)
  61. , m_lRefCount(0)
  62.     {
  63. pBuffer->AddRef();
  64. m_pData = pBuffer->GetBuffer() + ulOffset;
  65. m_ulSize = ulSize;
  66.     }
  67. #endif // QTCONFIG_BFRAG_FACTORY
  68.     /*
  69.      * IUnknown methods
  70.      */
  71.     STDMETHOD(QueryInterface) (THIS_
  72. REFIID riid,
  73. void** ppvObj);
  74.     STDMETHOD_(ULONG32,AddRef) (THIS);
  75.     STDMETHOD_(ULONG32,Release) (THIS);
  76.     /*
  77.      * CBufferFragment methods
  78.      */
  79. #ifdef QTCONFIG_BFRAG_FACTORY
  80.     void Link (CBufferFragmentFactory* pBufferFragmentFactory);
  81.     inline void Unlink(void);
  82.     void Init (IHXBuffer* pBuffer,
  83.  ULONG32 ulOffset,
  84.  ULONG32 ulSize, 
  85.  CBufferFragmentFactory* pBufferFragmentFactory)
  86.     {
  87. if (m_pBuffer)
  88. {
  89.     m_pBuffer->Release();
  90. }
  91. Link(pBufferFragmentFactory);
  92. m_pBuffer = pBuffer;
  93. pBuffer->AddRef();
  94. m_pData = pBuffer->GetBuffer() + ulOffset;
  95. m_ulSize = ulSize;
  96.     }
  97. #endif // QTCONFIG_BFRAG_FACTORY
  98.     /*
  99.      * IHXBuffer methods
  100.      */
  101.     STDMETHOD(Get) (THIS_
  102. REF(UCHAR*) pData, 
  103. REF(ULONG32) ulLength);
  104.     STDMETHOD(Set) (THIS_
  105. const UCHAR* pData, 
  106. ULONG32 ulLength);
  107.     STDMETHOD(SetSize) (THIS_
  108. ULONG32 ulLength);
  109.     STDMETHOD_(ULONG32,GetSize) (THIS);
  110.     STDMETHOD_(UCHAR*,GetBuffer)(THIS);
  111. private:
  112.     IHXBuffer* m_pBuffer;
  113.     UINT8* m_pData;
  114.     UINT32 m_ulSize;
  115. #ifdef QTCONFIG_BFRAG_FACTORY
  116.     CBufferFragmentFactory* m_pBufferFragmentFactory;
  117. #endif // QTCONFIG_BFRAG_FACTORY
  118.     LONG32 m_lRefCount;
  119.     ~CBufferFragment();
  120.     PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME
  121. };
  122. #endif  // _BFRAG_H_