// 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 occ::handle AddAlert( const occ::handle& theReport, const occ::handle& 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 const char* GetMessageKey() const override; //! Returns container of the alert attributes const occ::handle& Attribute() const { return myAttribute; } //! Sets container of the alert attributes //! @param theAttributes an attribute values void SetAttribute(const occ::handle& 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 occ::handle CompositeAlerts( const bool theToCreate = 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 bool SupportsMerge() const override; //! If possible, merge data contained in this alert to theTarget. //! Base implementation always returns false. //! @return True if merged Standard_EXPORT bool Merge(const occ::handle& theTarget) override; //! Dumps the content of me into the stream Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override; DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert) protected: // clang-format off occ::handle myCompositAlerts; //!< class provided hierarchical structure of alerts // clang-format on occ::handle myAttribute; //!< container of the alert attributes }; #endif // _Message_Alert_HeaderFile