|
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 // Special build functions: ASSERTING, NOTIFY on Leave, TRACING |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __D32ASSERT_H__ |
|
19 #define __D32ASSERT_H__ |
|
20 |
|
21 #include <e32std.h> |
|
22 |
|
23 #if defined(_DEBUG) |
|
24 #define __DEBUG(s) s |
|
25 #define _ASSERTIONS |
|
26 //#define _NOTIFY |
|
27 //#define _TRACE |
|
28 //#define __DBDUMP__ |
|
29 #define __DBINVARIANT__ |
|
30 #else |
|
31 #define __DEBUG(s) |
|
32 #endif |
|
33 |
|
34 #ifdef __DBDUMP__ |
|
35 #include <f32file.h> //RFile |
|
36 #endif |
|
37 |
|
38 /** |
|
39 DECLARE_DB_DUMP, DECLARE_DB_DUMP2, DECLARE_DB_DUMP3 macros can be used for printing out |
|
40 DBMS security policy data to a text file. |
|
41 __DBDUMP__ macro must be defined if you want to use them. |
|
42 Usage: |
|
43 Use DECLARE_DB_DUMP macro for declaring pure virtual Dump(RFile& aFile) method in a particular class. |
|
44 Use DECLARE_DB_DUMP2 macro for declaring virtual Dump(RFile& aFile) method in a particular class. |
|
45 Use DECLARE_DB_DUMP3 macro for declaring non-virtual Dump(RFile& aFile) method in a particular class. |
|
46 @internalComponent |
|
47 */ |
|
48 |
|
49 #ifdef __DBDUMP__ |
|
50 #define DECLARE_DB_DUMP(aFile) virtual void Dump(RFile& aFile) const = 0; |
|
51 #define DECLARE_DB_DUMP2(aFile) virtual void Dump(RFile& aFile) const; |
|
52 #define DECLARE_DB_DUMP3(aFile) void Dump(RFile& aFile) const; |
|
53 #else |
|
54 #define DECLARE_DB_DUMP(aFile) |
|
55 #define DECLARE_DB_DUMP2(aFile) |
|
56 #define DECLARE_DB_DUMP3(aFile) |
|
57 #endif |
|
58 |
|
59 /** |
|
60 DECLARE_DB_INVARIANT, DECLARE_DB_INVARIANT2, DB_INVARIANT, DB_INVARIANT_ASSERT |
|
61 macros can be used for asserting the internal state of DBMS security policy classes. |
|
62 __DBINVARIANT__ macro must be defined if you want to use them. |
|
63 Usage: |
|
64 Use DECLARE_DB_INVARIANT macro for declaring virtual Invariant() method in a particular class. |
|
65 Use DECLARE_DB_INVARIANT2 macro for declaring non-virtual Invariant() method in a particular class. |
|
66 Use DB_INVARIANT macro to call Invariant() method somewhere in the code. |
|
67 Use DB_INVARIANT_ASSERT macro in places, where you want to use __ASSERT macro (it may not be defined). |
|
68 @internalComponent |
|
69 */ |
|
70 |
|
71 #ifdef __DBINVARIANT__ |
|
72 #define DECLARE_DB_INVARIANT() virtual void Invariant() const; |
|
73 #define DECLARE_DB_INVARIANT2() void Invariant() const; |
|
74 #define DB_INVARIANT() Invariant() |
|
75 #define DB_INVARIANT_ASSERT(aExprVal) Util::Invariant(aExprVal) |
|
76 #else |
|
77 #define DECLARE_DB_INVARIANT() |
|
78 #define DECLARE_DB_INVARIANT2() |
|
79 #define DB_INVARIANT() void(0) |
|
80 #define DB_INVARIANT_ASSERT(aExprVal) void(0) |
|
81 #endif |
|
82 |
|
83 /** |
|
84 @internalComponent |
|
85 */ |
|
86 class Util |
|
87 { |
|
88 public: |
|
89 static void Assert(const TText* aFile,TInt aLine); |
|
90 // |
|
91 static void Leave(const TText* aFile,TInt aLine,TInt aError); |
|
92 static TInt LeaveIfError(const TText* aFile,TInt aLine,TInt aError); |
|
93 // |
|
94 static void Trace(const TText* aFile,TInt aLine); |
|
95 static void Trace(const TText* aFile,TInt aLine,const TText* aString); |
|
96 static void Trace(const TText* aFile,TInt aLine,const TText* aExp,const TDesC& aDes); |
|
97 static void Trace(const TText* aFile,TInt aLine,const TText* aExp,TInt aVal); |
|
98 static void Trace(const TText* aFile,TInt aLine,const TText* aExp,const TAny* aPtr); |
|
99 static void Invariant(TBool aExprVal); |
|
100 private: |
|
101 static TPtrC Filename(const TText* aFile); |
|
102 }; |
|
103 |
|
104 #define __STRING(s) _S(s) |
|
105 |
|
106 #if defined(_ASSERTIONS) |
|
107 #define __ASSERT(c) (void)((c)||(Util::Assert(__STRING(__FILE__),__LINE__),0)) |
|
108 #else |
|
109 #define __ASSERT(c) void(0) |
|
110 #endif |
|
111 |
|
112 #if defined(_NOTIFY) |
|
113 #define __LEAVE(r) Util::Leave(__STRING(__FILE__),__LINE__,r) |
|
114 #define __LEAVE_IF_ERROR(r) Util::LeaveIfError(__STRING(__FILE__),__LINE__,r) |
|
115 #else |
|
116 #define __LEAVE(r) User::Leave(r) |
|
117 #define __LEAVE_IF_ERROR(r) User::LeaveIfError(r) |
|
118 #endif |
|
119 |
|
120 #if defined(_TRACE) |
|
121 #define __TRACEP() Util::Trace(__STRING(__FILE__),__LINE__) |
|
122 #define __TRACES(string) Util::Trace(__STRING(__FILE__),__LINE__,_S(string)) |
|
123 #define __TRACE(exp) Util::Trace(__STRING(__FILE__),__LINE__,__STRING(#exp),exp) |
|
124 #else |
|
125 #define __TRACEP() void(0) |
|
126 #define __TRACES(string) void(0) |
|
127 #define __TRACE(exp) void(0) |
|
128 #endif |
|
129 |
|
130 #endif//__D32ASSERT_H__ |