From a09c44692f6358311fd4a3e9b656cbc1e5addb4d Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 5 Oct 2020 14:26:21 +0300 Subject: [PATCH] 0029451: Information Message Alert to debug an algorithm or object functionality --- src/Message/Message_Alert.cxx | 10 +++++++ src/Message/Message_Alert.hxx | 3 +++ src/Message/Message_AlertExtended.cxx | 20 ++++++++++++++ src/Message/Message_AlertExtended.hxx | 4 +++ src/Message/Message_Attribute.cxx | 11 ++++++++ src/Message/Message_Attribute.hxx | 3 +++ src/Message/Message_AttributeMeter.cxx | 25 ++++++++++++++++++ src/Message/Message_AttributeMeter.hxx | 4 +++ src/Message/Message_AttributeObject.hxx | 10 +++++++ src/Message/Message_AttributeStream.cxx | 14 ++++++++++ src/Message/Message_AttributeStream.hxx | 4 +++ src/Message/Message_CompositeAlerts.cxx | 23 ++++++++++++++++ src/Message/Message_CompositeAlerts.hxx | 3 +++ src/Message/Message_Report.cxx | 29 ++++++++++++++++++++- src/Message/Message_Report.hxx | 3 +++ src/TopoDS/TopoDS_AlertAttribute.cxx | 13 +++++++++ src/TopoDS/TopoDS_AlertAttribute.hxx | 4 +++ tools/MessageModel/MessageModel_Actions.cxx | 1 + 18 files changed, 183 insertions(+), 1 deletion(-) diff --git a/src/Message/Message_Alert.cxx b/src/Message/Message_Alert.cxx index 5901a49a09..c9148aa973 100644 --- a/src/Message/Message_Alert.cxx +++ b/src/Message/Message_Alert.cxx @@ -14,6 +14,7 @@ // commercial license or contractual agreement. #include +#include 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) +} diff --git a/src/Message/Message_Alert.hxx b/src/Message/Message_Alert.hxx index a460787354..8a62457062 100644 --- a/src/Message/Message_Alert.hxx +++ b/src/Message/Message_Alert.hxx @@ -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) }; diff --git a/src/Message/Message_AlertExtended.cxx b/src/Message/Message_AlertExtended.cxx index 843c3b6d31..a203777eb7 100644 --- a/src/Message/Message_AlertExtended.cxx +++ b/src/Message/Message_AlertExtended.cxx @@ -18,6 +18,7 @@ #include #include +#include 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()) + } +} diff --git a/src/Message/Message_AlertExtended.hxx b/src/Message/Message_AlertExtended.hxx index 8c0420836d..0487dd56ea 100644 --- a/src/Message/Message_AlertExtended.hxx +++ b/src/Message/Message_AlertExtended.hxx @@ -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: diff --git a/src/Message/Message_Attribute.cxx b/src/Message/Message_Attribute.cxx index 6efcd0f7ba..3f0fb284e7 100644 --- a/src/Message/Message_Attribute.cxx +++ b/src/Message/Message_Attribute.cxx @@ -14,6 +14,7 @@ #include #include +#include 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) +} diff --git a/src/Message/Message_Attribute.hxx b/src/Message/Message_Attribute.hxx index cce24fd803..773bbf2937 100644 --- a/src/Message/Message_Attribute.hxx +++ b/src/Message/Message_Attribute.hxx @@ -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: diff --git a/src/Message/Message_AttributeMeter.cxx b/src/Message/Message_AttributeMeter.cxx index f9571b9bef..27c386f8bd 100644 --- a/src/Message/Message_AttributeMeter.cxx +++ b/src/Message/Message_AttributeMeter.cxx @@ -18,6 +18,7 @@ #include #include +#include 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::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) + } +} diff --git a/src/Message/Message_AttributeMeter.hxx b/src/Message/Message_AttributeMeter.hxx index 72be3f6097..d322385d2e 100644 --- a/src/Message/Message_AttributeMeter.hxx +++ b/src/Message/Message_AttributeMeter.hxx @@ -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: diff --git a/src/Message/Message_AttributeObject.hxx b/src/Message/Message_AttributeObject.hxx index 3775685da1..c9f5d7c2f0 100644 --- a/src/Message/Message_AttributeObject.hxx +++ b/src/Message/Message_AttributeObject.hxx @@ -15,6 +15,7 @@ #define _Message_AttributeObject_HeaderFile #include +#include 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: diff --git a/src/Message/Message_AttributeStream.cxx b/src/Message/Message_AttributeStream.cxx index f0cf931415..0236296b9c 100644 --- a/src/Message/Message_AttributeStream.cxx +++ b/src/Message/Message_AttributeStream.cxx @@ -12,6 +12,7 @@ // commercial license or contractual agreement. #include +#include 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) +} diff --git a/src/Message/Message_AttributeStream.hxx b/src/Message/Message_AttributeStream.hxx index c4a73527fa..2f992dd486 100644 --- a/src/Message/Message_AttributeStream.hxx +++ b/src/Message/Message_AttributeStream.hxx @@ -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: diff --git a/src/Message/Message_CompositeAlerts.cxx b/src/Message/Message_CompositeAlerts.cxx index 48d0e14be9..9c25f226cf 100644 --- a/src/Message/Message_CompositeAlerts.cxx +++ b/src/Message/Message_CompositeAlerts.cxx @@ -14,6 +14,7 @@ #include #include #include +#include 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()) + } + } +} diff --git a/src/Message/Message_CompositeAlerts.hxx b/src/Message/Message_CompositeAlerts.hxx index 0864e05b6f..937eda0137 100644 --- a/src/Message/Message_CompositeAlerts.hxx +++ b/src/Message/Message_CompositeAlerts.hxx @@ -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: diff --git a/src/Message/Message_Report.cxx b/src/Message/Message_Report.cxx index a6e15044fe..19d9b7f111 100644 --- a/src/Message/Message_Report.cxx +++ b/src/Message/Message_Report.cxx @@ -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::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) +} diff --git a/src/Message/Message_Report.hxx b/src/Message/Message_Report.hxx index b96f5c5e62..03ef68ffe3 100644 --- a/src/Message/Message_Report.hxx +++ b/src/Message/Message_Report.hxx @@ -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: diff --git a/src/TopoDS/TopoDS_AlertAttribute.cxx b/src/TopoDS/TopoDS_AlertAttribute.cxx index c4fc6127dd..3f11158964 100644 --- a/src/TopoDS/TopoDS_AlertAttribute.cxx +++ b/src/TopoDS/TopoDS_AlertAttribute.cxx @@ -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) +} diff --git a/src/TopoDS/TopoDS_AlertAttribute.hxx b/src/TopoDS/TopoDS_AlertAttribute.hxx index b7e5e95e1c..deaa193dc4 100644 --- a/src/TopoDS/TopoDS_AlertAttribute.hxx +++ b/src/TopoDS/TopoDS_AlertAttribute.hxx @@ -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) diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx index 6308c66460..8ca4217c74 100644 --- a/tools/MessageModel/MessageModel_Actions.cxx +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -170,6 +170,7 @@ void MessageModel_Actions::OnActivateReport() Message::DefaultMessenger()->AddPrinter (MyPrinterToReport); Message::DefaultMessenger()->SetTraceLevel (1); + Message::DefaultReport()->UpdateActiveInMessenger(); myTreeModel->UpdateTreeModel(); } -- 2.39.5