⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cbbqueue.h

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** 
 * Version: RCSL 1.0/RPSL 1.0 
 *  
 * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
 *      
 * The contents of this file, and the files included with this file, are 
 * subject to the current version of the RealNetworks Public Source License 
 * Version 1.0 (the "RPSL") available at 
 * http://www.helixcommunity.org/content/rpsl unless you have licensed 
 * the file under the RealNetworks Community Source License Version 1.0 
 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
 * in which case the RCSL will apply. You may also obtain the license terms 
 * directly from RealNetworks.  You may not use this file except in 
 * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
 * applicable to this file, the RCSL.  Please see the applicable RPSL or 
 * RCSL for the rights, obligations and limitations governing use of the 
 * contents of the file.  
 *  
 * This file is part of the Helix DNA Technology. RealNetworks is the 
 * developer of the Original Code and owns the copyrights in the portions 
 * it created. 
 *  
 * This file, and the files included with this file, is distributed and made 
 * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
 * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
 * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
 * 
 * Technology Compatibility Kit Test Suite(s) Location: 
 *    http://www.helixcommunity.org/content/tck 
 * 
 * Contributor(s): 
 *  
 * ***** END LICENSE BLOCK ***** */ 

/*******************************************************************
 *
 *	NAME:	CBBQueue.h
 *
 *	CLASS:
 *		CBigByteQueue class declaration.
 *
 *	DESCRIPTION:
 *		Class declaration for a 'Queue of bytes' object.
 *		This object is meant to serve the needs of either clients as
 *		an abstract object, or of subclasses as a base object.
 *
 *		That is a client may use this instances of this class directly,
 *		or they may inherit from the class and provide expanded
 *		functionality.
 *
 *	NOTES:
 *		This is a reimplementation of the existing CBigByteQueue
 *		class using 32-bit pointers instead of 16-bit pointers.
 *
 *******************************************************************/

#ifndef _CBBQUEUE_H_
#define _CBBQUEUE_H_
 
#include "hxtypes.h"
#include "hxassert.h"

#if !defined( NULL )
#define NULL	0
#endif

#if !defined( FALSE )
#define FALSE	0
#endif	//	!defined( FALSE )

#if !defined( TRUE )
#define TRUE	!FALSE
#endif	//	!defined( TRUE )

class CBigByteQueue
{
/*
 *	Our public interface.
 *	These are the methods we export to the world.
 *	These methods are primarily used by our clients.
 */
public:
   /*
	** CBigByteQueue( ulSize, ulElementSize )
	*
	*  PARAMETERS:
	*	ulSize			Size of the bytequeue in bytes.
	*	ulElementSize		For subclasses we ensure our size is a multiple of this.
	*
	*  DESCRIPTION:
	*	Parameterized constructor.
	*	This is the primary means of creating an instance of CBigByteQueue.
	*
	*  RETURNS:
	*	void
	*/
	CBigByteQueue( UINT32 ulSize, UINT32 ulElementSize = 1);

   /*
	** CBigByteQueue( rReferent )
	*
	*  PARAMETERS:
	*	rReferent	Constant reference to another CBigByteQueue object.
	*
	*  DESCRIPTION:
    	*	Copy constructor (ctor).  Copies a CBigByteQueue into
	*	another CBigByteQueue that is under construction.
	*	This guy is called in construction situations like this:
	*		CBigByteQueue		rQueueOrig( 10 );			//	Call param ctor
	*		CBigByteQueue		rQueueCopy = rQueueOrig;	//	Call copy ctor
	*
	*  RETURNS:
	*	void
	*/
	CBigByteQueue( const CBigByteQueue &rReferent );


   /*********************************************************
    *	Here are are non-virtual methods that provide
	*	primitive functionality to all queues.
	*********************************************************/

   /*
	** GetQueuedItemCount()
	*
	*  PARAMETERS:
	*	void
	*
	*  DESCRIPTION:
	*	Returns a count of the items we have queue'd up.
	*	This function is accurate even in subclasses with
	*	elements that are a different size from a UCHAR.
	*
	*  RETURNS:
	*	Returns the number of ITEMS we have queued up.
	*
	*/
	UINT32 GetQueuedItemCount() const
	{
		HX_ASSERT( this );
		HX_ASSERT( IsQueueValid() );    

		return( Base_GetUsedByteCount() / m_ulElementSize );
	}

   /*
	** UINT32 GetAvailableElements()
	*
	*  PARAMETERS:
	*	void
	*
	*  DESCRIPTION:
	*	Returns the number of ITEMS we can EnQueue w/o failing.
	*
	*  RETURNS:
	*	0 if the queue is full
	*	non-zero to indicate how many ITEMS we can EnQueue.
	*/
	UINT32 GetAvailableElements() const
	{
		HX_ASSERT( this );
		HX_ASSERT( IsQueueValid() );    

		return( Base_GetAvailableBytes() / m_ulElementSize );
	}

   /*
	** UINT32 GetMaxAvailableElements()
	*
	*  PARAMETERS:
	*	void
	*
	*  DESCRIPTION:
	*	Returns the number of ITEMS we can EnQueue w/o failing AFTER 
	*	we have grown the queue to its Maximum size.
	*
	*  RETURNS:
	*	0 if the queue is full AND there is no more room to grow
	*	beyond the max size
	*	non-zero to indicate how many ITEMS we can EnQueue.
	*/
	UINT32 GetMaxAvailableElements() const
	{
		HX_ASSERT( this );
		HX_ASSERT( IsQueueValid() );    

		return( Base_GetMaxAvailableBytes() / m_ulElementSize );
	}
   /*
	** BOOL IsEmpty()
	*
	*  PARAMETERS:
	*	void
	*
	*  DESCRIPTION:
	*	Tells us if the queue is empty.
	*
	*  RETURNS:
	*	Returns TRUE if the queue is empty.
	*
	*/
	BOOL IsEmpty() const
	{
		HX_ASSERT( this );
		HX_ASSERT( IsQueueValid() );    

		return( m_pTail == m_pHead );
	}

   /*
	** CBigByteQueue &operator=( rReferent )
	*
	*  PARAMETERS:
	*	Constant reference to the CBigByteQueue object we are assigning from
	*	(the rValue).
	*
	*  DESCRIPTION:
	*	Assignment operator.
	*	This guy gets called when we assign a CBigByteQueue.
	*	This guy creates a fully functional copy of the source queue.
	*
	*	Subclasses that want an assignment operator SHOULD redefine
	*	this guy, but they should use the base method to copy the 
	*	bits of the base class.
	*
	*  RETURNS:
	*	A reference to the object we are assigning into.
	*/
	CBigByteQueue &operator=( const CBigByteQueue &rReferent );

   /*
	** UINT32 PeekAt( ulIndex, pOutBuffer )
	*
	*  PARAMETERS:
	*	ulIndex		The ulIndex'th object from the head of the queue
	*				that we are interested in.
	*	pOutBuffer	Pointer to the buffer to receive the contents of the
	*				element.
	*
	*  DESCRIPTION:
   	*	Peeks at a particular index off of the first element in the queue.
   	*	The index is 0 based, hence an index of 0 will indicate the queue
   	*	Head element.
	*	Will copy the element of size GetElementSize() into the pOutBuffer.
	*	*pbIsValid is set to FALSE if the element is not valid data.
	*	Notice that the client needn't redifine this guy if the default
	*	is satisfactory.
	*	In particular this method will remain valid even across changes
	*	of object size in the subclass.
	*	The client will only NEED to imlement an override if they need
	*	to provide another level of indirection.
	*
	*  RETURNS:
	*		Returns the number of bytes copied into pOutBuffer.
	*		0 if nIndex specifies an invalid position in the queue.
	*		(for instance if nIndex is 3, but there are only 2 elements
	*		queued up we wil return 0)
	*/
	UINT32 PeekAt( UINT32 ulIndex, void *pOutBuffer ) const;

   /*
	** FlushQueue()
	*
	*  PARAMETERS:
	*	void
	*
	*  DESCRIPTION:
	*	Instantly flush all elements from the queue.
	*
	*  RETURNS:
	*	void
	*/
	void FlushQueue()
	{
		HX_ASSERT( this );
		HX_ASSERT( IsQueueValid() );    

		Base_SetEmpty();
	}

   /*********************************************************
    *	The rest of these public methods are virtual.
	*
	*	HOWEVER, the default behavior is will remain fully
	*	functional across all changes in object size.
	*
	*	The only reason to provide overrides in subclasses
	*	is to provide additional behavior.  If you do
	*	implement an override make sure it calls the base
	*	virtual method.
	*********************************************************/

   /*
	** ~CBigByteQueue()
	*
	*  PARAMETERS:
	*	void
	*
	*  DESCRIPTION:
	*	Destructor
	*	Notice that this is a virtual destructor.  
	*	The base class CBigByteQueue will delete the buffer.
	*	The subclass need only implement on override if they
	*	need additional cleanup besides the buffer.
	*
	*  RETURNS:
	*	void
	*/
	virtual ~CBigByteQueue();
	
   /*
	** BOOL IsQueueValid()
	*
	*  PARAMETERS:
	*	void
	*
	*  DESCRIPTION:
	*	This method allows the client to test the queue object for
	*	validity.  The base class implements default behavior that
	*	tests it's internal buffer pointers. 
	*	The subclass will only need to implement an override if they
	*	have additional validity checks.
	*
	*	Any override of this funcion MUST return the logical AND of
	*	it's validity checks and the checks of the base method.
	*	Sort of like:
	*		return( CBigByteQueue::IsQueueValid() && CSubClass::IsQueueValid() )
	*
	*  RETURNS:
	*	TRUE	If the queue is valid.
	*	FALSE	If there is an error in the queue members.
	*/
	virtual BOOL IsQueueValid() const;

   /*
	** UINT32 DeQueue( pOutBuffer, ulItemCount )
	*
	*  PARAMETERS:
	*	pOutBuffer		Pointer to buffer to receive bytes we're pulling
	*					out of the queue.
	*	ulItemCount		Number of items we want to dequeue.
	*
	*  DESCRIPTION:
	*	One of our primary operations.
	*	The client can redefine this function, but it is NOT necessary
	*	as the default implementation will suffice for most cases.

⌨️ 快捷键说明

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