commsfwutils/commsbufs/src/commsbufpond.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "es_commsbuf_internal.h"
       
    17 #include <comms-infras/commsbufasyncrequest.h>
       
    18 #include "commsbufpondintf.h"
       
    19 
       
    20 EXPORT_C RCommsBufPond::RCommsBufPond()
       
    21 :iPondImpl(NULL)
       
    22 /**
       
    23 The constructor
       
    24 */
       
    25 	{
       
    26 		
       
    27 		
       
    28 	}
       
    29 
       
    30 EXPORT_C RCommsBuf* RCommsBufPond::Alloc(TInt aSize, TInt aMinBufSize, TInt aMaxBufSize)
       
    31 /**
       
    32 Allocates memory for a RCommsBuf object. More than one buffer may be allocated and linked, 
       
    33 if the requested buffer size doesn't directly satisfy with the configured buffer sizes
       
    34 
       
    35 @param 	aSize 		The requested total size
       
    36 @param 	aMinBufSize The size that the allocated buffer must atleast have
       
    37 @param 	aMinBufSize The size that the allocated buffer can have
       
    38 
       
    39 @return Allocated RCommsBuf pointer on success otherwise NULL
       
    40 */
       
    41 	{
       
    42 	return iPondImpl->Alloc(aSize, aMinBufSize, aMaxBufSize);	
       
    43 	}
       
    44 
       
    45 EXPORT_C TInt RCommsBufPond::BytesAvailable() const
       
    46 /**
       
    47 Returns the total bytes available in the available pools
       
    48 */
       
    49 	{
       
    50 	return iPondImpl->BytesAvailable();
       
    51 	}
       
    52 	
       
    53 EXPORT_C TInt RCommsBufPond::BytesAvailable(TInt aSize) const
       
    54 /**
       
    55 Returns the total bytes available in a pool with a given size.
       
    56 */
       
    57 	{
       
    58 	return iPondImpl->BytesAvailable(aSize);	
       
    59 	}
       
    60 	
       
    61 EXPORT_C TInt RCommsBufPond::NextBufSize(TInt aSize) const
       
    62 /**
       
    63 Returns the buffer size that is greater than the given size.
       
    64 */
       
    65 	{
       
    66 	return iPondImpl->NextBufSize(aSize);		
       
    67 	}
       
    68 	
       
    69 EXPORT_C TInt RCommsBufPond::LargestBufSize() const
       
    70 /**
       
    71 Larget buffer size available in the available pools
       
    72 */
       
    73 	{
       
    74 	return iPondImpl->LargestBufSize();	
       
    75 	}
       
    76 
       
    77 EXPORT_C TCommsBufAllocator RCommsBufPond::Allocator()
       
    78 /**
       
    79 Returns a handle to the allocator
       
    80 */
       
    81 	{
       
    82 	return TCommsBufAllocator(*this);		
       
    83 	}
       
    84 
       
    85 EXPORT_C void RCommsBufPond::StartRequest(RCommsBufAsyncRequest& aRequest)
       
    86 /**
       
    87 Issue an asynchronous request to create a RCommsBufChain
       
    88 
       
    89 @param aRequest	A new request
       
    90 */
       
    91 	{
       
    92 	iPondImpl->StartRequest(*(aRequest.iAsyncReqImpl));		
       
    93 	}
       
    94 
       
    95 EXPORT_C void RCommsBufPond::CancelRequest(RCommsBufAsyncRequest& aRequest)
       
    96 /**
       
    97 Cancel the issued request
       
    98 
       
    99 @param aRequest	A  request
       
   100 */
       
   101 	{
       
   102 	iPondImpl->CancelRequest(*(aRequest.iAsyncReqImpl));				
       
   103 	}
       
   104 
       
   105 
       
   106 EXPORT_C RCommsBuf* RCommsBufPond::FromHandle(TInt aHandle)
       
   107 /**
       
   108 Constructs the RCommsBuf from the supplied handle
       
   109 
       
   110 TInt aHandle RShBuf handle
       
   111 */
       
   112 	{
       
   113 	return iPondImpl->FromHandle(aHandle);
       
   114 	}
       
   115 
       
   116 
       
   117 /**
       
   118 @purpose Writes flattened pond structure to a descriptor for transfer to a commsbufs aware driver
       
   119 @param aStore Descriptor in to which the pond structure will be flattened
       
   120 */
       
   121 EXPORT_C TInt RCommsBufPond::Store(TPondTransferBuf& aStore) const
       
   122 	{
       
   123 	// Just forward to the implementation of the pond
       
   124 	return iPondImpl->Store(aStore);
       
   125 	}
       
   126