Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:17:11

0001 // Created on: 1996-02-15
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _MoniTool_Stat_HeaderFile
0018 #define _MoniTool_Stat_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 #include <Standard_Real.hxx>
0028 class TCollection_HAsciiString;
0029 
0030 //! This class manages Statistics to be queried asynchronously.
0031 //!
0032 //! It is organized as a stack of counters, identified by their
0033 //! levels, from one to ... . Each one has a total account of
0034 //! items to be counted, a count of already passed items, plus a
0035 //! count of "current items". The counters of higher level play on
0036 //! these current items.
0037 //! For instance, if a counter has been opened for 100 items, 40
0038 //! already passed, 20 current, its own percent is 40, but there
0039 //! is the contribution of higher level counters, rated for 20 %
0040 //! of this counter.
0041 //!
0042 //! Hence, a counter is opened, items are added. Also items can be
0043 //! add for sub-counter (of higher level), they will be added
0044 //! definitively when the sub-counter will be closed. When the
0045 //! count has ended, this counter is closed, the counter of
0046 //! lower level cumulates it and goes on. As follows :
0047 //!
0048 //! Way of use :
0049 //! Open(nbitems);
0050 //! Add(..)  :  direct adding
0051 //! Add(..)
0052 //! AddSub (nsub)  :  for sub-counter
0053 //! Open (nbsubs)  :  nbsubs for this sub-counter
0054 //! Add (..)
0055 //! Close        : the sub-counter
0056 //! AddEnd()
0057 //! etc...
0058 //! Close          : the starting counter
0059 //!
0060 //! This means that a counter can be opened in a Stat, regardless
0061 //! to the already opened ones :: this will be cumulated
0062 //!
0063 //! A Current Stat is available, but it is possible to have others
0064 class MoniTool_Stat
0065 {
0066 public:
0067   DEFINE_STANDARD_ALLOC
0068 
0069   //! Creates a Stat form. At start, one default phase is defined,
0070   //! with one default step. Then, it suffises to start with a
0071   //! count of items (and cycles if several) then record items,
0072   //! to have a queryable report.
0073   Standard_EXPORT MoniTool_Stat(const char* const title = "");
0074 
0075   //! used when starting
0076   Standard_EXPORT MoniTool_Stat(const MoniTool_Stat& other);
0077 
0078   Standard_EXPORT static MoniTool_Stat& Current();
0079 
0080   //! Opens a new counter with a starting count of items
0081   Standard_EXPORT int Open(const int nb = 100);
0082 
0083   //! Adds more items to be counted by Add... on current level
0084   Standard_EXPORT void OpenMore(const int id, const int nb);
0085 
0086   //! Directly adds items
0087   Standard_EXPORT void Add(const int nb = 1);
0088 
0089   //! Declares a count of items to be added later. If a sub-counter
0090   //! is opened, its percentage multiplies this sub-count to compute
0091   //! the percent of current level
0092   Standard_EXPORT void AddSub(const int nb = 1);
0093 
0094   //! Ends the AddSub and cumulates the sub-count to current level
0095   Standard_EXPORT void AddEnd();
0096 
0097   Standard_EXPORT void Close(const int id);
0098 
0099   Standard_EXPORT int Level() const;
0100 
0101   Standard_EXPORT double Percent(const int fromlev = 0) const;
0102 
0103 private:
0104   occ::handle<TCollection_HAsciiString> thetit;
0105   int                                   thelev;
0106   occ::handle<NCollection_HArray1<int>> thetot;
0107   occ::handle<NCollection_HArray1<int>> thedone;
0108   occ::handle<NCollection_HArray1<int>> thecurr;
0109 };
0110 
0111 #endif // _MoniTool_Stat_HeaderFile