Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:16

0001 // Copyright (c) 2020 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Message_PrinterToReport_HeaderFile
0015 #define _Message_PrinterToReport_HeaderFile
0016 
0017 #include <Message_Printer.hxx>
0018 #include <TCollection_AsciiString.hxx>
0019 
0020 class Message_Report;
0021 
0022 //! Implementation of a message printer associated with Message_Report
0023 //! Send will create a new alert of the report. If string is sent, an alert is created by Eol only.
0024 //! The alerts are sent into set report or default report of Message.
0025 class Message_PrinterToReport : public Message_Printer
0026 {
0027   DEFINE_STANDARD_RTTIEXT(Message_PrinterToReport, Message_Printer)
0028 public:
0029   //! Create printer for redirecting messages into report.
0030   Message_PrinterToReport() {}
0031 
0032   //! Destructor
0033   virtual ~Message_PrinterToReport() {}
0034 
0035   //! Returns the current or default report
0036   Standard_EXPORT const Handle(Message_Report)& Report() const;
0037 
0038   //! Sets the printer report
0039   //! @param theReport report for messages processing, if NULL, the default report is used
0040   void SetReport (const Handle(Message_Report)& theReport) { myReport = theReport; }
0041 
0042   //! Send a string message with specified trace level.
0043   //! Stream is converted to string value.
0044   //! Default implementation calls first method Send().
0045   Standard_EXPORT virtual void SendStringStream (const Standard_SStream& theStream,
0046                                                  const Message_Gravity theGravity) const Standard_OVERRIDE;
0047 
0048   //! Send a string message with specified trace level.
0049   //! The object is converted to string in format: <object kind> : <object pointer>.
0050   //! The parameter theToPutEol specified whether end-of-line should be added to the end of the message.
0051   //! Default implementation calls first method Send().
0052   Standard_EXPORT virtual void SendObject (const Handle(Standard_Transient)& theObject,
0053                                            const Message_Gravity theGravity) const Standard_OVERRIDE;
0054 
0055 protected:
0056 
0057   //! Send a string message with specified trace level.
0058   //! This method must be redefined in descendant.
0059   Standard_EXPORT virtual void send (const TCollection_AsciiString& theString,
0060                                      const Message_Gravity theGravity) const Standard_OVERRIDE;
0061 
0062   //! Send an alert with metrics active in the current report
0063   Standard_EXPORT void sendMetricAlert (const TCollection_AsciiString& theValue,
0064                                         const Message_Gravity theGravity) const;
0065 
0066 private:
0067   mutable TCollection_AsciiString myName;
0068   Handle(Message_Report) myReport; //!< the report for sending alerts
0069 };
0070 
0071 DEFINE_STANDARD_HANDLE(Message_PrinterToReport, Message_Printer)
0072 
0073 #endif // _Message_PrinterToReport_HeaderFile