agendainterface/inc/CleanupResetAndDestroy.inl
changeset 45 b6db4fd4947b
child 75 7ac58b2aae6f
equal deleted inserted replaced
23:fd30d51f876b 45:b6db4fd4947b
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:	Provides cleanup item to push ResetAndDestroy calls to 
       
    15 *                cleanup stack. It is heavily used for RPointerArrays,
       
    16 *                which are used all over Symbian's CalenInterimAPI.
       
    17 *                Implementation is more or less copy-paste of
       
    18 *                cleanup item of Close method and CleanupClosePushL   
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #include "CleanupResetAndDestroy.h"
       
    25 
       
    26 
       
    27 /**
       
    28  *  Creates a TCleanupItem for the specified object.
       
    29  *  The cleanup operation is the private static function ResetAndDestroy() of this class.
       
    30  *  @param aRef The object for which a TCleanupItem is to be constructed.
       
    31  **/
       
    32 template <class T>
       
    33 inline void CleanupResetAndDestroy<T>::PushL(T& aRef)
       
    34 {
       
    35     CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) );
       
    36 }
       
    37 
       
    38 /**
       
    39  *  The cleanup operation to be performed.
       
    40  *  @param aPtr A pointer to the object for which clean up is to be performed. 
       
    41  *              The implementation calls ResetAndDestroy() on this object.
       
    42  **/
       
    43 template <class T>
       
    44 void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr)
       
    45 {
       
    46     static_cast<T*>( aPtr )->ResetAndDestroy();
       
    47 }
       
    48 
       
    49 /**
       
    50  *  See header file CleanupResetAndDestroy.h for in-source comment.
       
    51  *
       
    52  **/
       
    53 template <class T>
       
    54 inline void CleanupResetAndDestroyPushL(T& aRef)
       
    55 {
       
    56     CleanupResetAndDestroy<T>::PushL( aRef );
       
    57 }
       
    58 
       
    59 
       
    60 // End of File