sipvoipprovider/inc/svpcleanupresetanddestroy.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of CleanupResetAndDestroyPushL
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef SVPCLEANUPRESETANDDESTROY_H
       
    22 #define SVPCLEANUPRESETANDDESTROY_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 
       
    27 // CLASS DEFINITION
       
    28 /**
       
    29  * Template class for cleaning up arrays that have a ResetAndDestroy() function.
       
    30  * To be used with the CleanupStack.
       
    31  */
       
    32 template <class T>
       
    33 class CleanupResetAndDestroy
       
    34 	{
       
    35 	public:	// New functions
       
    36 
       
    37 		inline static void PushL( T& aRef );
       
    38 
       
    39 	private: // New functions
       
    40 
       
    41 		static void ResetAndDestroy( TAny *aPtr );
       
    42 
       
    43 	};
       
    44 
       
    45 // INLINE FUNCTIONS
       
    46 template <class T>
       
    47 inline void CleanupResetAndDestroy< T >::PushL( T& aRef )
       
    48 	{
       
    49 	CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) );
       
    50 	}
       
    51 
       
    52 template <class T>
       
    53 void CleanupResetAndDestroy<T>::ResetAndDestroy( TAny *aPtr )
       
    54 	{
       
    55 	( static_cast< T* >( aPtr ) )->ResetAndDestroy();
       
    56 	( static_cast< T* >( aPtr ) )->Close();
       
    57 	}
       
    58 
       
    59 template <class T>
       
    60 inline void CleanupResetAndDestroyPushL( T& aRef )
       
    61 	{ CleanupResetAndDestroy< T >::PushL( aRef ); }
       
    62 
       
    63 #endif // SVPCLEANUPRESETANDDESTROY_H