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

#include <diagnosticBase.h>

+ Inheritance diagram for TfDiagnosticBase:

Public Member Functions

const TfCallContextGetContext () 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
 
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)
 
TfEnum GetDiagnosticCode () const
 Return the diagnostic code posted. More...
 
const std::stringGetDiagnosticCodeAsString () const
 
template<typename T >
const TGetInfo () const
 
void SetInfo (TfDiagnosticInfo any)
 
bool GetQuiet () const
 
TF_API bool IsFatal () const
 Return true if this diagnostic's code is a fatal code. More...
 
TF_API bool IsCodingError () const
 
TF_API 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 page_tf_TfError 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 65 of file diagnosticBase.h.

Constructor & Destructor Documentation

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

Construct an instance.

Member Function Documentation

void TfDiagnosticBase::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 105 of file diagnosticBase.h.

std::string const& TfDiagnosticBase::GetCommentary ( ) const
inline

Return the commentary string describing this diagnostic message.

Definition at line 85 of file diagnosticBase.h.

const TfCallContext& TfDiagnosticBase::GetContext ( ) const
inline

Return the call context where the message was issued.

Definition at line 69 of file diagnosticBase.h.

TfEnum TfDiagnosticBase::GetDiagnosticCode ( ) const
inline

Return the diagnostic code posted.

Definition at line 115 of file diagnosticBase.h.

const std::string& TfDiagnosticBase::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 138 of file diagnosticBase.h.

template<typename T >
const T* TfDiagnosticBase::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 162 of file diagnosticBase.h.

bool TfDiagnosticBase::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 178 of file diagnosticBase.h.

std::string TfDiagnosticBase::GetSourceFileName ( ) const
inline

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

Definition at line 74 of file diagnosticBase.h.

std::string TfDiagnosticBase::GetSourceFunction ( ) const
inline

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

Definition at line 90 of file diagnosticBase.h.

size_t TfDiagnosticBase::GetSourceLineNumber ( ) const
inline

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

Definition at line 80 of file diagnosticBase.h.

TF_API bool TfDiagnosticBase::IsCodingError ( ) const

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

TF_API bool TfDiagnosticBase::IsFatal ( ) const

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

void TfDiagnosticBase::SetInfo ( TfDiagnosticInfo  any)
inline

Set the info object associated with this diagnostic message.

See Also
GetInfo()

Definition at line 168 of file diagnosticBase.h.

Friends And Related Function Documentation

friend class TfDiagnosticMgr
friend

Definition at line 208 of file diagnosticBase.h.

friend class TfErrorMark
friend

Definition at line 210 of file diagnosticBase.h.

friend class TfErrorTransport
friend

Definition at line 209 of file diagnosticBase.h.

Member Data Documentation

TfEnum TfDiagnosticBase::_code
protected

Definition at line 202 of file diagnosticBase.h.

std::string TfDiagnosticBase::_codeString
protected

Definition at line 203 of file diagnosticBase.h.

std::string TfDiagnosticBase::_commentary
protected

Definition at line 201 of file diagnosticBase.h.

TfCallContext TfDiagnosticBase::_context
protected

Definition at line 199 of file diagnosticBase.h.

TfDiagnosticInfo TfDiagnosticBase::_info
protected

Definition at line 204 of file diagnosticBase.h.

bool TfDiagnosticBase::_quiet = false
protected

Definition at line 206 of file diagnosticBase.h.

size_t TfDiagnosticBase::_serial = 0
protected

Definition at line 205 of file diagnosticBase.h.


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