35 #ifndef ID_ENABLE_DEBUGGING 36 #error ID_ENABLE_DEBUGGING is not defined in DEBUG. 40 #if defined(ID_ENABLE_DEBUGGING) 42 #include <boost/mpl/or.hpp> 43 #include <boost/utility/enable_if.hpp> 44 #include <boost/type_traits.hpp> 55 RUNTIME_DECL
void TraceImpl(bool16 checkCategory,
const char* category,
const char* filename,
const int32 lineNo,
const char* format, ...);
58 template<
typename A,
typename Enabler =
void>
59 struct get_return_type;
63 struct get_return_type<A,
64 typename boost::enable_if<boost::mpl::or_<boost::is_arithmetic<A>, boost::is_pointer<A>, boost::is_enum<A> > >::type >
71 struct get_return_type<std::string>
73 typedef const char* type;
78 struct get_return_type<
UID>
89 inline typename get_return_type<A>::type format_arg(A
const& a)
96 inline const char* format_arg<std::string>(std::string
const& a)
103 inline uint32 format_arg<UID>(
UID const& a)
112 class RUNTIME_DECL TraceCategory
118 explicit TraceCategory(
const char* str);
119 TraceCategory(
const TraceCategory& rhs);
121 TraceCategory& operator=(TraceCategory rhs);
124 inline const char* c_str()
const 129 inline friend void swap(TraceCategory& left, TraceCategory& right){
131 swap(left.fText, right.fText);
132 swap(left.fLen, right.fLen);
135 bool16 operator==(
const TraceCategory& rhs)
const;
136 bool16 operator<(
const TraceCategory& rhs)
const;
146 class RUNTIME_DECL TraceFlow
149 typedef std::pair<TraceCategory, bool16> SEntry;
150 typedef std::vector<SEntry> SEntryArray;
152 enum {kMaxCategories = 512};
156 static void EnableCategory(
const char* category, bool16 enable =
true);
157 static bool16 IsCategoryEnabled(
const char* category);
158 static void ClearAll();
159 static void RemoveAllDisabled();
162 static void GetEntries(SEntryArray& entries);
167 typedef SEntry* iterator;
169 static void AddCategory(TraceCategory
const& newCategory, bool16 enable);
170 static void RemoveCategory(iterator category);
172 static iterator __begin();
173 static iterator __end();
183 #include "TraceOverloads.h" 186 inline bool16 CheckPredicateInTrace(bool16 predicate)
191 #define TRACE(...) TRACE_INTERNAL(kFalse, "No_Category", __FILE__, __LINE__, __VA_ARGS__ ) 192 #define TRACEFLOW_WITH_FILE(category, file, lineno, ...) \ 193 TRACE_INTERNAL(kTrue, category, file, lineno, __VA_ARGS__ ) 195 #define TRACEFLOW(category, ...) TRACE_INTERNAL(kTrue, category, __FILE__, __LINE__, __VA_ARGS__ ) 197 #define TRACE_IF(predicate, ...) CheckPredicateInTrace(predicate) ? TRACE_INTERNAL(kFalse, "No_Category", __FILE__, __LINE__, __VA_ARGS__ ) : (void)0 199 #define TRACEFLOW_IF(predicate, category, ...) CheckPredicateInTrace(predicate) ? TRACE_INTERNAL(kTrue, category, __FILE__, __LINE__, __VA_ARGS__ ) : (void)0 202 #define TRACEFLOW_OBSOLETE(...) ((void) 0) 205 #ifndef DEBUG_LAYER_LOG 208 #define DEBUG_LAYER_LOG(category, ...) NSLog((@""), ##__VA_ARGS__) 210 #define DEBUG_LAYER_LOG(category, ...) TRACE_INTERNAL(kTrue, category, __FILE__, __LINE__, __VA_ARGS__ ) 215 #ifndef DEBUG_LAYER_LOG 216 #define DEBUG_LAYER_LOG(...) ((void) 0) 220 #else // !defined(ID_ENABLE_DEBUGGING) 221 #define TRACE(...) ((void) 0) 222 #define TRACEFLOW(...) ((void) 0) 223 #define TRACEFLOW_OBSOLETE(...) ((void) 0) 224 #define TRACE_IF(...) ((void) 0) 225 #define TRACEFLOW_IF(...) ((void) 0) 227 #define DEBUG_LAYER_LOG(...) ((void) 0) 229 #endif // defined(ID_ENABLE_DEBUGGING) 231 #endif // __TRACE_H__