17#if !defined(OWL_PRIVATE_CHECKS_H)
18#define OWL_PRIVATE_CHECKS_H
19#define SERVICES_CHECKS_H
22#if defined(BI_HAS_PRAGMA_ONCE)
142 :
public std::exception
151 virtual const char* what()
const noexcept;
213# define VALIDPTR(p) ((p) != 0)
217# define VALIDPTR(p) (!::IsBadReadPtr((p),1))
220#define VALIDORNULLPTR(p) (!(p) || VALIDPTR(p))
227#define PRECONDITION(condition) PRECONDITIONX(condition, ::owl::TDiagException::ToString(#condition))
229# define PRECONDITIONX(condition, message) DIAG_ASSERT_IMPL(Precondition, condition, message)
231# define PRECONDITIONX(condition, message) ((void)0)
239#define CHECK(condition) CHECKX(condition, ::owl::TDiagException::ToString(#condition))
241# define CHECKX(condition, message) DIAG_ASSERT_IMPL(Check, condition, message)
242# define VERIFY(condition) CHECK(condition)
243# define VERIFYX(condition, message) CHECKX(condition, message)
245# define CHECKX(condition, message) ((void)0)
246# define VERIFY(condition) ((void)(condition))
247# define VERIFYX(condition, message) ((void)(condition))
255#define TRACE(message) TRACEX(Def, 0, message)
256#define TRACE_FUNCTION(function) TRACE_FUNCTIONX(Def, 0, function)
257#define TRACE_FUNCTIONP(function, condition) TRACE_FUNCTIONXP(Def, 0, function, condition)
259# define TRACEX(group, level, message) DIAG_TRACE_IMPL(Trace, group, true, level, message)
260# define TRACE_FUNCTIONX(group, level, function) ::owl::TDiagFunction __traceFunc((::owl::TDiagBase&)__OwlDiagGroup##group, level, function, __FILE__, __LINE__)
261# define TRACE_FUNCTIONXP(group, level, function, condition) ::owl::TDiagFunction __traceFunc((::owl::TDiagBase&)__OwlDiagGroup##group, level, function, condition, __FILE__, __LINE__)
263# define TRACEX(group, level, message) ((void)0)
264# define TRACE_FUNCTIONX(group, level, function) ((void)0)
265# define TRACE_FUNCTIONXP(group, level, function, condition) ((void)0)
273#define WARN(condition, message) WARNX(Def, condition, 0, message)
275# define WARNX(group, condition, level, message) DIAG_TRACE_IMPL(Warn, group, condition, level, message)
277# define WARNX(group, condition, level, message) ((void)0)
283#define TRACEX_IF(condition, group, level, message) WARNX(group, condition, level, message)
284#define TRACE_IF(condition, message) WARNX(Def, condition, 0, message)
289#define DIAG_ASSERT_IMPL(assertion, condition, message)\
291 int retval = ::owl::TDiagException::BreakMessage(#assertion, message, __FILE__, __LINE__);\
292 if (retval == IDRETRY)\
294 else if (retval == IDABORT)\
295 {throw ::owl::T##assertion##Failure(message, __FILE__, __LINE__);}\
301#define DIAG_TRACE_IMPL(operation, group, condition, level, message)\
303 using namespace ::owl;\
304 if (__OwlDiagGroup##group.IsEnabled() && level <= __OwlDiagGroup##group.GetLevel() && (condition)) {\
305 tostringstream out; out << message;\
306 __OwlDiagGroup##group.operation(out.str(), level, __FILE__, __LINE__);\
313#if defined(__TRACE) || defined(__WARN)
315#if defined(_OWLDLL) || defined(_BUILDOWLDLL)
316# if !defined(DIAG_IMPORT)
317# define DIAG_IMPORT __declspec(dllimport)
319# if !defined(DIAG_EXPORT)
320# define DIAG_EXPORT __declspec(dllexport)
327#define DECLARE_DIAG_GROUP_COMMON(group)\
329 TDiagGroup##group(LPCSTR name, bool enable, int level);\
330 virtual ::owl::TModule* GetDiagModule();\
333#define DECLARE_DIAG_GROUP(group, qual)\
334 class qual TDiagGroup##group : public ::owl::TDiagBase {\
335 DECLARE_DIAG_GROUP_COMMON(group)
337#define DECLARE_DIAG_STATIC_GROUP(group)\
338 class TDiagGroup##group : public ::owl::TDiagBase {\
339 DECLARE_DIAG_GROUP_COMMON(group)
341#define DIAG_DEFINE_GROUP_COMMON(group)\
342 TDiagGroup##group::TDiagGroup##group(LPCSTR name,bool enable, int level) : ::owl::TDiagBase(name, enable, level) {}\
343 ::owl::TModule* TDiagGroup##group::GetDiagModule() {return &::owl::GetGlobalModule();}
345#define _DIAG_DEFINE_GROUP_(group, enable, level, t)\
346 DECLARE_DIAG_GROUP(group, t);\
347 DIAG_DEFINE_GROUP_COMMON(group)
349#define _DIAG_DEFINE_GROUP_STATIC(group, enable, level)\
350 DECLARE_DIAG_STATIC_GROUP(group);\
351 DIAG_DEFINE_GROUP_COMMON(group);\
352 TDiagGroup##group __OwlDiagGroup##group(#group, enable, level)
357#define OWL_DIAG_DEFINE_GROUP(group, enable, level) \
358 DIAG_DEFINE_GROUP_COMMON(group); \
359 TDiagGroup##group __OwlDiagGroup##group(#group, enable, level)
361#define DIAG_DECLARE_GROUP(group)\
362 DECLARE_DIAG_STATIC_GROUP(group);\
363 extern TDiagGroup##group __OwlDiagGroup##group
365#define DIAG_DEFINE_GROUP(group, enable, level)\
366 _DIAG_DEFINE_GROUP_STATIC(group, enable, level);
368#define DIAG_DECLARE_EXPORTGROUP(group)\
369 DECLARE_DIAG_GROUP(group, DIAG_EXPORT);\
370 extern _OWLEXPORTDATA(TDiagGroup##group) __OwlDiagGroup##group
372#define DIAG_DECLARE_IMPORTTGROUP(group)\
373 DECLARE_DIAG_GROUP(group, DIAG_IMPORT);\
374 extern _OWLIMPORTDATA(TDiagGroup##group) __OwlDiagGroup##group
379#define OWL_DIAG_DEFINE_EXPORTGROUP(group, enable, level)\
380 DIAG_DEFINE_GROUP_COMMON(group)\
381 _OWLEXPORTDATA(TDiagGroup##group) __OwlDiagGroup##group(#group, enable, level)
383#define DIAG_DEFINE_EXPORTGROUP(group, enable, level)\
384 _DIAG_DEFINE_GROUP_(group, enable, level, DIAG_EXPORT);\
385 _OWLEXPORTDATA(TDiagGroup##group) __OwlDiagGroup##group(#group, enable, level)
390#define DIAG_ENABLE(group, s) __OwlDiagGroup##group.Enable(s)
391#define DIAG_ISENABLED(group) __OwlDiagGroup##group.IsEnabled()
392#define DIAG_SETLEVEL(group, level) __OwlDiagGroup##group.SetLevel(level)
393#define DIAG_GETLEVEL(group) __OwlDiagGroup##group.GetLevel()
394#define DIAG_REDIRECT(group, s) __OwlDiagGroup##group.SetLocalHook(s)
404#define DIAG_DECLARE_GROUP(group)
405#define DIAG_DECLARE_EXPORTGROUP(group)
406#define DIAG_DECLARE_IMPORTTGROUP(group)
408#define DIAG_DEFINE_GROUP(group,enable,level)
409#define OWL_DIAG_DEFINE_GROUP(group,enable,level)
410#define DIAG_DEFINE_EXPORTGROUP(group,enable,level)
412#define DIAG_ENABLE(group,s) ((void)0)
413#define DIAG_ISENABLED(group) ((void)0)
414#define DIAG_SETLEVEL(group,level) ((void)0)
415#define DIAG_GETLEVEL(group) ((void)0)
416#define DIAG_REDIRECT(group,s) ((void)0)
426#define OWL_DIAG_DEFINE_GROUP_INIT(f,g,e,l)\
427 OWL_DIAG_DEFINE_GROUP(g, ::owl::GetDiagEnabled(f,#g,e), ::owl::GetDiagLevel(f,#g,l));
429#define DIAG_DEFINE_GROUP_INIT(f,g,e,l)\
430 DIAG_DEFINE_GROUP(g, ::owl::GetDiagEnabled(f,#g,e), ::owl::GetDiagLevel(f,#g,l));
432#define OWL_DIAG_DEFINE_EXPORTGROUP_INIT(f,g,e,l)\
433 OWL_DIAG_DEFINE_EXPORTGROUP(g, ::owl::GetDiagEnabled(f,#g,e), ::owl::GetDiagLevel(f,#g,l));
435#define DIAG_DEFINE_EXPORTGROUP_INIT(f,g,e,l)\
436 DIAG_DEFINE_EXPORTGROUP(g, ::owl::GetDiagEnabled(f,#g,e), ::owl::GetDiagLevel(f,#g,l));
440#if (defined(__TRACE) || defined(__WARN)) && !defined(_DONT_DECLARE_DEF_DIAG_GROUP) && !defined(_DEF_DECLARED)
442# define _DEF_DECLARED
443# if defined(_BUILDOWLDLL)
445# elif defined(_OWLDLL)
457#if defined(__TRACE) || defined(__WARN)
468 {
return os <<
typeid(T).
name();}
496 {
return os <<
TraceType(
id.p) <<
" [" <<
static_cast<void*
>(
id.p) <<
"]";}
#define DIAG_DECLARE_GROUP(group)
#define DIAG_DECLARE_EXPORTGROUP(group)
#define DIAG_DECLARE_IMPORTTGROUP(group)
TDiagBaseHook * LocalHook
void Enable(bool enable=true)
void SetLocalHook(TDiagBaseHook *hook)
virtual TModule * GetDiagModule()=0
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Derived from xmsg, TXBase is the base class for ObjectWindows and ObjectComponents exception-handling...
Base exception support for framework exceptions.
Object Windows Library (OWLNext Core)
std::ostringstream tostringstream
bool GetDiagEnabled(LPCSTR filename, LPCSTR diagGroup, bool defEnabled)
Retrieves a diagnostic group's enabled flag from a private ini-file.
void InUse(const T &arg)
Handy utility to avoid compiler warnings about unused parameters.
tostringstream diag_stream
int GetDiagLevel(LPCSTR filename, LPCSTR diagGroup, int defLevel)
Retrieves a diagnostic group's level setting from a private ini-file.
virtual void Output(TDiagBase *group, LPCTSTR str)=0