Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:16

0001 // Copyright (c) 2019 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_Level_HeaderFile
0015 #define _Message_Level_HeaderFile
0016 
0017 #include <Message.hxx>
0018 #include <Message_AlertExtended.hxx>
0019 #include <Message_Gravity.hxx>
0020 #include <Message_Messenger.hxx>
0021 
0022 #include <Standard.hxx>
0023 
0024 //! This class is an instance of Sentry to create a level in a message report
0025 //! Constructor of the class add new (active) level in the report, destructor removes it
0026 //! While the level is active in the report, new alerts are added below the level root alert.
0027 //!
0028 //! The first added alert is a root alert, other are added below the root alert
0029 //!
0030 //! If alert has Message_AttributeMeter attribute, active metrics of the default report are stored in
0031 //! the attribute: start value of metric on adding alert, stop on adding another alert or closing (delete) the level
0032 //! in the report.
0033 //!
0034 //! Processing of this class is implemented in Message_Report, it is used only inside it.
0035 //! Levels using should be only through using OCCT_ADD_MESSAGE_LEVEL_SENTRY only. No other code is required outside.
0036 class Message_Level
0037 {
0038 public:
0039   //! Constructor.
0040   //! One string key is used for all alert meters.
0041   //! The perf meter is not started automatically, it will be done in AddAlert() method
0042   Standard_EXPORT Message_Level (const TCollection_AsciiString& theName = TCollection_AsciiString());
0043 
0044   //! Assures stopping upon destruction
0045   Standard_EXPORT ~Message_Level();
0046 
0047   //! Returns root alert of the level
0048   //! @return alert instance or NULL
0049   const Handle(Message_AlertExtended)& RootAlert() const { return myRootAlert; }
0050 
0051   //! Sets the root alert. Starts collects alert metrics if active.
0052   //! @param theAlert an alert  
0053   Standard_EXPORT void SetRootAlert (const Handle(Message_AlertExtended)& theAlert,
0054                                      const Standard_Boolean isRequiredToStart);
0055 
0056   //! Adds new alert on the level. Stops the last alert metric, appends the alert and starts the alert metrics collecting.
0057   //! Sets root alert beforehand this method using, if the root is NULL, it does nothing.
0058   //! @param theGravity an alert gravity
0059   //! @param theAlert an alert  
0060   //! @return true if alert is added
0061   Standard_EXPORT Standard_Boolean AddAlert (const Message_Gravity theGravity,
0062                                              const Handle(Message_Alert)& theAlert);
0063 
0064 private:
0065   //! Remove the current level from the report. It stops metric collecting for the last and the root alerts.
0066   Standard_EXPORT void remove();
0067 
0068 private:
0069   Handle(Message_AlertExtended) myRootAlert; //!< root alert
0070   Handle(Message_AlertExtended) myLastAlert; //!< last added alert on the root alert
0071 };
0072 
0073 //! @def MESSAGE_NEW_LEVEL
0074 //! Creates a new level instance of Sentry. This row should be inserted before messages using in the method.
0075 #define OCCT_ADD_MESSAGE_LEVEL_SENTRY(theMessage) \
0076   Message_Level aLevel(theMessage);
0077 
0078 #endif // _Message_Level_HeaderFile