internetradio2.0/mediaengineinc/irbuffercontainer.h
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef IRBUFFERCONTAINER_H
       
    20 #define IRBUFFERCONTAINER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 //========================================class declaration CIRBufferContainer============================================
       
    25 
       
    26 /**
       
    27  * This class is wrapper class which can hold an address of a memory chunk
       
    28  * and size (granularity) of memory chunk.
       
    29  * This is implemented so as to use with queue like TSglQue
       
    30  * iLink is public member and is of a member of type TSglQueLink
       
    31  * The memory address is of TUint8* type and address is of type TInt
       
    32  * you can assign the address and granularity only when you create an instance
       
    33  * and retrive address and size using Des() and GetSize() respectively
       
    34  * typical usage is as follows
       
    35  * Note: This class DOESN'T take any responsibility of removing memory chunk
       
    36  * associated to it when you delete the chunk, since it is not creating the memory
       
    37  * chunk it doesn't do deallocation it has to taken care from where you create
       
    38  * the memory chunk
       
    39  *
       
    40  * @code
       
    41  *
       
    42  * TSglQue<CIRBufferContainer> Myque;
       
    43  * TInt f_off = _FOFF(CIRBufferContainer,iLink);
       
    44  * Myque.SetOffset(f_off);
       
    45  * TUint8* buffer;
       
    46  * TInt sizeofbuffer;
       
    47  * CIRBufferContainer* bufferholder;
       
    48  * bufferholder = CIRBufferContainer::NewL(buffer,sizeofbuffer);
       
    49  * Myque.AddLast(*bufferholder);
       
    50  * TUint8* ptr = bufferholder->Des();
       
    51  * TInt size = bufferholder->GetSize();
       
    52  * bufferholder = Myque.First();
       
    53  * Myque.Remove(*bufferholder);
       
    54  * delete bufferholder; //deleting bufferholder doesn't deletes memory allocated
       
    55  *			            //to buffer is not getting deleted we have delete it explicitly
       
    56  * 
       
    57  * delete buffer;
       
    58  *
       
    59  * @endcode
       
    60  *   
       
    61  */
       
    62 
       
    63 NONSHARABLE_CLASS(CIRBufferContainer) : public CBase
       
    64 	{
       
    65 											//member functions
       
    66 public :
       
    67 	
       
    68 	/**
       
    69 	 * Two Phase NewL
       
    70 	 * returns an instance CIRBufferContainer
       
    71 	 * Owned by CIRBufferContainer
       
    72 	 * @param Address of data chunk
       
    73 	 * @param Granularity of data chunk
       
    74 	 * @return instance CIRBufferContainer
       
    75 	 */	
       
    76 	static CIRBufferContainer* NewL(TUint8* aAddress,TInt aGranularity);
       
    77 		
       
    78 	/**
       
    79 	 * Two Phase NewLC
       
    80 	 * Creates an instance CIRBufferContainer
       
    81 	 * Owned by CIRBufferContainer
       
    82 	 * @param Address of data chunk
       
    83 	 * @param Granularity of data chunk
       
    84 	 * @return instance CIRBufferContainer
       
    85 	 */
       
    86 	static CIRBufferContainer* NewLC(TUint8* aAddress,TInt aGranularity);
       
    87 
       
    88 	/**
       
    89 	 * destructor function
       
    90 	 * Owned by CIRBufferContainer
       
    91 	 */ 
       
    92 	~CIRBufferContainer();
       
    93 	
       
    94  	/**	
       
    95 	 *  Des returns the Address of the chunk;
       
    96 	 *  Owned by CIRBufferContainer Class
       
    97 	 *  @return address
       
    98 	 */	
       
    99 	 TUint8* Des() const;
       
   100 	
       
   101 		 
       
   102 	/**	
       
   103 	 *  Size returns the size of the chunk;
       
   104 	 *  Owned by CIRBufferContainer Class
       
   105 	 *  @return size of chunk
       
   106 	 */
       
   107 	 TInt Size() const;	
       
   108 												
       
   109 private:
       
   110 
       
   111 	/**
       
   112 	 * Function : CIRBufferContainer
       
   113 	 * default constructor
       
   114 	 */	
       
   115 	CIRBufferContainer();
       
   116 				
       
   117 	/**
       
   118 	 * Two Phase ConstructL
       
   119 	 * Owned by CIRBufferContainer
       
   120 	 * @param Address of data chunk
       
   121 	 * @param Granularity of data chunk
       
   122 	 */
       
   123  	void ConstructL(TUint8* aAddress,TInt aGranularity);
       
   124  		 	
       
   125 												
       
   126 									//function which return address and granularity
       
   127 
       
   128 												//data members
       
   129 
       
   130 public:
       
   131 	//Que Link owned by CIRBufferContainer
       
   132 	TSglQueLink iLink; 
       
   133 
       
   134 private:
       
   135 		
       
   136 	//Queued buffer pointer owned by CIRBufferContainer
       
   137 	TUint8* iDataAddress;
       
   138 		
       
   139 	//Size of the chunk
       
   140 	TInt iSize;		
       
   141 	};
       
   142 
       
   143 #include "irbuffercontainer.inl"
       
   144 	
       
   145 #endif//IRBUFFERCONTAINER_H
       
   146 
       
   147