Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

etools.h

Go to the documentation of this file.
00001 // ETOOLS.H
00002 //
00003 // Copyright (c) 1999 A. Heggestad. Conditions dont apply
00004 //
00005 
00006 #if !defined(__ETOOLS_H__)
00007 #define __ETOOLS_H__
00008 
00009 #if defined (__EPOC32__)
00010 #include <e32std.h>
00011 #endif
00012 
00013 // Tool for putting a name to the class
00014 // when a memory leak occurs, you can trace it back
00015 // by looking at the memory space!
00016 // the for(;;) is a bit awkward
00017 #if _DEBUG
00018 #define CLASSNAMEDECL(a) char __iName[sizeof(#a)];
00019 #define CLASSNAMEINIT(a) \
00020         char tmp[] = #a; \
00021         for(TUint i=0;i<sizeof(tmp);i++) __iName[i] = tmp[i];
00022 #else
00023 #define CLASSNAMEDECL(a)
00024 #define CLASSNAMEINIT(a)
00025 #endif
00026 
00027 
00028 //
00029 // put this in your constructor/desctructor to see the memory usage
00030 //
00031 #if defined(_DEBUG) || defined(__WINS__)
00032 #define CTOR(a) ELOG4(_L8("created object %s (%d bytes) at 0x%08x\n"), #a, sizeof(a), this );
00033 #define DTOR(a) ELOG4(_L8("deleted object %s (%d bytes) at 0x%08x\n"), #a, sizeof(a), this );
00034 #else
00035 #define CTOR(a)
00036 #define DTOR(a)
00037 #endif
00038 
00039 //
00040 // Use this macro in the beginning of functions to check that some ptrs are != NULL
00041 //
00042 
00043 #ifndef __PANIC
00044 #ifdef _UNICODE
00045 #define __PANIC(p) { char tmp[] = __FILE__; \
00046                 TInt i;\
00047                 for(i=sizeof(tmp)-1;i>=0;i--) \
00048                         if( (tmp[i] == 0x5c /* '\' */) || (tmp[i] == '/') ) \
00049                                 break; \
00050                 TBuf8<32> txt8((const TUint8*)&tmp[++i]); \
00051                 TBuf16<32> txt16; \
00052                 txt16.Copy(txt8); \
00053                 User::Panic( txt16 , __LINE__ ); }
00054 #else
00055 #define __PANIC(p)      { \
00056                                         RDebug::Print(_L("WARNING!!! pointer to '%s' was NULL"), #p ); \
00057                                         RDebug::Print(_L("WARNING!!! file %s line %d"), __FILE__, __LINE__ ); \
00058                                         User::Panic( _L(__FILE__) , __LINE__ ); \
00059                                         }
00060 
00061 #endif  // _UNICODE
00062 
00063 #endif  // __PANIC
00064 
00065 #if defined(__WINS__) || defined(_DEBUG)
00066 #define __CHECK_NULL(p) if(p == NULL) __PANIC(p)
00067 #else
00068 #define __CHECK_NULL(p)
00069 #endif
00070 
00071 
00072 //
00073 // size of arrays
00074 //
00075 #ifndef ELEM_SIZE
00076 #define ELEM_SIZE(t) (sizeof(t)/sizeof(t[0]))
00077 #endif
00078 
00079 
00080 //
00081 //      Check var against mask, return bool type
00082 //
00083 #define BOOL_BIT(var,msk) ( (var & msk)==(msk) )
00084 //#define BOOL_BIT(var,msk)     (var & msk)
00085 //#pragma warning( disable : 4800 )  // Disable warning messages
00086 
00087 #if _DEBUG
00088 #define DBG(a)  RDebug::Print(_L(a));
00089 #define DBGF    RDebug::Print
00090 #else
00091 #define DBG(a)
00092 #define DBGF    (void)
00093 #endif
00094 
00095 //#define HEAVY_DEBUGGING
00096 
00097 #if defined(HEAVY_DEBUGGING) && defined(_DEBUG)
00098 #define DBGARM(a)       RDebug::Print(_L(a));
00099 #else
00100 #define DBGARM(a)
00101 #endif
00102 
00103 //
00104 // Profiling - log ticks
00105 //
00106 #if _DEBUG
00107 #define DUMP_TICK(a) RDebug::Print(_L("tick %d: %d"), a, User::TickCount() );
00108 #else
00109 #define DUMP_TICK(a)
00110 #endif
00111 
00112 
00113 #endif // ETOOLS_H

Generated on Tue Feb 8 04:13:58 2005 for Esidplay by doxygen 1.3.3