qtmcache.h

来自「symbian 下的helix player源代码」· C头文件 代码 · 共 111 行

H
111
字号
/****************************************************************************
 * 
 *  $Id: qtmcache.h,v 1.1 2003/03/30 22:17:13 milko Exp $
 *
 *  Copyright (C) 1995-1999 RealNetworks, Inc. All rights reserved.
 *  
 *  http://www.real.com/devzone
 *
 *  This program contains proprietary 
 *  information of Progressive Networks, Inc, and is licensed
 *  subject to restrictions on use and distribution.
 *
 *
 *  Memory Cache
 *
 */

#ifndef _QTMCACHE_H_
#define _QTMCACHE_H_

/****************************************************************************
 *  Defines
 */

/****************************************************************************
 *  Includes
 */
#include "hxtypes.h"
#include "hxcom.h"
#include "hxcomm.h"
#include "ihxpckts.h"


/****************************************************************************
 * 
 *  Class:
 *	CQTMemCache
 *
 *  Purpose:
 *	Enables paging of file sections into memory
 *
 */
class CQTMemCache
{
public:
    /*
     *	Constructor/Destructor
     */
    CQTMemCache(void)
	: m_pBuffer(NULL)
	, m_ulBaseOffset(0)
	, m_ulEndOffset(0)
	, m_bEnabled(TRUE)
    {
	;
    }

    ~CQTMemCache()
    {
	HX_RELEASE(m_pBuffer);
    }

    /*
     *	IUnknown methods
     */
    void SetPage(ULONG32 ulBaseOffset, IHXBuffer* pBuffer)
    {
	if (m_pBuffer)
	{
	    m_pBuffer->Release();
	}
	m_pBuffer = pBuffer;
	pBuffer->AddRef();
	m_ulBaseOffset = ulBaseOffset;
	m_ulEndOffset = ulBaseOffset + m_pBuffer->GetSize();
    }

    void ReleasePage(void)
    {
	HX_RELEASE(m_pBuffer);
    }

    BOOL IsInPage(ULONG32 ulBaseOffset, ULONG32 ulSize)
    {
	return (m_pBuffer &&
		(((LONG32) (ulBaseOffset - m_ulBaseOffset)) >= 0) &&
		(((LONG32) (m_ulEndOffset - ulBaseOffset - ulSize)) >= 0));
    }

    // COM semantics is not followed here (no AddRef of pBuffer) 
    // for efficiency reasons.
    void Get(ULONG32 ulBaseOffset,
	     IHXBuffer* &pBuffer, ULONG32 &ulPageOffset)
    {
	pBuffer = m_pBuffer;
	ulPageOffset = ulBaseOffset - m_ulBaseOffset;
    }

    BOOL IsEnabled(void)    { return m_bEnabled; }

    void Enable(BOOL bEnable)	{ m_bEnabled = bEnable; }

private:
    IHXBuffer* m_pBuffer;
    ULONG32 m_ulBaseOffset;
    ULONG32 m_ulEndOffset;
    BOOL m_bEnabled;
};

#endif  // _QTMCACHE_H_

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?