Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Data Structures | Public Member Functions
Message_Messenger Class Reference

Messenger is API class providing general-purpose interface for libraries that may issue text messages without knowledge of how these messages will be further processed. More...

#include <Message_Messenger.hxx>

Inheritance diagram for Message_Messenger:
Inheritance graph
[legend]

Data Structures

class  StreamBuffer
 Auxiliary class wrapping std::stringstream thus allowing constructing message via stream interface, and putting result into its creator Message_Messenger within destructor. More...
 

Public Member Functions

 Message_Messenger ()
 Empty constructor; initializes by single printer directed to std::cout. Note: the default messenger is not empty but directed to cout in order to protect against possibility to forget defining printers. If printing to cout is not needed, clear messenger by GetPrinters().Clear()
 
 Message_Messenger (const occ::handle< Message_Printer > &thePrinter)
 Create messenger with single printer.
 
bool AddPrinter (const occ::handle< Message_Printer > &thePrinter)
 Add a printer to the messenger. The printer will be added only if it is not yet in the list. Returns True if printer has been added.
 
bool RemovePrinter (const occ::handle< Message_Printer > &thePrinter)
 Removes specified printer from the messenger. Returns True if this printer has been found in the list and removed.
 
int RemovePrinters (const occ::handle< Standard_Type > &theType)
 Removes printers of specified type (including derived classes) from the messenger. Returns number of removed printers.
 
const NCollection_Sequence< occ::handle< Message_Printer > > & Printers () const
 Returns current sequence of printers.
 
NCollection_Sequence< occ::handle< Message_Printer > > & ChangePrinters ()
 Returns sequence of printers The sequence can be modified.
 
void Send (const char *const theString, const Message_Gravity theGravity=Message_Warning) const
 Dispatch a message to all the printers in the list. Three versions of string representations are accepted for convenience, by default all are converted to ExtendedString.
 
void Send (const Standard_SStream &theStream, const Message_Gravity theGravity=Message_Warning) const
 See above.
 
void Send (const TCollection_AsciiString &theString, const Message_Gravity theGravity=Message_Warning) const
 See above.
 
void Send (const TCollection_ExtendedString &theString, const Message_Gravity theGravity=Message_Warning) const
 See above.
 
StreamBuffer Send (Message_Gravity theGravity)
 Create string buffer for message of specified type.
 
void Send (const occ::handle< Standard_Transient > &theObject, const Message_Gravity theGravity=Message_Warning) const
 See above.
 
StreamBuffer SendFail ()
 Create string buffer for sending Fail message.
 
StreamBuffer SendAlarm ()
 Create string buffer for sending Alarm message.
 
StreamBuffer SendWarning ()
 Create string buffer for sending Warning message.
 
StreamBuffer SendInfo ()
 Create string buffer for sending Info message.
 
StreamBuffer SendTrace ()
 Create string buffer for sending Trace message.
 
void SendFail (const TCollection_AsciiString &theMessage)
 Short-cut to Send (theMessage, Message_Fail)
 
void SendAlarm (const TCollection_AsciiString &theMessage)
 Short-cut to Send (theMessage, Message_Alarm)
 
void SendWarning (const TCollection_AsciiString &theMessage)
 Short-cut to Send (theMessage, Message_Warning)
 
void SendInfo (const TCollection_AsciiString &theMessage)
 Short-cut to Send (theMessage, Message_Info)
 
void SendTrace (const TCollection_AsciiString &theMessage)
 Short-cut to Send (theMessage, Message_Trace)
 
void DumpJson (Standard_OStream &theOStream, int theDepth=-1) const
 Dumps the content of me into the stream.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
bool IsKind (const char *const theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object.
 
- Static Public Member Functions inherited from Standard_Transient
static constexpr const charget_type_name ()
 Returns a type descriptor about this object.
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class.
 

Detailed Description

Messenger is API class providing general-purpose interface for libraries that may issue text messages without knowledge of how these messages will be further processed.

The messenger contains a sequence of "printers" which can be customized by the application, and dispatches every received message to all the printers.

For convenience, a set of methods Send...() returning a string stream buffer is defined for use of stream-like syntax with operator <<

Example:

Messenger->SendFail() << " Unknown fail at line " << aLineNo << " in file " << aFile;
STL input iterator that wraps an OCCT More()/Next() iterator.
Definition NCollection_ForwardRange.hxx:142

The message is sent to messenger on destruction of the stream buffer, call to Flush(), or passing manipulator std::ends, std::endl, or std::flush. Empty messages are not sent except if manipulator is used.

Constructor & Destructor Documentation

◆ Message_Messenger() [1/2]

Message_Messenger::Message_Messenger ( )

Empty constructor; initializes by single printer directed to std::cout. Note: the default messenger is not empty but directed to cout in order to protect against possibility to forget defining printers. If printing to cout is not needed, clear messenger by GetPrinters().Clear()

◆ Message_Messenger() [2/2]

Message_Messenger::Message_Messenger ( const occ::handle< Message_Printer > & thePrinter)

Create messenger with single printer.

Member Function Documentation

◆ AddPrinter()

bool Message_Messenger::AddPrinter ( const occ::handle< Message_Printer > & thePrinter)

Add a printer to the messenger. The printer will be added only if it is not yet in the list. Returns True if printer has been added.

◆ ChangePrinters()

NCollection_Sequence< occ::handle< Message_Printer > > & Message_Messenger::ChangePrinters ( )
inline

Returns sequence of printers The sequence can be modified.

◆ DumpJson()

void Message_Messenger::DumpJson ( Standard_OStream & theOStream,
int theDepth = -1 ) const

Dumps the content of me into the stream.

◆ Printers()

const NCollection_Sequence< occ::handle< Message_Printer > > & Message_Messenger::Printers ( ) const
inline

Returns current sequence of printers.

◆ RemovePrinter()

bool Message_Messenger::RemovePrinter ( const occ::handle< Message_Printer > & thePrinter)

Removes specified printer from the messenger. Returns True if this printer has been found in the list and removed.

◆ RemovePrinters()

int Message_Messenger::RemovePrinters ( const occ::handle< Standard_Type > & theType)

Removes printers of specified type (including derived classes) from the messenger. Returns number of removed printers.

◆ Send() [1/6]

void Message_Messenger::Send ( const char *const theString,
const Message_Gravity theGravity = Message_Warning ) const

Dispatch a message to all the printers in the list. Three versions of string representations are accepted for convenience, by default all are converted to ExtendedString.

◆ Send() [2/6]

void Message_Messenger::Send ( const occ::handle< Standard_Transient > & theObject,
const Message_Gravity theGravity = Message_Warning ) const

See above.

◆ Send() [3/6]

void Message_Messenger::Send ( const Standard_SStream & theStream,
const Message_Gravity theGravity = Message_Warning ) const

See above.

◆ Send() [4/6]

void Message_Messenger::Send ( const TCollection_AsciiString & theString,
const Message_Gravity theGravity = Message_Warning ) const

See above.

◆ Send() [5/6]

void Message_Messenger::Send ( const TCollection_ExtendedString & theString,
const Message_Gravity theGravity = Message_Warning ) const

See above.

◆ Send() [6/6]

StreamBuffer Message_Messenger::Send ( Message_Gravity theGravity)
inline

Create string buffer for message of specified type.

◆ SendAlarm() [1/2]

StreamBuffer Message_Messenger::SendAlarm ( )
inline

Create string buffer for sending Alarm message.

◆ SendAlarm() [2/2]

void Message_Messenger::SendAlarm ( const TCollection_AsciiString & theMessage)
inline

Short-cut to Send (theMessage, Message_Alarm)

◆ SendFail() [1/2]

StreamBuffer Message_Messenger::SendFail ( )
inline

Create string buffer for sending Fail message.

◆ SendFail() [2/2]

void Message_Messenger::SendFail ( const TCollection_AsciiString & theMessage)
inline

Short-cut to Send (theMessage, Message_Fail)

◆ SendInfo() [1/2]

StreamBuffer Message_Messenger::SendInfo ( )
inline

Create string buffer for sending Info message.

◆ SendInfo() [2/2]

void Message_Messenger::SendInfo ( const TCollection_AsciiString & theMessage)
inline

Short-cut to Send (theMessage, Message_Info)

◆ SendTrace() [1/2]

StreamBuffer Message_Messenger::SendTrace ( )
inline

Create string buffer for sending Trace message.

◆ SendTrace() [2/2]

void Message_Messenger::SendTrace ( const TCollection_AsciiString & theMessage)
inline

Short-cut to Send (theMessage, Message_Trace)

◆ SendWarning() [1/2]

StreamBuffer Message_Messenger::SendWarning ( )
inline

Create string buffer for sending Warning message.

◆ SendWarning() [2/2]

void Message_Messenger::SendWarning ( const TCollection_AsciiString & theMessage)
inline

Short-cut to Send (theMessage, Message_Warning)


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