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 #include <Message_PrinterToReport.hxx>
16 #include <Message.hxx>
17 #include <Message_AlertExtended.hxx>
18 #include <Message_Attribute.hxx>
19 #include <Message_AttributeMeter.hxx>
20 #include <Message_AttributeObject.hxx>
21 #include <Message_AttributeStream.hxx>
22 #include <Message_Report.hxx>
24 #include <Standard_Dump.hxx>
25 #include <TCollection_ExtendedString.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(Message_PrinterToReport, Message_Printer)
29 //=======================================================================
32 //=======================================================================
33 const Handle(Message_Report)& Message_PrinterToReport::Report() const
35 if (!myReport.IsNull())
40 return Message::DefaultReport (Standard_True);
43 //=======================================================================
44 //function : SendStringStream
46 //=======================================================================
47 void Message_PrinterToReport::SendStringStream (const Standard_SStream& theStream,
48 const Message_Gravity theGravity) const
50 const Handle(Message_Report)& aReport = Report();
51 if (!aReport->ActiveMetrics().IsEmpty())
53 sendMetricAlert (theStream.str().c_str(), theGravity);
56 if (Standard_Dump::HasChildKey(Standard_Dump::Text (theStream)))
58 Message_AlertExtended::AddAlert (aReport, new Message_AttributeStream (theStream, myName), theGravity);
63 if (!myName.IsEmpty())
65 TCollection_AsciiString aName = myName;
67 send (aName, theGravity);
69 myName = Standard_Dump::Text (theStream);
73 //=======================================================================
74 //function : SendObject
76 //=======================================================================
77 void Message_PrinterToReport::SendObject (const Handle(Standard_Transient)& theObject,
78 const Message_Gravity theGravity) const
80 const Handle(Message_Report)& aReport = Report();
81 if (!aReport->ActiveMetrics().IsEmpty())
83 sendMetricAlert (myName, theGravity);
87 Message_AlertExtended::AddAlert (aReport, new Message_AttributeObject (theObject, myName), theGravity);
90 //=======================================================================
93 //=======================================================================
94 void Message_PrinterToReport::send (const TCollection_AsciiString& theString,
95 const Message_Gravity theGravity) const
97 if (!myName.IsEmpty())
99 TCollection_AsciiString aName = myName;
101 send (aName, theGravity);
104 const Handle(Message_Report)& aReport = Report();
105 if (!aReport->ActiveMetrics().IsEmpty())
107 sendMetricAlert (theString, theGravity);
110 Message_AlertExtended::AddAlert (aReport, new Message_Attribute (theString), theGravity);
113 //=======================================================================
114 //function : sendMetricAlert
116 //=======================================================================
117 void Message_PrinterToReport::sendMetricAlert (const TCollection_AsciiString theValue,
118 const Message_Gravity theGravity) const
120 Message_AlertExtended::AddAlert (Report(), new Message_AttributeMeter (theValue), theGravity);