Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:17

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 <TColStd_HArray1OfInteger.hxx>
0026 #include <Standard_Real.hxx>
0027 class TCollection_HAsciiString;
0028 
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 
0068   DEFINE_STANDARD_ALLOC
0069 
0070   
0071   //! Creates a Stat form. At start, one default phase is defined,
0072   //! with one default step. Then, it suffises to start with a
0073   //! count of items (and cycles if several) then record items,
0074   //! to have a queryable report.
0075   Standard_EXPORT MoniTool_Stat(const Standard_CString title = "");
0076   
0077   //! used when starting
0078   Standard_EXPORT MoniTool_Stat(const MoniTool_Stat& other);
0079   
0080   Standard_EXPORT static MoniTool_Stat& Current();
0081   
0082   //! Opens a new counter with a starting count of items
0083   Standard_EXPORT Standard_Integer Open (const Standard_Integer nb = 100);
0084   
0085   //! Adds more items to be counted by Add... on current level
0086   Standard_EXPORT void OpenMore (const Standard_Integer id, const Standard_Integer nb);
0087   
0088   //! Directly adds items
0089   Standard_EXPORT void Add (const Standard_Integer nb = 1);
0090   
0091   //! Declares a count of items to be added later. If a sub-counter
0092   //! is opened, its percentage multiplies this sub-count to compute
0093   //! the percent of current level
0094   Standard_EXPORT void AddSub (const Standard_Integer nb = 1);
0095   
0096   //! Ends the AddSub and cumulates the sub-count to current level
0097   Standard_EXPORT void AddEnd();
0098   
0099   Standard_EXPORT void Close (const Standard_Integer id);
0100   
0101   Standard_EXPORT Standard_Integer Level() const;
0102   
0103   Standard_EXPORT Standard_Real Percent (const Standard_Integer fromlev = 0) const;
0104 
0105 
0106 
0107 
0108 protected:
0109 
0110 
0111 
0112 
0113 
0114 private:
0115 
0116 
0117 
0118   Handle(TCollection_HAsciiString) thetit;
0119   Standard_Integer thelev;
0120   Handle(TColStd_HArray1OfInteger) thetot;
0121   Handle(TColStd_HArray1OfInteger) thedone;
0122   Handle(TColStd_HArray1OfInteger) thecurr;
0123 
0124 
0125 };
0126 
0127 
0128 
0129 
0130 
0131 
0132 
0133 #endif // _MoniTool_Stat_HeaderFile