accessoryservices/pluggeddisplay/pluggeddisplayengine/inc/cleanupresetanddestroy.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2  * Copyright (c) 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  *
       
    16  */
       
    17 
       
    18 // NAMESCAPE DEFINITION
       
    19 namespace
       
    20     {
       
    21     // CLASS DECLARATION
       
    22     template <class T> class CleanupResetAndDestroy
       
    23     	{
       
    24         public:
       
    25             
       
    26             // Push cleanup item into cleanup stack
       
    27     	    inline static void PushL(T& aRef)
       
    28     	        {
       
    29     	        CleanupStack::PushL(
       
    30     	            TCleanupItem( &ResetAndDestroy, &aRef ) );
       
    31     	        };
       
    32         
       
    33         private:
       
    34         
       
    35             // Cleanup item action
       
    36     	    static void ResetAndDestroy(TAny *aPtr)
       
    37         	    {
       
    38         	    static_cast<T*>( aPtr )->ResetAndDestroy();
       
    39         	    };
       
    40     	};
       
    41     
       
    42     // Local function which pushes RPointerArray<T&> instance into cleanup stack
       
    43     template <class T> inline void CleanupResetAndDestroyPushL( T& aRef )
       
    44         {
       
    45             CleanupResetAndDestroy<T>::PushL( aRef );
       
    46         };
       
    47     }
       
    48