realtimenetprots/sipfw/ClientResolver/common/inc/CleanupResetAndDestroy.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004-2009 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:
       
    15 * Name        : CleanupResetAndDestroy.h
       
    16 * Part of     : ClientResolver
       
    17 * Inlined implementation of CleanupResetAndDestroyPushL()
       
    18 * Version     : SIP/4.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @internalComponent
       
    27 */
       
    28 
       
    29 #ifndef __CLEANUPRESETANDDESTROY_H__
       
    30 #define __CLEANUPRESETANDDESTROY_H__
       
    31 
       
    32 // INCLUDES
       
    33 #include <e32base.h>
       
    34 
       
    35 // CLASS DEFINITION
       
    36 /**
       
    37  * Template class for cleaning up arrays that have a ResetAndDestroy() function.
       
    38  * To be used with the CleanupStack.
       
    39  */
       
    40 template <class T>
       
    41 class CleanupResetAndDestroy
       
    42 	{
       
    43 	public:	// New functions
       
    44 
       
    45 		inline static void PushL( T& aRef );
       
    46 
       
    47 	private: // New functions
       
    48 
       
    49 		static void ResetAndDestroy( TAny *aPtr );
       
    50 
       
    51 	};
       
    52 
       
    53 // INLINE FUNCTIONS
       
    54 template <class T>
       
    55 inline void CleanupResetAndDestroy< T >::PushL( T& aRef )
       
    56 	{
       
    57 	CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) );
       
    58 	}
       
    59 
       
    60 template <class T>
       
    61 void CleanupResetAndDestroy<T>::ResetAndDestroy( TAny *aPtr )
       
    62 	{ ( static_cast< T* >( aPtr ) )->ResetAndDestroy(); }
       
    63 
       
    64 template <class T>
       
    65 inline void CleanupResetAndDestroyPushL( T& aRef )
       
    66 	{ CleanupResetAndDestroy< T >::PushL( aRef ); }
       
    67 
       
    68 #endif // __CLEANUPRESETANDDESTROY_H__