0032429: Coding - Warnings during compilation on macosx arm64 with option BUILD_Inspe...
[occt.git] / tools / MessageModel / MessageModel_ItemReport.hxx
1 // Created on: 2021-04-27
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2021 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement. 
15
16 #ifndef MessageModel_ItemReport_H
17 #define MessageModel_ItemReport_H
18
19 #include <inspector/MessageModel_ItemBase.hxx>
20 #include <Standard.hxx>
21 #include <TCollection_AsciiString.hxx>
22 #include <Message_Alert.hxx>
23 #include <Message_Report.hxx>
24 #include <NCollection_DataMap.hxx>
25
26 #include <Standard_WarningsDisable.hxx>
27 #include <QMap>
28 #include <QVariant>
29 #include <Standard_WarningsRestore.hxx>
30
31 class MessageModel_ItemReport;
32 typedef QExplicitlySharedDataPointer<MessageModel_ItemReport> MessageModel_ItemReportPtr;
33
34 //! \class MessageModel_ItemReport
35 //! This item is connected to Message_Alert.
36 //! Parent is MessageModel_ItemRoot, children are MessageModel_ItemAlert or no children
37 class MessageModel_ItemReport : public MessageModel_ItemBase
38 {
39 public:
40
41   //! Creates an item wrapped by a shared pointer
42   //! \param theRow the item row positition in the parent item
43   //! \param theColumn the item column positition in the parent item
44   //! \return the pointer to the created item
45   static MessageModel_ItemReportPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
46   { return MessageModel_ItemReportPtr (new MessageModel_ItemReport (theParent, theRow, theColumn)); }
47
48   //! Destructor
49   virtual ~MessageModel_ItemReport() Standard_OVERRIDE {};
50
51   //! Returns the current shape
52   const Handle(Message_Report)& GetReport() const { return myReport; }
53
54   //! Returns alert of the report for the parameter row
55   Standard_Boolean GetChildAlerts (const int theRow, Message_ListOfAlert& theAlerts) const { return myChildAlerts.Find(theRow, theAlerts); }
56
57   //! Returns the report description or NULL
58   const TCollection_AsciiString& GetDescription() const { return myDescription; }
59
60   //! Inits the item, fills internal containers
61   Standard_EXPORT virtual void Init() Standard_OVERRIDE;
62
63   //! Resets cached values
64   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
65
66   //! Return data value for the role.
67   //! \param theRole a value role
68   //! \return the value
69   Standard_EXPORT virtual QVariant initValue (const int theRole) const Standard_OVERRIDE;
70
71   //! \return number of children.
72   Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
73
74   //! Returns report of the tree model item. Iterates up by parents intil the report item is found.
75   //! \return an item or NULL
76   Standard_EXPORT static MessageModel_ItemReportPtr FindReportItem (const TreeModel_ItemBasePtr& theItem);
77
78   //! Returns report of the item
79   static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem);
80
81   //! Returns report cumulative metric as stop time of the last alert minus start time of the first alert
82   Standard_EXPORT static Standard_Real CumulativeMetric (const Handle(Message_Report)& theReport, const Message_MetricType theMetricType);
83
84 protected:
85
86   //! Initialize the current item.
87   virtual void initItem() const Standard_OVERRIDE;
88
89   //! Creates a child item in the given position.
90   //! \param theRow the child row position
91   //! \param theColumn the child column position
92   //! \return the created item
93   virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
94
95   //! Returns number of child shapes. Init item if it is not initialized
96   //! \return integer value
97   int getRowCount() const;
98
99   //! Returns current shape, initialized item if it has not been initialized yet
100   //! \return shape value
101   const Handle(Message_Report)& getReport() const;
102
103 private:
104
105   //! Constructor
106   MessageModel_ItemReport (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
107   : MessageModel_ItemBase (theParent, theRow, theColumn) {}
108
109 private:
110
111   NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
112
113   Handle(Message_Report) myReport; //!< current report
114   TCollection_AsciiString myDescription; //!< description
115 };
116
117 #endif