0029451: Information Message Alert to debug an algorithm or object functionality
[occt.git] / src / TopoDS / TopoDS_AlertAttribute.cxx
1 // Created on: 2018-06-10
2 // Created by: Natalia Ermolaeva
3 // Copyright (c) 2018-2020 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <TopoDS_AlertAttribute.hxx>
17
18 #include <Message_PrinterToReport.hxx>
19
20 IMPLEMENT_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_Attribute)
21
22 //=======================================================================
23 //function : TopoDS_AlertAttribute
24 //purpose  :
25 //=======================================================================
26 TopoDS_AlertAttribute::TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
27                                               const TCollection_AsciiString& theName)
28 : Message_AttributeStream (Standard_SStream(), theName), myShape (theShape)
29 {
30   Standard_SStream aStream;
31   theShape.DumpJson (aStream);
32
33   SetStream (aStream);
34 }
35
36 //=======================================================================
37 //function : Send
38 //purpose  :
39 //=======================================================================
40 void TopoDS_AlertAttribute::Send (const Handle(Message_Messenger)& theMessenger,
41                                   const TopoDS_Shape& theShape)
42 {
43   for (Message_SequenceOfPrinters::Iterator aPrinterIter (theMessenger->Printers()); aPrinterIter.More(); aPrinterIter.Next())
44   {
45     const Handle(Message_Printer)& aPrinter = aPrinterIter.Value();
46     if (!aPrinter->IsKind (STANDARD_TYPE (Message_PrinterToReport)))
47     {
48       continue;
49     }
50
51     Handle (Message_PrinterToReport) aPrinterToReport = Handle(Message_PrinterToReport)::DownCast (aPrinter);
52     const Handle(Message_Report)& aReport = aPrinterToReport->Report();
53
54     Message_AlertExtended::AddAlert (aReport, new TopoDS_AlertAttribute (theShape), Message_Info);
55   }
56 }
57
58 //=======================================================================
59 //function : DumpJson
60 //purpose  :
61 //=======================================================================
62 void TopoDS_AlertAttribute::DumpJson (Standard_OStream& theOStream,
63                                       Standard_Integer theDepth) const
64 {
65   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
66   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
67
68   OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myShape)
69 }