emailuis/emailui/inc/FreestyleEmailExportedUtilities.h
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Exported utilities for FS Email
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef FREESTYLEEMAILEXPORTEDUTILITIES_H_
       
    20 #define FREESTYLEEMAILEXPORTEDUTILITIES_H_
       
    21 
       
    22 /**
       
    23 *  CleanupResetAndDestroyClose
       
    24 *
       
    25 *  Use CleanupResetAndDestroyClosePushL to push RPointerArray items
       
    26 *   on the cleanup stack. Use CleanupStack::PopAndDestroy( &ptrarray )
       
    27 *   to resetanddestroy + close the pointer array.
       
    28 *
       
    29 */
       
    30 template<typename T> class CleanupResetAndDestroyClose
       
    31     {
       
    32 public:
       
    33     inline static void PushL( T& aRef );
       
    34 private:
       
    35     static void Close( TAny *aPtr );
       
    36     };
       
    37 
       
    38 template<typename T> inline void CleanupResetAndDestroyClosePushL( T& aRef );
       
    39 
       
    40 template<typename T> inline void CleanupResetAndDestroyClose<T>::PushL( T& aRef )
       
    41     {
       
    42     CleanupStack::PushL( TCleanupItem( &Close, &aRef ) );
       
    43     }
       
    44 
       
    45 template<typename T> void CleanupResetAndDestroyClose<T>::Close( TAny *aPtr )
       
    46     {
       
    47     static_cast<T*>(aPtr)->ResetAndDestroy();
       
    48     static_cast<T*>(aPtr)->Close();
       
    49     }
       
    50 
       
    51 template<typename T> inline void CleanupResetAndDestroyClosePushL( T& aRef )
       
    52     {
       
    53     CleanupResetAndDestroyClose<T>::PushL( aRef );
       
    54     }
       
    55 
       
    56 #endif /*FREESTYLEEMAILEXPORTEDUTILITIES_H_*/