CATMathStream CATCGMProgressBar

Usage: you must use this class as is. You should never derive it.


public class CATCGMProgressBar

Class to track the progress of a task.
This object can be used in the Run of an operator to specify an estimated progress rate for different steps of the algorithm. A progress bar can be assigned an interruption function which is to be written by the calling application. A progress bar indicator is incremented between 0 and 100. Progress bars can be nested which is useful if an operator calls other operators which may themselves call other operators. With this mecanism, progress can be tracked linearly between 0 and 100 regardless of the nesting depth.
Example If Operator A calls Operators B and C, it can assign to them the progress bars and sets arbitrary proportions. For instance, assume that the Run method from A calls sequentially the Run methods from B and C and finally a Foo method from A. Furthermore, assume that on average 30% of the time is spent in B::Run, 50% in C::Run and 20% in A::Foo. The three operators have a SetProgressBar method that sets the callback in the operator;
Let _operA_CB be a pointer to a progress bar instance set in A. Then, the A::Run and A::Foo would be implemented as follows:

  CATBoolean A::Run ()
  {
    CATBoolean okToContinue = TRUE;

    B operB;
    C operC;

    // _operA_CB is the progress bar that is set in Class A.

    CATCGMProgressBar operB_CB (_operA_CB, 0.0, 30.0);     // 30%
    b.SetProgressBar (&operB_CB);
    okToContinue = operB.Run ();

    if (okToContinue)
    {
      CATCGMProgressBar operC_CB (_cb, 30.0, 80.0);        // 50%
      c.SetProgressBar (&cCB);
      okToContinue = operC.Run ();
    }

    if (okToContinue)
    {
      CATCGMProgressBar fooCB (_cb, 80.0, 100.0);          // 20%
      okToContinue = Foo (&fooCB);
    }
    
    return okToContinue;
  }

  okToContinue = A::Foo (CATCGMProgressBar* fooCB)
  {
    CATBoolean okToContinue = TRUE;

    if (fooCB)
      okToContinue = fooCB->SetProgress (0.0);
    +++

    if (fooCB && okToContinue)
      okToContinue = fooCB->SetProgress (50.0);
    +++

    if (okToContinue)
      okToContinue = fooCB->SetProgress (100.0);
    +++
     
  }
 


Constructor and Destructor Index


o CATCGMProgressBar()
o CATCGMProgressBar(CATCGMProgressBar*,double,double)
Constructs a nested progress bar.
o ~CATCGMProgressBar()

Method Index


o GetInterruptFunction()
Returns the external interrupt function (NULL if none)
o GetProgress()
Returns the progress currently made.
o SetProgress(double,double,CATBoolean,char*)
Sets the progress.
o SetProgressBarFunction(CATCGMInterruptFunction)
Sets the progress bar display and interrupt function.

Constructor and Destructor


o CATCGMProgressBar
public CATCGMProgressBar()
o CATCGMProgressBar
public CATCGMProgressBar( iParentProgressBar,
const iStartPercentage= 0.0,
const iEndPercentage= 100.0)
Constructs a nested progress bar. The two arguments are the mapped starting and end percentage values respectively:
Parameters:
iParentProgressBar
The parent progress bar.
iStartPercentage
A value between 0.0 and 100.0 to which a progress of 0% will be mapped.
iEndPercentage
A value between 0.0 and 100.0 to which a progress of 100% will be mapped. The iEndPercentage must be greater or equal to the iStartPercentage.
o ~CATCGMProgressBar
public virtual ~CATCGMProgressBar()

Methods


o GetInterruptFunction
public GetInterruptFunction()
Returns the external interrupt function (NULL if none)
o GetProgress
public GetProgress()
Returns the progress currently made.
Returns:
A double between 0 and 100.
o SetProgress
public SetProgress( const iValue,
const iTotalValue= 100.0,
iThrowIfInterrupted= FALSE,
const iStaticConstLabel= NULL)
Sets the progress.
Parameters:
iValue
The value currently reached (between 0 and iTotalValue if iTotalValue>0.)
iTotalValue
The value that is reached when 100% progress is achieved.
iThrowIfInterrupted
Indicates if an error "MathInterruptedOperator_ERR_110" has to be raised in case of interruption
iStaticConstLabel
This value is usefull for debugging purpose. if not NULL, to avoid memory lifecycle and invalid pointer, it MUST refers something such as :
 
        static const char MyOperationLabel[] = "IntersectionFaceFace"; 
        const char* iStaticConstLabel = MyOperationLabel; 
     
Returns:
A boolean to specify whether computation should continue (TRUE) or stop (FALSE.)
o SetProgressBarFunction
public SetProgressBarFunction( ipInterruptFunction)
Sets the progress bar display and interrupt function. The progress bar function cannot be specified twice. If a parent progress bar is specified, its interrupt function is used, even if an other interrupt function is set by SetProgressBarFunction.
Parameters:
ipInterruptFunction
The interruption function to be written by the calling application.

This object is included in the file: CATCGMProgressBar.h
If needed, your Imakefile.mk should include the module: CATMathStream

Copyright © 1999-2015, Dassault Systèmes. All rights reserved.