|
||||
File indexing completed on 2025-01-18 10:04:17
0001 // Created on: 2017-06-26 0002 // Created by: Andrey Betenev 0003 // Copyright (c) 2017 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef _Message_Report_HeaderFile 0017 #define _Message_Report_HeaderFile 0018 0019 #include <Message_Level.hxx> 0020 #include <Message_ListOfAlert.hxx> 0021 #include <Message_MetricType.hxx> 0022 #include <NCollection_IndexedMap.hxx> 0023 #include <NCollection_Sequence.hxx> 0024 #include <Standard_Mutex.hxx> 0025 0026 class Message_CompositeAlerts; 0027 class Message_Messenger; 0028 0029 class Message_Report; 0030 0031 DEFINE_STANDARD_HANDLE(Message_Report, Standard_Transient) 0032 0033 //! Container for alert messages, sorted according to their gravity. 0034 //! 0035 //! For each gravity level, alerts are stored in simple list. 0036 //! If alert being added can be merged with another alert of the same 0037 //! type already in the list, it is merged and not added to the list. 0038 //! 0039 //! This class is intended to be used as follows: 0040 //! 0041 //! - In the process of execution, algorithm fills report by alert objects 0042 //! using methods AddAlert() 0043 //! 0044 //! - The result can be queried for presence of particular alert using 0045 //! methods HasAlert() 0046 //! 0047 //! - The reports produced by nested or sequentially executed algorithms 0048 //! can be collected in one using method Merge() 0049 //! 0050 //! - The report can be shown to the user either as plain text with method 0051 //! Dump() or in more advanced way, by iterating over lists returned by GetAlerts() 0052 //! 0053 //! - Report can be cleared by methods Clear() (usually after reporting) 0054 //! 0055 //! Message_PrinterToReport is a printer in Messenger to convert data sent to messenger into report 0056 class Message_Report : public Standard_Transient 0057 { 0058 public: 0059 0060 //! Empty constructor 0061 Standard_EXPORT Message_Report (); 0062 0063 //! Add alert with specified gravity. 0064 //! This method is thread-safe, i.e. alerts can be added from parallel threads safely. 0065 Standard_EXPORT void AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert); 0066 0067 //! Returns list of collected alerts with specified gravity 0068 Standard_EXPORT const Message_ListOfAlert& GetAlerts (Message_Gravity theGravity) const; 0069 0070 //! Returns true if specific type of alert is recorded 0071 Standard_EXPORT Standard_Boolean HasAlert (const Handle(Standard_Type)& theType); 0072 0073 //! Returns true if specific type of alert is recorded with specified gravity 0074 Standard_EXPORT Standard_Boolean HasAlert (const Handle(Standard_Type)& theType, Message_Gravity theGravity); 0075 0076 //! Returns true if a report printer for the current report is registered in the messenger 0077 //! @param theMessenger the messenger. If it's NULL, the default messenger is used 0078 Standard_EXPORT Standard_Boolean IsActiveInMessenger (const Handle(Message_Messenger)& theMessenger = NULL) const; 0079 0080 //! Creates an instance of Message_PrinterToReport with the current report and register it in messenger 0081 //! @param toActivate if true, activated else deactivated 0082 //! @param theMessenger the messenger. If it's NULL, the default messenger is used 0083 Standard_EXPORT void ActivateInMessenger (const Standard_Boolean toActivate, 0084 const Handle(Message_Messenger)& theMessenger = NULL); 0085 0086 //! Updates internal flag IsActiveInMessenger. 0087 //! It becomes true if messenger contains at least one instance of Message_PrinterToReport. 0088 //! @param theMessenger the messenger. If it's NULL, the default messenger is used 0089 Standard_EXPORT void UpdateActiveInMessenger (const Handle(Message_Messenger)& theMessenger = NULL); 0090 0091 //! Add new level of alerts 0092 //! @param theLevel a level 0093 Standard_EXPORT void AddLevel (Message_Level* theLevel, const TCollection_AsciiString& theName); 0094 0095 //! Remove level of alerts 0096 Standard_EXPORT void RemoveLevel (Message_Level* theLevel); 0097 0098 //! Clears all collected alerts 0099 Standard_EXPORT void Clear (); 0100 0101 //! Clears collected alerts with specified gravity 0102 Standard_EXPORT void Clear (Message_Gravity theGravity); 0103 0104 //! Clears collected alerts with specified type 0105 Standard_EXPORT void Clear (const Handle(Standard_Type)& theType); 0106 0107 //! Returns computed metrics when alerts are performed 0108 const NCollection_IndexedMap<Message_MetricType>& ActiveMetrics() const { return myActiveMetrics; } 0109 0110 //! Sets metrics to compute when alerts are performed 0111 //! @param theMetrics container of metrics 0112 Standard_EXPORT void SetActiveMetric (const Message_MetricType theMetricType, const Standard_Boolean theActivate); 0113 0114 //! Removes all activated metrics 0115 void ClearMetrics() { myActiveMetrics.Clear(); } 0116 0117 //! Returns maximum number of collecting alerts. If the limit is achieved, 0118 //! first alert is removed, the new alert is added in the container. 0119 //! @return the limit value 0120 Standard_Integer Limit() const { return myLimit; } 0121 0122 //! Sets maximum number of collecting alerts. 0123 //! @param theLimit limit value 0124 void SetLimit(const Standard_Integer theLimit) { myLimit = theLimit; } 0125 0126 //! Dumps all collected alerts to stream 0127 Standard_EXPORT void Dump (Standard_OStream& theOS); 0128 0129 //! Dumps collected alerts with specified gravity to stream 0130 Standard_EXPORT void Dump (Standard_OStream& theOS, Message_Gravity theGravity); 0131 0132 //! Sends all collected alerts to messenger. 0133 Standard_EXPORT virtual void SendMessages (const Handle(Message_Messenger)& theMessenger); 0134 0135 //! Dumps collected alerts with specified gravity to messenger. 0136 //! Default implementation creates Message_Msg object with a message 0137 //! key returned by alert, and sends it in the messenger. 0138 Standard_EXPORT virtual void SendMessages (const Handle(Message_Messenger)& theMessenger, 0139 Message_Gravity theGravity); 0140 0141 //! Merges data from theOther report into this 0142 Standard_EXPORT void Merge (const Handle(Message_Report)& theOther); 0143 0144 //! Merges alerts with specified gravity from theOther report into this 0145 Standard_EXPORT void Merge (const Handle(Message_Report)& theOther, Message_Gravity theGravity); 0146 0147 //! Dumps the content of me into the stream 0148 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; 0149 0150 // OCCT RTTI 0151 DEFINE_STANDARD_RTTIEXT(Message_Report,Standard_Transient) 0152 0153 protected: 0154 //! Returns class provided hierarchy of alerts if created or create if the parameter is true 0155 //! @param isCreate if composite alert has not been created for this alert, it should be created 0156 //! @return instance or NULL 0157 Standard_EXPORT const Handle(Message_CompositeAlerts)& compositeAlerts (const Standard_Boolean isCreate = Standard_False); 0158 0159 //! Sends alerts to messenger 0160 Standard_EXPORT void sendMessages (const Handle(Message_Messenger)& theMessenger, Message_Gravity theGravity, 0161 const Handle(Message_CompositeAlerts)& theCompositeAlert); 0162 0163 //! Dumps collected alerts with specified gravity to stream 0164 Standard_EXPORT void dumpMessages (Standard_OStream& theOS, Message_Gravity theGravity, 0165 const Handle(Message_CompositeAlerts)& theCompositeAlert); 0166 0167 protected: 0168 Standard_Mutex myMutex; 0169 0170 Handle(Message_CompositeAlerts) myCompositAlerts; //!< container of alerts 0171 0172 NCollection_Sequence<Message_Level*> myAlertLevels; //!< container of active levels, new alerts are added below the latest level 0173 NCollection_IndexedMap<Message_MetricType> myActiveMetrics; //!< metrics to compute on alerts 0174 0175 Standard_Integer myLimit; //!< Maximum number of collected alerts on the top level 0176 Standard_Boolean myIsActiveInMessenger; //! state whether the report is activated in messenger 0177 }; 0178 0179 #endif // _Message_Report_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |