Back to home page

EIC code displayed by LXR

 
 

    


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

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_AttributeMeter_HeaderFile
0015 #define _Message_AttributeMeter_HeaderFile
0016 
0017 #include <Message_Attribute.hxx>
0018 #include <Message_MetricType.hxx>
0019 
0020 #include <NCollection_IndexedDataMap.hxx>
0021 
0022 class Message_AlertExtended;
0023 
0024 //! Alert object storing alert metrics values.
0025 //! Start and stop values for each metric.
0026 class Message_AttributeMeter : public Message_Attribute
0027 {
0028 public:
0029 
0030   //! Returns default value of the metric when it is not defined
0031   //! @return undefined value
0032   static Standard_Real UndefinedMetricValue() { return -1.0; }
0033 
0034 public:
0035 
0036   //! Constructor with string argument
0037   Standard_EXPORT Message_AttributeMeter (const TCollection_AsciiString& theName = TCollection_AsciiString());
0038 
0039   //! Checks whether the attribute has values for the metric
0040   //! @param theMetric [in] metric type
0041   //! @return true if the metric values exist in the attribute
0042   Standard_EXPORT Standard_Boolean HasMetric (const Message_MetricType& theMetric) const;
0043 
0044   //! Returns true when both values of the metric are set.
0045   //! @param theMetric [in] metric type
0046   //! @return true if metric values are valid
0047   Standard_EXPORT Standard_Boolean IsMetricValid (const Message_MetricType& theMetric) const;
0048 
0049   //! Returns start value for the metric
0050   //! @param theMetric [in] metric type
0051   //! @return real value
0052   Standard_EXPORT Standard_Real StartValue (const Message_MetricType& theMetric) const;
0053 
0054   //! Sets start values for the metric
0055   //! @param theMetric [in] metric type
0056   Standard_EXPORT void SetStartValue (const Message_MetricType& theMetric, const Standard_Real theValue);
0057 
0058   //! Returns stop value for the metric
0059   //! @param theMetric [in] metric type
0060   //! @return real value
0061   Standard_EXPORT Standard_Real StopValue (const Message_MetricType& theMetric) const;
0062 
0063   //! Sets stop values for the metric
0064   //! @param theMetric [in] metric type
0065   Standard_EXPORT void SetStopValue (const Message_MetricType& theMetric, const Standard_Real theValue);
0066 
0067 public:
0068 
0069   //! Sets start values of default report metrics into the alert
0070   //! @param theAlert an alert  
0071   static void StartAlert (const Handle(Message_AlertExtended)& theAlert) { SetAlertMetrics (theAlert, Standard_True); }
0072 
0073   //! Sets stop values of default report metrics into the alert
0074   //! @param theAlert an alert  
0075   static void StopAlert (const Handle(Message_AlertExtended)& theAlert) { SetAlertMetrics (theAlert, Standard_False); }
0076 
0077   //! Sets current values of default report metrics into the alert.
0078   //! Processed only alert with Message_AttributeMeter attribute
0079   //! @param theAlert an alert  
0080   //! @param theStartValue flag, if true, the start value is collected otherwise stop
0081   static Standard_EXPORT void SetAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
0082                                                const Standard_Boolean theStartValue);
0083 
0084   //! Dumps the content of me into the stream
0085   virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
0086                                          Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0087 
0088   DEFINE_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
0089 
0090 private:
0091 
0092   typedef std::pair<Standard_Real, Standard_Real> StartToStopValue;
0093   NCollection_IndexedDataMap<Message_MetricType, StartToStopValue> myMetrics; //!< computed metrics
0094 };
0095 
0096 #endif // _Message_AttributeMeter_HeaderFile