]> OCCT Git - occt-copy.git/commitdiff
0029451: Information Message Alert to debug an algorithm or object functionality
authornds <nds@opencascade.com>
Mon, 5 Oct 2020 11:26:21 +0000 (14:26 +0300)
committernds <nds@opencascade.com>
Mon, 5 Oct 2020 16:44:13 +0000 (19:44 +0300)
18 files changed:
src/Message/Message_Alert.cxx
src/Message/Message_Alert.hxx
src/Message/Message_AlertExtended.cxx
src/Message/Message_AlertExtended.hxx
src/Message/Message_Attribute.cxx
src/Message/Message_Attribute.hxx
src/Message/Message_AttributeMeter.cxx
src/Message/Message_AttributeMeter.hxx
src/Message/Message_AttributeObject.hxx
src/Message/Message_AttributeStream.cxx
src/Message/Message_AttributeStream.hxx
src/Message/Message_CompositeAlerts.cxx
src/Message/Message_CompositeAlerts.hxx
src/Message/Message_Report.cxx
src/Message/Message_Report.hxx
src/TopoDS/TopoDS_AlertAttribute.cxx
src/TopoDS/TopoDS_AlertAttribute.hxx
tools/MessageModel/MessageModel_Actions.cxx

index 5901a49a096237fc29cc2676ea2f6f4828196e0c..c9148aa9730752b9475b772b6fa0df2751444666 100644 (file)
@@ -14,6 +14,7 @@
 // commercial license or contractual agreement.
 
 #include <Message_Alert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_Alert,Standard_Transient)
 
@@ -48,3 +49,12 @@ Standard_Boolean Message_Alert::Merge (const Handle(Message_Alert)& /*theTarget*
   // by default, merge trivially
   return Standard_True;
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_Alert::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+}
index a460787354e88bc6a9121068d88b299deb6fe689..8a624570623254781db429425afbf94e180f6cd5 100644 (file)
@@ -54,6 +54,9 @@ public:
   //! Base implementation always returns true.
   virtual Standard_EXPORT Standard_Boolean Merge (const Handle(Message_Alert)& theTarget);
   
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_Alert,Standard_Transient)
 };
 
index 843c3b6d311ac96ffda58005d1b992b2b968b266..a203777eb7c3c64a7438605ac27289123327b7b1 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <Precision.hxx>
 #include <Standard_Assert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_AlertExtended,Message_Alert)
 
@@ -89,3 +90,22 @@ Handle(Message_Alert) Message_AlertExtended::AddAlert (const Handle(Message_Repo
 
   return anAlert;
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_AlertExtended::DumpJson (Standard_OStream& theOStream,
+                                      Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+  if (!myCompositAlerts.IsNull())
+  {
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCompositAlerts.get())
+  }
+  if (!myAttribute.IsNull())
+  {
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAttribute.get())
+  }
+}
index 8c0420836d7e9f9efc7e362ee16deb317ee88535..0487dd56eaf80757ce083ee699f6ed17521e1a1a 100644 (file)
@@ -78,6 +78,10 @@ public:
                                                          const Handle(Message_Attribute)& theAttribute,
                                                          const Message_Gravity theGravity);
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert)
 
 protected:
index 6efcd0f7ba1801342130026e0f8bad334cad10fa..3f0fb284e723e0a7caab27645f2019afb7c48cf7 100644 (file)
@@ -14,6 +14,7 @@
 #include <Message_Attribute.hxx>
 
 #include <Standard_Assert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
 
@@ -26,3 +27,13 @@ Standard_CString Message_Attribute::GetMessageKey () const
 {
   return !myName.IsEmpty() ? myName.ToCString() : "";
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_Attribute::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName)
+}
index cce24fd803ef2ca706de2776e6089d75810cf87c..773bbf2937f83a256f43789f28089410c97cc084 100644 (file)
@@ -43,6 +43,9 @@ public:
   //! @param theName a name for the alert
   void SetName (const TCollection_AsciiString& theName) { myName = theName; }
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
 
 private:
index f9571b9befed083cf62d66511316d32740efe1ac..27c386f8bdd791bf97abac5e90cf20b9e36e8d5b 100644 (file)
@@ -18,6 +18,7 @@
 #include <OSD_Chronometer.hxx>
 
 #include <Precision.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
 
@@ -173,3 +174,27 @@ void Message_AttributeMeter::SetAlertMetrics (const Handle(Message_AlertExtended
       aMeterAttribute->SetStopValue (aMetricType, (Standard_Real)aMemInfo.ValuePreciseMiB (anIterator.Value()));
   }
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_AttributeMeter::DumpJson (Standard_OStream& theOStream,
+                                       Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+
+  for (NCollection_DataMap<Message_MetricType, StartToStopValue>::Iterator anIterator (myMetrics);
+       anIterator.More(); anIterator.Next())
+  {
+    Message_MetricType aMetricType = anIterator.Key();
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aMetricType)
+
+    Standard_Real aStartValue = anIterator.Value().first;
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aStartValue)
+
+    Standard_Real aStopValue = anIterator.Value().second;
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aStopValue)
+  }
+}
index 72be3f6097eac8744566134b8b8162eb2d0c82ad..d322385d2e4d174b6d34c07a4816b94c44c1f967 100644 (file)
@@ -80,6 +80,10 @@ public:
   static Standard_EXPORT void SetAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
                                                const Standard_Boolean theStartValue);
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   DEFINE_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
 
 private:
index 3775685da1e3f0c1c902239bcf15f5f069dff618..c9f5d7c2f06a7a5ef95539bc3bdf4bbecb5e11a0 100644 (file)
@@ -15,6 +15,7 @@
 #define _Message_AttributeObject_HeaderFile
 
 #include <Message_Attribute.hxx>
+#include <Standard_Dump.hxx>
 
 class Standard_Transient;
 
@@ -35,6 +36,15 @@ public:
   //! @param theObject an instance
   void SetObject (const Handle(Standard_Transient)& theObject) { myObject = theObject; }
 
+  //! Dumps the content of me into the stream
+  virtual void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE
+  {
+    OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+    OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+    OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myObject.get())
+  }
+
   DEFINE_STANDARD_RTTI_INLINE(Message_AttributeObject, Message_Attribute)
 
 private:
index f0cf9314159b28f54a64dcdbd75715a63e189749..0236296b9c3ba49709dcb4a7a30c0767b1690b43 100644 (file)
@@ -12,6 +12,7 @@
 // commercial license or contractual agreement.
 
 #include <Message_AttributeStream.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
 
@@ -39,3 +40,16 @@ void Message_AttributeStream::SetStream (const Standard_SStream& theStream)
   myStream << aStreamStr;
 }
 
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_AttributeStream::DumpJson (Standard_OStream& theOStream,
+                                        Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+
+  TCollection_AsciiString aStream = Standard_Dump::Text (myStream);
+  OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aStream)
+}
index c4a73527fa1c9b1ca7bee289b7066ed05d159bf1..2f992dd486baceef180b13b0c24ad14df45224ca 100644 (file)
@@ -34,6 +34,10 @@ public:
   //! Sets stream value
   Standard_EXPORT void SetStream (const Standard_SStream& theStream);
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   DEFINE_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
 
 private:
index 48d0e14be950c9d71c7f9282bb2ba42fb420613a..9c25f226cf5ca537d4a8594c61f74ed19c7f434b 100644 (file)
@@ -14,6 +14,7 @@
 #include <Message_CompositeAlerts.hxx>
 #include <Message_AlertExtended.hxx>
 #include <Standard_Assert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_CompositeAlerts, Standard_Transient)
 
@@ -153,3 +154,25 @@ void Message_CompositeAlerts::Clear (const Handle(Standard_Type)& theType)
     }
   }
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_CompositeAlerts::DumpJson (Standard_OStream& theOStream,
+                                        Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+  for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
+  {
+    Message_Gravity aGravity = (Message_Gravity)i;
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aGravity)
+
+    for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); anIt.Next())
+    {
+      const Handle(Message_Alert)& anAlert = anIt.Value();
+      OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anAlert.get())
+    }
+  }
+}
index 0864e05b6fc90d2cca9e529c91caf8fef668cfb8..937eda0137e462c433ca2358c6aa4453ae79541e 100644 (file)
@@ -66,6 +66,9 @@ public:
   //! @param theType an alert type
   Standard_EXPORT void Clear (const Handle(Standard_Type)& theType);
 
+  //! Dumps the content of me into the stream
+  Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_CompositeAlerts,Standard_Transient)
 
 protected:
index a6e15044fe28e2535646fba43b78bd9258b1e62b..19d9b7f1112484483e76937f783ccc182b798ad5 100644 (file)
@@ -122,7 +122,7 @@ Standard_Boolean Message_Report::HasAlert (const Handle(Standard_Type)& theType,
 //purpose  :
 //=======================================================================
 
-Standard_Boolean Message_Report::IsActiveInMessenger (const Handle(Message_Messenger)& theMessenger) const
+Standard_Boolean Message_Report::IsActiveInMessenger (const Handle(Message_Messenger)&) const
 {
   return myIsActiveInMessenger;
 }
@@ -176,6 +176,7 @@ void Message_Report::UpdateActiveInMessenger (const Handle(Message_Messenger)& t
         Handle(Message_PrinterToReport)::DownCast (anIterator.Value())->Report() == this)
     {
       myIsActiveInMessenger = Standard_True;
+      return;
     }
   }
   myIsActiveInMessenger = Standard_False;
@@ -460,3 +461,29 @@ void Message_Report::writeReport()
 
   myReportWriter->ExportReport (this);
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_Report::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+  if (!myCompositAlerts.IsNull())
+  {
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCompositAlerts.get())
+  }
+
+  Standard_Integer anAlertLevels = myAlertLevels.Size();
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, anAlertLevels)
+
+  for (NCollection_Map<Message_MetricType>::Iterator anIterator (myActiveMetrics); anIterator.More(); anIterator.Next())
+  {
+    Message_MetricType anActiveMetric = anIterator.Value();
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, anActiveMetric)
+  }
+
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLimit)
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsActiveInMessenger)
+}
index b96f5c5e62e17a952a040ca8ccce50658482ff00..03ef68ffe3f293d4144c0d4a334ed7270016cb5d 100644 (file)
@@ -158,6 +158,9 @@ public:
   //! Merges alerts with specified gravity from theOther report into this
   Standard_EXPORT void Merge (const Handle(Message_Report)& theOther, Message_Gravity theGravity);
 
+  //! Dumps the content of me into the stream
+  Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
 
 protected:
index c4fc6127dd0c674dd5aef8fa70f69dd6d049e1e5..3f111589648f53b24ee3cc544532cf21991486ca 100644 (file)
@@ -53,3 +53,16 @@ void TopoDS_AlertAttribute::Send (const Handle(Message_Messenger)& theMessenger,
     //                                 Message_Info);
   }
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void TopoDS_AlertAttribute::DumpJson (Standard_OStream& theOStream,
+                                      Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+
+  OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myShape)
+}
index b7e5e95e1cca5c2627e80dc5e8154ac7f92ab05b..deaa193dc4bf448675ca82d0289d2c6fb6b70362 100644 (file)
@@ -40,6 +40,10 @@ public:
   Standard_EXPORT static void Send (const Handle(Message_Messenger)& theMessenger,
                                     const TopoDS_Shape& theShape);
 
+  //! Dumps the content of me into the stream
+  Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                 Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   // OCCT RTTI
   DEFINE_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_AttributeStream)
 
index 6308c66460b44770f301abb2ce3830f1a0b064da..8ca4217c74cb80f8607ed1cd8309824ce1caddba 100644 (file)
@@ -170,6 +170,7 @@ void MessageModel_Actions::OnActivateReport()
 
   Message::DefaultMessenger()->AddPrinter (MyPrinterToReport);
   Message::DefaultMessenger()->SetTraceLevel (1);
+  Message::DefaultReport()->UpdateActiveInMessenger();
 
   myTreeModel->UpdateTreeModel();
 }