All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfDiagnosticBase Class Reference

Represents the base class of an object representing a diagnostic message. More...

+ Inheritance diagram for TfDiagnosticBase:

Public Member Functions

const TfCallContext & GetContext () const
 Return the call context where the message was issued. More...
 
std::string GetSourceFileName () const
 Return the source file name that the diagnostic message was posted from. More...
 
size_t GetSourceLineNumber () const
 Return the source line number that the diagnostic message was posted from. More...
 
std::string const & GetCommentary () const
 Return the commentary string describing this diagnostic message. More...
 
std::string GetSourceFunction () const
 Return the source function that the diagnostic message was posted from. More...
 
void AugmentCommentary (const std::string &s)
 Add to the commentary string describing this diagnostic message. More...
 
TfEnum GetDiagnosticCode () const
 Return the diagnostic code posted. More...
 
const std::string & GetDiagnosticCodeAsString () const
 Return the diagnostic code posted as a string. More...
 
template<typename T >
const T * GetInfo () const
 Return a (possibly NULL) const pointer to the info object associated with this message. More...
 
void SetInfo (TfDiagnosticInfo any)
 Set the info object associated with this diagnostic message. More...
 
bool GetQuiet () const
 Return true if the message was posted via PostQuietly(). More...
 
std::string GetPrettyPrintString () const
 Return the commentary string. More...
 
bool IsFatal () const
 Return true if this diagnostic's code is a fatal code. More...
 
bool IsCodingError () const
 Return true if this diagnostic's code is either a fatal or nonfatal coding error. More...
 
 TfDiagnosticBase (TfEnum code, char const *codeString, TfCallContext const &context, const std::string &commentary, TfDiagnosticInfo info, bool quiet)
 Construct an instance. More...
 

Protected Attributes

TfCallContext _context
 
std::string _commentary
 
TfEnum _code
 
std::string _codeString
 
TfDiagnosticInfo _info
 
size_t _serial = 0
 
bool _quiet = false
 

Friends

class TfDiagnosticMgr
 
class TfErrorTransport
 
class TfErrorMark
 

Detailed Description

Represents the base class of an object representing a diagnostic message.

This forms the base class for specific types associated with errors, warnings and status messages. It associates a diagnostic code (which is an enum value) with the message. It can also hold on to arbitrary information associated with the message in a TfDiagnosticInfo.

See The TfError Error Posting System in the C++ API reference for a detailed example. For a description of how to post an error, warning or a status message see TF_ERROR(), TF_WARN and TF_STATUS also in the C++ API reference.

Definition at line 64 of file diagnosticBase.h.

Constructor & Destructor Documentation

TfDiagnosticBase ( TfEnum  code,
char const *  codeString,
TfCallContext const &  context,
const std::string &  commentary,
TfDiagnosticInfo  info,
bool  quiet 
)

Construct an instance.

Member Function Documentation

void AugmentCommentary ( const std::string &  s)
inline

Add to the commentary string describing this diagnostic message.

Note: each string added to the commentary is separated from the previous one with a newline. This means that you the string s should not end with a newline. Thus,

* cout << e.GetCommentary() << "\n";
*

always prints the entire commentary string as a newline separated sequence of messages.

Definition at line 104 of file diagnosticBase.h.

std::string const& GetCommentary ( ) const
inline

Return the commentary string describing this diagnostic message.

Definition at line 84 of file diagnosticBase.h.

const TfCallContext& GetContext ( ) const
inline

Return the call context where the message was issued.

Definition at line 68 of file diagnosticBase.h.

TfEnum GetDiagnosticCode ( ) const
inline

Return the diagnostic code posted.

Definition at line 114 of file diagnosticBase.h.

const std::string& GetDiagnosticCodeAsString ( ) const
inline

Return the diagnostic code posted as a string.

If the enum value posted with the message has been registered with TF_ADD_ENUM_NAME(), then GetDiagnosticCodeAsString() will return the symbolic name of the enum.

If the enum has not been registered, then code of the form

* TF_ERROR(PUCE).Post("is an ugly color");
*

will still result in GetDiagnosticCodeAsString() returning the string "PUCE"; however, code of the form

* MyErrorCode c = PUCE;
* TF_ERROR(c).Post("is still ugly");
*

will result in GetDiagnosticCodeAsString() returning the (uninformative) string "c".

Definition at line 137 of file diagnosticBase.h.

const T* GetInfo ( ) const
inline

Return a (possibly NULL) const pointer to the info object associated with this message.

If this message was posted without supplying an info argument to Post(), e.g.

* TF_ERROR(SOME_CODE).Post("something went wrong");
*

then GetInfo() returns NULL. Otherwise, when info is supplied, e.g.

* T myInfo = ...
* TF_ERROR(SOME_CODE).Post("something went wrong")->SetInfo(myInfo);
*

then a const pointer to a copy of myInfo in the above example is returned by GetInfo<T>(). If the type T doesn't match the held type then GetInfo() returns NULL.

Definition at line 161 of file diagnosticBase.h.

std::string GetPrettyPrintString ( ) const

Return the commentary string.

bool GetQuiet ( ) const
inline

Return true if the message was posted via PostQuietly().

Notices sent from PostQuietly() are indicating that an immediate printout of the error is not desirable, because someone higher up on the stack may actually handle this error. This is rare, but it does happen on occasion.

Definition at line 177 of file diagnosticBase.h.

std::string GetSourceFileName ( ) const
inline

Return the source file name that the diagnostic message was posted from.

Definition at line 73 of file diagnosticBase.h.

std::string GetSourceFunction ( ) const
inline

Return the source function that the diagnostic message was posted from.

Definition at line 89 of file diagnosticBase.h.

size_t GetSourceLineNumber ( ) const
inline

Return the source line number that the diagnostic message was posted from.

Definition at line 79 of file diagnosticBase.h.

bool IsCodingError ( ) const

Return true if this diagnostic's code is either a fatal or nonfatal coding error.

bool IsFatal ( ) const

Return true if this diagnostic's code is a fatal code.

void SetInfo ( TfDiagnosticInfo  any)
inline

Set the info object associated with this diagnostic message.

See Also
GetInfo()

Definition at line 167 of file diagnosticBase.h.


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