7#ifndef PXR_BASE_TF_DIAGNOSTIC_TRAP_H
8#define PXR_BASE_TF_DIAGNOSTIC_TRAP_H
13#include "pxr/base/tf/api.h"
20PXR_NAMESPACE_OPEN_SCOPE
97 template <
class Predicate>
99 Tf_DiagnosticContainer result;
101 auto it = _container.GetIterator();
102 while (it.Next([&](
auto const &d) {
103 if (auto r = TfTryInvoke<bool>(std::forward<Predicate>(pred), d)) {
112 _container = std::move(result);
113 _OnContentsChanged();
135 template <
class Predicate>
137 auto it = _container.GetIterator();
138 while (
auto r = it.Next(std::forward<Predicate>(pred))) {
175 template <
class Predicate>
177 auto it = _container.GetIterator();
178 while (
auto r = it.Next(std::forward<Predicate>(pred))) {
190 template <
class Predicate>
193 auto it = _container.GetIterator();
194 while (
auto r = it.Next(std::forward<Predicate>(pred))) {
221 Tf_DiagnosticContainer copy(_container);
222 auto it = copy.GetIterator();
223 while (it.Next(std::forward<Fn>(fn))) {}
235 TF_API
void _OnContentsChanged()
const;
237 Tf_DiagnosticContainer _container;
238 bool _active =
false;
241PXR_NAMESPACE_CLOSE_SCOPE
Singleton class through which all errors and diagnostics pass.
A facility for transporting diagnostics from thread to thread.
A scoped, stack-based mechanism for intercepting and examining diagnostics issued on the current thre...
TF_API std::vector< TfError > const & GetErrors() const
Return the captured errors.
TF_API void ClearErrors()
Discard all captured errors. They will not be re-posted.
TF_API void Dismiss()
Re-post any uncleared diagnostics and deactivate the trap; called automatically on destruction if not...
TF_API TfDiagnosticTrap()
Construct a trap and install it as the active interceptor on the current thread.
TF_API void ClearWarnings()
Discard all captured warnings. They will not be re-posted.
TF_API bool HasStatuses() const
Return true if any status messages have been captured.
size_t CountMatching(Predicate &&pred) const
Return the number of captured diagnostics for which pred returns true.
TF_API void Clear()
Discard all captured diagnostics. They will not be re-posted.
TF_API bool HasWarnings() const
Return true if any warnings have been captured.
TF_API bool HasErrors() const
Return true if any errors have been captured.
bool HasAnyMatching(Predicate &&pred) const
Invoke pred on the captured diagnostics in order, returning true as soon as pred returns true for any...
TF_API std::vector< TfWarning > const & GetWarnings() const
Return the captured warnings.
size_t EraseMatching(Predicate &&pred)
Erase all captured diagnostics for which pred returns true, preserving the relative order of the rema...
TF_API ~TfDiagnosticTrap()
Destroy the trap, re-posting any diagnostics not explicitly discarded by calls to the Clear or Erase ...
TF_API TfDiagnosticTransport Transport()
Move all accumulated diagnostics into a TfDiagnosticTransport, leaving this trap active but empty.
TF_API bool IsClean() const
Return true if no diagnostics have been captured.
TF_API std::vector< TfStatus > const & GetStatuses() const
Return the captured status messages.
void ForEach(Fn &&fn) const
Invoke fn for each captured diagnostic in the order they were received.
TF_API void ClearStatuses()
Discard all captured status messages. They will not be re-posted.
bool HasAllMatching(Predicate &&pred) const
Invoke pred on the captured diagnostics in order, returning false as soon as pred returns false for a...