| // 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_AttributeMeter_HeaderFile | |
| #define _Message_AttributeMeter_HeaderFile | |
| #include <Message_Attribute.hxx> | |
| #include <Message_MetricType.hxx> | |
| #include <TCollection_AsciiString.hxx> | |
| #include <NCollection_IndexedDataMap.hxx> | |
| class Message_AlertExtended; | |
| //! Alert object storing alert metrics values. | |
| //! Start and stop values for each metric. | |
| class Message_AttributeMeter : public Message_Attribute | |
| { | |
| public: | |
| //! Returns default value of the metric when it is not defined | |
| //! @return undefined value | |
| static double UndefinedMetricValue() { return -1.0; } | |
| public: | |
| //! Constructor with string argument | |
| Standard_EXPORT Message_AttributeMeter( | |
| const TCollection_AsciiString& theName = TCollection_AsciiString::EmptyString()); | |
| //! Checks whether the attribute has values for the metric | |
| //! @param[in] theMetric metric type | |
| //! @return true if the metric values exist in the attribute | |
| Standard_EXPORT bool HasMetric(const Message_MetricType& theMetric) const; | |
| //! Returns true when both values of the metric are set. | |
| //! @param[in] theMetric metric type | |
| //! @return true if metric values are valid | |
| Standard_EXPORT bool IsMetricValid(const Message_MetricType& theMetric) const; | |
| //! Returns start value for the metric | |
| //! @param[in] theMetric metric type | |
| //! @return real value | |
| Standard_EXPORT double StartValue(const Message_MetricType& theMetric) const; | |
| //! Sets start values for the metric | |
| //! @param[in] theMetric metric type | |
| Standard_EXPORT void SetStartValue(const Message_MetricType& theMetric, const double theValue); | |
| //! Returns stop value for the metric | |
| //! @param[in] theMetric metric type | |
| //! @return real value | |
| Standard_EXPORT double StopValue(const Message_MetricType& theMetric) const; | |
| //! Sets stop values for the metric | |
| //! @param[in] theMetric metric type | |
| Standard_EXPORT void SetStopValue(const Message_MetricType& theMetric, const double theValue); | |
| public: | |
| //! Sets start values of default report metrics into the alert | |
| //! @param theAlert an alert | |
| static void StartAlert(const occ::handle<Message_AlertExtended>& theAlert) | |
| { | |
| SetAlertMetrics(theAlert, true); | |
| } | |
| //! Sets stop values of default report metrics into the alert | |
| //! @param theAlert an alert | |
| static void StopAlert(const occ::handle<Message_AlertExtended>& theAlert) | |
| { | |
| SetAlertMetrics(theAlert, false); | |
| } | |
| //! Sets current values of default report metrics into the alert. | |
| //! Processed only alert with Message_AttributeMeter attribute | |
| //! @param theAlert an alert | |
| //! @param theStartValue flag, if true, the start value is collected otherwise stop | |
| static Standard_EXPORT void SetAlertMetrics(const occ::handle<Message_AlertExtended>& theAlert, | |
| const bool theStartValue); | |
| //! Dumps the content of me into the stream | |
| Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override; | |
| DEFINE_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute) | |
| private: | |
| typedef std::pair<double, double> StartToStopValue; | |
| // clang-format off | |
| NCollection_IndexedDataMap<Message_MetricType, StartToStopValue> myMetrics; //!< computed metrics | |
| // clang-format on | |
| }; | |
| #endif // _Message_AttributeMeter_HeaderFile |