Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-05 09:23:10

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