Files
OCCT/src/Message/Message_AlertExtended.hxx
nds 6522304c17 0029451: Information Message Alert to debug an algorithm or object functionality
- Added possibility to send stream information and transient object into Message_Messenger. Message_Printer will process it if needed.
- Add Message_PrinterToReport to send messenger information into Message_Report.
- Extended Message_Report to collect hierarchical alerts, to be able to collect some metrics during alerts processing.
- Added Message_AlertExtended to prepare hierarchical alerts with custom attributes. One attribute for one alert.
- Added Message_CompositeAlerts class to handle a container of alerts.
- Added Message_Level to start a new hierarchical level by creating an instance, stop by destricting.
- Added Message_Attribute and inheritors to store custom information about alert like object, stream, shape, some metrics.
- Implement Message_AttributeAlert to collect start/stop information about active metrics of Message_Report. This kind of attribute is created if at least one metric is active in the report.
- Add Message_MetricType enumeration with possible kinds of metrics in report.
- Implement DumpJson for Message_Report to store all collected alerts into stream.
- Added draw commands for Message_Report, Message_Messenger.
2020-10-02 20:45:29 +03:00

89 lines
4.0 KiB
C++

// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Message_AlertExtended_HeaderFile
#define _Message_AlertExtended_HeaderFile
#include <Message_Alert.hxx>
#include <Message_Gravity.hxx>
#include <TCollection_AsciiString.hxx>
class Message_Attribute;
class Message_Report;
class Message_CompositeAlerts;
//! Inherited class of Message_Alert with some additional information.
//! It has Message_Attributes to provide the alert name, and other custom information
//! It has a container of composite alerts, if the alert might provide
//! sub-alerts collecting.
class Message_AlertExtended : public Message_Alert
{
public:
//! Creates new instance of the alert and put it into report with Message_Info gravity.
//! It does nothing if such kind of gravity is not active in the report
//! @param theReport the message report where new alert is placed
//! @param theAttribute container of additional values of the alert
//! @return created alert or NULL if Message_Info is not active in report
Standard_EXPORT static Handle(Message_Alert) AddAlert (const Handle(Message_Report)& theReport,
const Handle(Message_Attribute)& theAttribute,
const Message_Gravity theGravity);
public:
//! Empty constructor
Message_AlertExtended() : Message_Alert() {}
//! Return a C string to be used as a key for generating text user messages describing this alert.
//! The messages are generated with help of Message_Msg class, in Message_Report::Dump().
//! Base implementation returns dynamic type name of the instance.
Standard_EXPORT virtual Standard_CString GetMessageKey() const Standard_OVERRIDE;
//! Returns container of the alert attributes
const Handle(Message_Attribute)& Attribute() const { return myAttribute; }
//! Sets container of the alert attributes
//! @param theAttributes an attribute values
void SetAttribute (const Handle(Message_Attribute)& theAttribute) { myAttribute = theAttribute; }
//! Returns class provided hierarchy of alerts if created or create if the parameter is true
//! @param theToCreate if composite alert has not been created for this alert, it should be created
//! @return instance or NULL
Standard_EXPORT Handle(Message_CompositeAlerts) CompositeAlerts (const Standard_Boolean theToCreate = Standard_False);
//! Return true if this type of alert can be merged with other
//! of the same type to avoid duplication.
//! Hierarchical alerts can not be merged
//! Basis implementation returns true.
Standard_EXPORT virtual Standard_Boolean SupportsMerge() const Standard_OVERRIDE;
//! If possible, merge data contained in this alert to theTarget.
//! Base implementation always returns false.
//! @return True if merged
Standard_EXPORT virtual Standard_Boolean Merge (const Handle(Message_Alert)& theTarget) Standard_OVERRIDE;
//! 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:
Handle(Message_CompositeAlerts) myCompositAlerts; //!< class provided hierarchical structure of alerts
Handle(Message_Attribute) myAttribute; //!< container of the alert attributes
};
DEFINE_STANDARD_HANDLE(Message_AlertExtended, Message_Alert)
#endif // _Message_Alert_HeaderFile