Loading...
Searching...
No Matches
TfDiagnosticMgr Class Reference

Singleton class through which all errors and diagnostics pass. More...

#include <diagnosticMgr.h>

+ Inheritance diagram for TfDiagnosticMgr:

Classes

class  Delegate
 One may set a delegate with the TfDiagnosticMgr which will be called to respond to errors and diagnostics. More...
 

Public Types

typedef TfDiagnosticMgr This
 
typedef std::list< TfErrorErrorList
 
typedef ErrorList::iterator ErrorIterator
 Synonym for standard STL iterator to traverse the error list.
 

Public Member Functions

TF_API void AddDelegate (Delegate *delegate)
 Add the delegate delegate to the list of current delegates.
 
TF_API void RemoveDelegate (Delegate *delegate)
 Removes all delegates equal to delegate from the current delegates.
 
TF_API void SetQuiet (bool quiet)
 Set whether errors, warnings and status messages should be printed out to the terminal.
 
ErrorIterator GetErrorBegin ()
 Return an iterator to the beginning of this thread's error list.
 
ErrorIterator GetErrorEnd ()
 Return an iterator to the end of this thread's error list.
 
TF_API ErrorIterator EraseError (ErrorIterator i)
 Remove error specified by iterator i.
 
TF_API ErrorIterator EraseRange (ErrorIterator first, ErrorIterator last)
 Remove all the errors in [first, last) from this thread's error stream.
 
TF_API void AppendError (TfError const &e)
 Append an error to the list of active errors.
 
TF_API void PostError (TfEnum errorCode, const char *errorCodeString, TfCallContext const &context, const std::string &commentary, TfDiagnosticInfo info, bool quiet)
 This method will create a TfError, append it to the error list, and pass it to all delegates.
 
TF_API void PostError (const TfDiagnosticBase &diagnostic)
 This method will create a TfError, append it to the error list, and pass it to all delegates.
 
TF_API void PostWarning (TfEnum warningCode, const char *warningCodeString, TfCallContext const &context, std::string const &commentary, TfDiagnosticInfo info, bool quiet)
 This method will create a TfWarning and pass it to all delegates.
 
TF_API void PostWarning (const TfDiagnosticBase &diagnostic)
 This method will create a TfWarning and pass it to all delegates.
 
TF_API void PostStatus (TfEnum statusCode, const char *statusCodeString, TfCallContext const &context, std::string const &commentary, TfDiagnosticInfo info, bool quiet)
 This method will create a TfStatus and pass it to all delegates.
 
TF_API void PostStatus (const TfDiagnosticBase &diagnostic)
 This method will create a TfStatus and pass it to all delegates.
 
TF_API void PostFatal (TfCallContext const &context, TfEnum statusCode, std::string const &msg) const
 This method will issue a fatal error to all delegates.
 
bool HasActiveErrorMark ()
 Return true if an instance of TfErrorMark exists in the current thread of execution, false otherwise.
 
- Public Member Functions inherited from TfWeakBase
 TfWeakBase (const TfWeakBase &)
 
const TfWeakBase__GetTfWeakBase__ () const
 
const TfWeakBaseoperator= (const TfWeakBase &)
 
void EnableNotification2 () const
 
TF_API void const * GetUniqueIdentifier () const
 

Static Public Member Functions

static TF_API std::string GetCodeName (const TfEnum &code)
 Returns the name of the given diagnostic code.
 
static TF_API std::string FormatDiagnostic (const TfEnum &code, const TfCallContext &context, const std::string &msg, const TfDiagnosticInfo &info)
 Return a human-readable diagnostic message.
 
static TF_API ThisGetInstance ()
 Return the singleton instance.
 

Friends

class TfSingleton< This >
 
class TfDiagnosticTransport
 
class TfDiagnosticTrap
 
class TfError
 
class TfErrorTransport
 
class TfErrorMark
 

Additional Inherited Members

- Protected Member Functions inherited from TfWeakBase
TfRefPtr< Tf_Remnant > _Register () const
 
template<class T >
TfRefPtr< Tf_Remnant > _Register (T *tempRmnt) const
 
bool _HasRemnant () const
 

Detailed Description

Singleton class through which all errors and diagnostics pass.

Definition at line 60 of file diagnosticMgr.h.

Member Typedef Documentation

◆ ErrorIterator

ErrorList::iterator ErrorIterator

Synonym for standard STL iterator to traverse the error list.

The error list for a thread is an STL list. The ErrorIterator type is an STL iterator and can be used without restriction in any way that it is legal to use an STL iterator.

Given an iterator, one accesses the error in the standard STL fashion:

... ;
if (!m.IsClean()) {
TfErrorMark::Iterator i;
for (i = m.GetBegin(); i != m.GetEnd(); ++i) {
cout << "file = " << i->GetSourceFileName()
<< "line = " << i->GetSourceLineNumber() << "\n";
}
Class used to record the end of the error-list.
Definition errorMark.h:48
Iterator GetBegin(size_t *nErrors=0) const
Return an iterator to the first error added to the error list after SetMark().
Definition errorMark.h:136
Iterator GetEnd() const
Return an iterator past the last error in the error system.
Definition errorMark.h:145
bool IsClean() const
Return true if no new errors were posted in this thread since the last call to SetMark(),...
Definition errorMark.h:82

Definition at line 85 of file diagnosticMgr.h.

◆ ErrorList

std::list<TfError> ErrorList

Definition at line 65 of file diagnosticMgr.h.

◆ This

Definition at line 63 of file diagnosticMgr.h.

Member Function Documentation

◆ AddDelegate()

TF_API void AddDelegate ( Delegate * delegate)

Add the delegate delegate to the list of current delegates.

This will add the delegate even if it already exists in the list.

Each delegate will be called when diagnostics and errors are invoked

This function is thread safe.

◆ AppendError()

TF_API void AppendError ( TfError const & e)

Append an error to the list of active errors.

This is generally not meant to be called by user code. It is public so that the system which translates tf errors to and from python exceptions can manage errors.

◆ EraseError()

TF_API ErrorIterator EraseError ( ErrorIterator i)

Remove error specified by iterator i.

Deprecated
Use TfErrorMark instead.

◆ EraseRange()

TF_API ErrorIterator EraseRange ( ErrorIterator first,
ErrorIterator last )

Remove all the errors in [first, last) from this thread's error stream.

This should generally not be invoked directly. Use TfErrorMark instead.

◆ FormatDiagnostic()

static TF_API std::string FormatDiagnostic ( const TfEnum & code,
const TfCallContext & context,
const std::string & msg,
const TfDiagnosticInfo & info )
static

Return a human-readable diagnostic message.

The TfDiagnosticMgr uses this function to print diagnostics when no diagnostic delegates are installed. Diagnostic delegate implementations can call this to produce messages in the same format, if desired.

◆ GetCodeName()

static TF_API std::string GetCodeName ( const TfEnum & code)
static

Returns the name of the given diagnostic code.

◆ GetErrorBegin()

ErrorIterator GetErrorBegin ( )
inline

Return an iterator to the beginning of this thread's error list.

Definition at line 170 of file diagnosticMgr.h.

◆ GetErrorEnd()

ErrorIterator GetErrorEnd ( )
inline

Return an iterator to the end of this thread's error list.

Definition at line 175 of file diagnosticMgr.h.

◆ GetInstance()

static TF_API This & GetInstance ( )
inlinestatic

Return the singleton instance.

Definition at line 144 of file diagnosticMgr.h.

◆ HasActiveErrorMark()

bool HasActiveErrorMark ( )
inline

Return true if an instance of TfErrorMark exists in the current thread of execution, false otherwise.

Definition at line 259 of file diagnosticMgr.h.

◆ PostError() [1/2]

TF_API void PostError ( const TfDiagnosticBase & diagnostic)

This method will create a TfError, append it to the error list, and pass it to all delegates.

If no delegates have been registered and no error mark is active, this method will print the error to stderr.

◆ PostError() [2/2]

TF_API void PostError ( TfEnum errorCode,
const char * errorCodeString,
TfCallContext const & context,
const std::string & commentary,
TfDiagnosticInfo info,
bool quiet )

This method will create a TfError, append it to the error list, and pass it to all delegates.

If no delegates have been registered and no error mark is active, this method will print the error to stderr.

◆ PostFatal()

TF_API void PostFatal ( TfCallContext const & context,
TfEnum statusCode,
std::string const & msg ) const

This method will issue a fatal error to all delegates.

If no delegates have been registered, or if none of the delegates abort the process, this method will print the error msg and abort the process.

◆ PostStatus() [1/2]

TF_API void PostStatus ( const TfDiagnosticBase & diagnostic)

This method will create a TfStatus and pass it to all delegates.

If no delegates have been registered, this method will print the status msg to stderr.

◆ PostStatus() [2/2]

TF_API void PostStatus ( TfEnum statusCode,
const char * statusCodeString,
TfCallContext const & context,
std::string const & commentary,
TfDiagnosticInfo info,
bool quiet )

This method will create a TfStatus and pass it to all delegates.

If no delegates have been registered, this method will print the status msg to stderr.

◆ PostWarning() [1/2]

TF_API void PostWarning ( const TfDiagnosticBase & diagnostic)

This method will create a TfWarning and pass it to all delegates.

If no delegates have been registered, this method will print the warning msg to stderr.

◆ PostWarning() [2/2]

TF_API void PostWarning ( TfEnum warningCode,
const char * warningCodeString,
TfCallContext const & context,
std::string const & commentary,
TfDiagnosticInfo info,
bool quiet )

This method will create a TfWarning and pass it to all delegates.

If no delegates have been registered, this method will print the warning msg to stderr.

◆ RemoveDelegate()

TF_API void RemoveDelegate ( Delegate * delegate)

Removes all delegates equal to delegate from the current delegates.

This function is thread safe.

◆ SetQuiet()

TF_API void SetQuiet ( bool quiet)
inline

Set whether errors, warnings and status messages should be printed out to the terminal.

Definition at line 167 of file diagnosticMgr.h.

Friends And Related Symbol Documentation

◆ TfDiagnosticTransport

friend class TfDiagnosticTransport
friend

Definition at line 554 of file diagnosticMgr.h.

◆ TfDiagnosticTrap

friend class TfDiagnosticTrap
friend

Definition at line 555 of file diagnosticMgr.h.

◆ TfError

friend class TfError
friend

Definition at line 556 of file diagnosticMgr.h.

◆ TfErrorMark

friend class TfErrorMark
friend

Definition at line 558 of file diagnosticMgr.h.

◆ TfErrorTransport

friend class TfErrorTransport
friend

Definition at line 557 of file diagnosticMgr.h.

◆ TfSingleton< This >

friend class TfSingleton< This >
friend

Definition at line 389 of file diagnosticMgr.h.


The documentation for this class was generated from the following file: