inc/vimpstcustomcleanupapi.h
changeset 0 5e5d6b214f4f
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     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: inf file for conversations
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef VIMPSTCUSTOMCLEANUPAPI_H
       
    19 #define VIMPSTCUSTOMCLEANUPAPI_H
       
    20 
       
    21 
       
    22 /** 
       
    23 * @publishedAll
       
    24 * @released
       
    25 * Template class CleanupResetAndDestroy to clean up the array
       
    26 * of implementation information from the cleanup stack.
       
    27 */
       
    28 
       
    29 template <class T>
       
    30 class CustomCleanupResetAndDestroy
       
    31     {
       
    32  public:
       
    33     /**
       
    34      * Puts an item on the cleanup stack.
       
    35      * @param  aRef 
       
    36      * The implementation information to be put on the cleanup stack.
       
    37      */
       
    38    inline static void PushL(T& aRef);
       
    39 private:
       
    40     static void ResetAndDestroy(TAny *aPtr);
       
    41     };
       
    42 
       
    43 template <class T>
       
    44         inline void CleanupResetAndDestroyPushL(T& aRef);
       
    45 
       
    46 template <class T>
       
    47          inline void CustomCleanupResetAndDestroy<T>::PushL(T& aRef)
       
    48     { CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef));}
       
    49 
       
    50 template <class T>
       
    51          void CustomCleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr)
       
    52     {(STATIC_CAST(T*,aPtr))->ResetAndDestroy();}
       
    53 
       
    54 template <class T>
       
    55          inline void CustomCleanupResetAndDestroyPushL(T& aRef)
       
    56     {CustomCleanupResetAndDestroy<T>::PushL(aRef);}
       
    57 
       
    58 #endif /*VIMPSTCUSTOMCLEANUPAPI_H*/