7#ifndef PXR_BASE_TF_DIAGNOSTIC_LITE_H
8#define PXR_BASE_TF_DIAGNOSTIC_LITE_H
27#include "pxr/base/tf/api.h"
28#include "pxr/base/arch/buildMode.h"
34PXR_NAMESPACE_OPEN_SCOPE
39 TF_DIAGNOSTIC_INVALID_TYPE = 0,
40 TF_DIAGNOSTIC_CODING_ERROR_TYPE,
41 TF_DIAGNOSTIC_FATAL_CODING_ERROR_TYPE,
42 TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE,
43 TF_DIAGNOSTIC_FATAL_ERROR_TYPE,
44 TF_DIAGNOSTIC_NONFATAL_ERROR_TYPE,
45 TF_DIAGNOSTIC_WARNING_TYPE,
46 TF_DIAGNOSTIC_STATUS_TYPE,
47 TF_APPLICATION_EXIT_TYPE,
53struct Tf_DiagnosticLiteHelper {
54 constexpr Tf_DiagnosticLiteHelper(TfCallContext
const &context,
61 TF_API
void IssueError(
64 TF_API
void IssueFatalError(
66 TF_API
void IssueWarning(
68 TF_API
void IssueStatus(
72 TfCallContext _context;
76#define TF_CODING_ERROR \
77 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
78 TF_DIAGNOSTIC_CODING_ERROR_TYPE).IssueError
80#define TF_CODING_WARNING \
81 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
82 TF_DIAGNOSTIC_CODING_ERROR_TYPE).IssueWarning \
84#define TF_FATAL_CODING_ERROR \
85 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
86 TF_DIAGNOSTIC_CODING_ERROR_TYPE).IssueFatalError
88#define TF_RUNTIME_ERROR \
89 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
90 TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE).IssueError
92#define TF_FATAL_ERROR \
93 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
94 TF_DIAGNOSTIC_FATAL_ERROR_TYPE).IssueFatalError
96#define TF_DIAGNOSTIC_FATAL_ERROR \
97 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
98 TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE).IssueFatalError
100#define TF_DIAGNOSTIC_NONFATAL_ERROR \
101 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
102 TF_DIAGNOSTIC_WARNING_TYPE).IssueWarning
104#define TF_DIAGNOSTIC_WARNING \
105 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT.Hide(), \
106 TF_DIAGNOSTIC_WARNING_TYPE).IssueWarning
109 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
110 TF_DIAGNOSTIC_WARNING_TYPE).IssueWarning
113 Tf_DiagnosticLiteHelper(TF_CALL_CONTEXT, \
114 TF_DIAGNOSTIC_STATUS_TYPE).IssueStatus
117Tf_AxiomHelper(
bool val, TfCallContext
const &ctx,
char const *txt) {
118 return (ARCH_LIKELY(val)) ? true :
119 (Tf_DiagnosticLiteHelper(ctx, TF_DIAGNOSTIC_FATAL_ERROR_TYPE).
120 IssueFatalError(
"Failed axiom: ' %s '", txt),
false);
123#define TF_AXIOM(cond) \
124 Tf_AxiomHelper(static_cast<bool>((cond)), TF_CALL_CONTEXT, #cond)
126#define TF_DEV_AXIOM(cond) \
127 Tf_AxiomHelper(!ARCH_DEV_BUILD || \
128 static_cast<bool>((cond)), TF_CALL_CONTEXT, #cond)
132PXR_NAMESPACE_CLOSE_SCOPE
Define function attributes.
#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
Macro used to indicate a function takes a printf-like specification.
Functions for recording call locations.
TfDiagnosticType
Enum describing various diagnostic conditions.