messagingfw/msgsrvnstore/server/inc/MSVINVR.H
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #if !defined( __MSVINVR_H )
       
    18 #define __MSVINVR_H
       
    19 
       
    20 #if !defined(__E32BASE_H__)
       
    21 #include <e32base.h>
       
    22 #endif
       
    23 
       
    24 #define __DECLARE_DEBUG  __DECLARE_TEST
       
    25 
       
    26 #if defined(_DEBUG)
       
    27 
       
    28 template <class T>
       
    29 struct CheckInvariant
       
    30 	{
       
    31 	static void Check(TAny* aPtr)
       
    32 		{((T*)aPtr)->__DbgTestInvariant();}
       
    33 	};
       
    34 
       
    35 template <class T>
       
    36 inline TCleanupOperation CheckInvariantFunction(T*)
       
    37 	{return CheckInvariant<T>::Check;}
       
    38 
       
    39 class __DbgInvariant
       
    40 	{
       
    41 public:
       
    42 	inline __DbgInvariant(TCleanupOperation aOp,TAny* aPtr)
       
    43 		:iOp(aOp), iPtr(aPtr)
       
    44 		{}
       
    45 	inline ~__DbgInvariant()
       
    46 		{iOp(iPtr);}
       
    47 private:
       
    48 	TCleanupOperation iOp;
       
    49 	TAny* iPtr;
       
    50 	};
       
    51 
       
    52 class __DbgInvariantL
       
    53 	{
       
    54 public:
       
    55 	inline __DbgInvariantL(TCleanupOperation aOp,TAny* aPtr)
       
    56 		{CleanupStack::PushL(TCleanupItem(aOp,aPtr));}
       
    57 	inline ~__DbgInvariantL()
       
    58 		{CleanupStack::PopAndDestroy();}
       
    59 	};
       
    60 
       
    61 #define __DEBUG_INVARIANT_ONEXIT    __DbgInvariant __invariant(CheckInvariantFunction(this),this)
       
    62 #define __DEBUG_INVARIANT_ONEXIT_L  __DbgInvariantL __invariant(CheckInvariantFunction(this),this)
       
    63 
       
    64 #else // defined( _DEBUG )
       
    65 
       
    66 #define __DEBUG_INVARIANT_ONEXIT    
       
    67 #define __DEBUG_INVARIANT_ONEXIT_L  
       
    68 //#define __DECLARE_DEBUG
       
    69 
       
    70 #endif
       
    71 
       
    72 #endif // __MSVINVR_H