emailservices/emailstore/base_plugin/inc/baseplugincommonutils.h
changeset 0 8466d47a6819
child 24 b5fbb9b25d57
child 56 15bc1d5d6267
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:   Utilities.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __COMMONUTILS_H__
       
    21 #define __COMMONUTILS_H__
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 //off imsutils.
       
    26 template <class T> class CleanupResetAndDestroyClose
       
    27     {
       
    28 public:
       
    29     inline static void PushL(T& aRef);
       
    30 private:
       
    31     static void Close(TAny *aPtr);
       
    32     };
       
    33 
       
    34 template <class T> inline void CleanupResetAndDestroyClosePushL(T& aRef);
       
    35 
       
    36 template <class T> inline void CleanupResetAndDestroyClose<T>::PushL(T& aRef)
       
    37     {
       
    38     CleanupStack::PushL(TCleanupItem(&Close, &aRef));
       
    39     }
       
    40 
       
    41 template <class T> void CleanupResetAndDestroyClose<T>::Close(TAny *aPtr)
       
    42     {
       
    43     static_cast<T*>(aPtr)->ResetAndDestroy();
       
    44     static_cast<T*>(aPtr)->Close();
       
    45     }
       
    46 
       
    47 template <class T> inline void CleanupResetAndDestroyClosePushL(T& aRef)
       
    48     {
       
    49     CleanupResetAndDestroyClose<T>::PushL(aRef);
       
    50     }
       
    51 
       
    52 #endif