Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-03 08:33:25

0001 // Copyright (c) 2020 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Message_AlertExtended_HeaderFile
0015 #define _Message_AlertExtended_HeaderFile
0016 
0017 #include <Message_Alert.hxx>
0018 #include <Message_Gravity.hxx>
0019 #include <TCollection_AsciiString.hxx>
0020 
0021 class Message_Attribute;
0022 class Message_Report;
0023 
0024 class Message_CompositeAlerts;
0025 
0026 //! Inherited class of Message_Alert with some additional information.
0027 //! It has Message_Attributes to provide the alert name, and other custom information
0028 //! It has a container of composite alerts, if the alert might provide
0029 //! sub-alerts collecting.
0030 class Message_AlertExtended : public Message_Alert
0031 {
0032 public:
0033   //! Creates new instance of the alert and put it into report with Message_Info gravity.
0034   //! It does nothing if such kind of gravity is not active in the report
0035   //! @param theReport the message report where new alert is placed
0036   //! @param theAttribute container of additional values of the alert
0037   //! @return created alert or NULL if Message_Info is not active in report
0038   Standard_EXPORT static Handle(Message_Alert) AddAlert(
0039     const Handle(Message_Report)&    theReport,
0040     const Handle(Message_Attribute)& theAttribute,
0041     const Message_Gravity            theGravity);
0042 
0043 public:
0044   //! Empty constructor
0045   Message_AlertExtended()
0046       : Message_Alert()
0047   {
0048   }
0049 
0050   //! Return a C string to be used as a key for generating text user messages describing this alert.
0051   //! The messages are generated with help of Message_Msg class, in Message_Report::Dump().
0052   //! Base implementation returns dynamic type name of the instance.
0053   Standard_EXPORT virtual Standard_CString GetMessageKey() const Standard_OVERRIDE;
0054 
0055   //! Returns container of the alert attributes
0056   const Handle(Message_Attribute)& Attribute() const { return myAttribute; }
0057 
0058   //! Sets container of the alert attributes
0059   //! @param theAttributes an attribute values
0060   void SetAttribute(const Handle(Message_Attribute)& theAttribute) { myAttribute = theAttribute; }
0061 
0062   //! Returns class provided hierarchy of alerts if created or create if the parameter is true
0063   //! @param theToCreate if composite alert has not been created for this alert, it should be
0064   //! created
0065   //! @return instance or NULL
0066   Standard_EXPORT Handle(Message_CompositeAlerts) CompositeAlerts(
0067     const Standard_Boolean theToCreate = Standard_False);
0068 
0069   //! Return true if this type of alert can be merged with other
0070   //! of the same type to avoid duplication.
0071   //! Hierarchical alerts can not be merged
0072   //! Basis implementation returns true.
0073   Standard_EXPORT virtual Standard_Boolean SupportsMerge() const Standard_OVERRIDE;
0074 
0075   //! If possible, merge data contained in this alert to theTarget.
0076   //! Base implementation always returns false.
0077   //! @return True if merged
0078   Standard_EXPORT virtual Standard_Boolean Merge(const Handle(Message_Alert)& theTarget)
0079     Standard_OVERRIDE;
0080 
0081   //! Dumps the content of me into the stream
0082   virtual Standard_EXPORT void DumpJson(Standard_OStream& theOStream,
0083                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0084 
0085   DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert)
0086 
0087 protected:
0088   // clang-format off
0089   Handle(Message_CompositeAlerts) myCompositAlerts; //!< class provided hierarchical structure of alerts
0090   // clang-format on
0091   Handle(Message_Attribute) myAttribute; //!< container of the alert attributes
0092 };
0093 
0094 DEFINE_STANDARD_HANDLE(Message_AlertExtended, Message_Alert)
0095 
0096 #endif // _Message_Alert_HeaderFile