42cf5bc1 |
1 | // Created on: 1996-02-15 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _MoniTool_Stat_HeaderFile |
18 | #define _MoniTool_Stat_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Integer.hxx> |
25 | #include <TColStd_HArray1OfInteger.hxx> |
26 | #include <Standard_CString.hxx> |
27 | #include <Standard_Real.hxx> |
28 | class TCollection_HAsciiString; |
29 | |
30 | |
31 | //! This class manages Statistics to be queried asynchronously. |
32 | //! |
33 | //! It is organized as a stack of counters, identified by their |
34 | //! levels, from one to ... . Each one has a total account of |
35 | //! items to be counted, a count of already passed items, plus a |
36 | //! count of "current items". The counters of higher level play on |
37 | //! these current items. |
38 | //! For instance, if a counter has been opened for 100 items, 40 |
39 | //! already passed, 20 current, its own percent is 40, but there |
40 | //! is the contribution of higher level counters, rated for 20 % |
41 | //! of this counter. |
42 | //! |
43 | //! Hence, a counter is opened, items are added. Also items can be |
44 | //! add for sub-counter (of higher level), they will be added |
45 | //! definitively when the sub-counter will be closed. When the |
46 | //! count has ended, this counter is closed, the counter of |
47 | //! lower level cumulates it and goes on. As follows : |
48 | //! |
49 | //! Way of use : |
50 | //! Open(nbitems); |
51 | //! Add(..) : direct adding |
52 | //! Add(..) |
53 | //! AddSub (nsub) : for sub-counter |
54 | //! Open (nbsubs) : nbsubs for this sub-counter |
55 | //! Add (..) |
56 | //! Close : the sub-counter |
57 | //! AddEnd() |
58 | //! etc... |
59 | //! Close : the starting counter |
60 | //! |
61 | //! This means that a counter can be opened in a Stat, regardless |
62 | //! to the already opened ones :: this will be cumulated |
63 | //! |
64 | //! A Current Stat is available, but it is possible to have others |
65 | class MoniTool_Stat |
66 | { |
67 | public: |
68 | |
69 | DEFINE_STANDARD_ALLOC |
70 | |
71 | |
72 | //! Creates a Stat form. At start, one default phase is defined, |
73 | //! with one default step. Then, it suffises to start with a |
74 | //! count of items (and cycles if several) then record items, |
75 | //! to have a queryable report. |
76 | Standard_EXPORT MoniTool_Stat(const Standard_CString title = ""); |
77 | |
78 | //! used when starting |
79 | Standard_EXPORT MoniTool_Stat(const MoniTool_Stat& other); |
80 | |
81 | Standard_EXPORT static MoniTool_Stat& Current(); |
82 | |
83 | //! Opens a new counter with a starting count of items |
84 | Standard_EXPORT Standard_Integer Open (const Standard_Integer nb = 100); |
85 | |
86 | //! Adds more items to be counted by Add... on current level |
87 | Standard_EXPORT void OpenMore (const Standard_Integer id, const Standard_Integer nb); |
88 | |
a25d5aaa |
89 | //! Directly adds items |
42cf5bc1 |
90 | Standard_EXPORT void Add (const Standard_Integer nb = 1); |
91 | |
92 | //! Declares a count of items to be added later. If a sub-counter |
93 | //! is opened, its percentage multiplies this sub-count to compute |
94 | //! the percent of current level |
95 | Standard_EXPORT void AddSub (const Standard_Integer nb = 1); |
96 | |
97 | //! Ends the AddSub and cumulates the sub-count to current level |
98 | Standard_EXPORT void AddEnd(); |
99 | |
100 | Standard_EXPORT void Close (const Standard_Integer id); |
101 | |
102 | Standard_EXPORT Standard_Integer Level() const; |
103 | |
104 | Standard_EXPORT Standard_Real Percent (const Standard_Integer fromlev = 0) const; |
105 | |
106 | |
107 | |
108 | |
109 | protected: |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | private: |
116 | |
117 | |
118 | |
119 | Handle(TCollection_HAsciiString) thetit; |
120 | Standard_Integer thelev; |
121 | Handle(TColStd_HArray1OfInteger) thetot; |
122 | Handle(TColStd_HArray1OfInteger) thedone; |
123 | Handle(TColStd_HArray1OfInteger) thecurr; |
124 | |
125 | |
126 | }; |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | #endif // _MoniTool_Stat_HeaderFile |