1 // Copyright (c) 2020 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Message_PrinterToReport_HeaderFile
15 #define _Message_PrinterToReport_HeaderFile
17 #include <Message_Printer.hxx>
18 #include <Standard_Address.hxx>
19 #include <Standard_OStream.hxx>
20 #include <TCollection_AsciiString.hxx>
24 //! Implementation of a message printer associated with Message_Report
25 //! Send will create a new alert of the report. If string is sent, an alert is created by Eol only.
26 //! The alerts are sent into set report or default report of Message.
27 class Message_PrinterToReport : public Message_Printer
29 DEFINE_STANDARD_RTTIEXT(Message_PrinterToReport, Message_Printer)
31 //! Create printer for redirecting messages into report.
32 Message_PrinterToReport() {}
35 virtual ~Message_PrinterToReport() {}
37 //! Returns the current or default report
38 Standard_EXPORT const Handle(Message_Report)& Report() const;
40 //! Sets the printer report
41 //! @param theReport report for messages processing, if NULL, the default report is used
42 void SetReport (const Handle(Message_Report)& theReport) { myReport = theReport; }
44 //! Send a string message with specified trace level.
45 //! Stream is converted to string value.
46 //! Default implementation calls first method Send().
47 Standard_EXPORT virtual void SendStringStream (const Standard_SStream& theStream,
48 const Message_Gravity theGravity) const Standard_OVERRIDE;
50 //! Send a string message with specified trace level.
51 //! The object is converted to string in format: <object kind> : <object pointer>.
52 //! The parameter theToPutEol specified whether end-of-line should be added to the end of the message.
53 //! Default implementation calls first method Send().
54 Standard_EXPORT virtual void SendObject (const Handle(Standard_Transient)& theObject,
55 const Message_Gravity theGravity) const Standard_OVERRIDE;
59 //! Send a string message with specified trace level.
60 //! This method must be redefined in descendant.
61 Standard_EXPORT virtual void send (const TCollection_AsciiString& theString,
62 const Message_Gravity theGravity) const Standard_OVERRIDE;
64 //! Send an alert with metrics active in the current report
65 Standard_EXPORT void sendMetricAlert (const TCollection_AsciiString theValue,
66 const Message_Gravity theGravity) const;
69 mutable TCollection_AsciiString myName;
70 Handle(Message_Report) myReport; //!< the report for sending alerts
73 DEFINE_STANDARD_HANDLE(Message_PrinterToReport, Message_Printer)
75 #endif // _Message_PrinterToReport_HeaderFile