ProgressMonitor::AbstractStatefulMonitor - a reusable/abstract monitor implementation


ProgressMonitor documentation  | view source Contained in the ProgressMonitor distribution.

Index


NAME

Top

ProgressMonitor::AbstractStatefulMonitor - a reusable/abstract monitor implementation keeping track of state

SYNOPSIS

Top

  ...
  use classes
    extends  => 'ProgressMonitor::AbstractStatefulMonitor',
    new      => 'new',
    ...
  ;

  sub new
  {
    my $class = shift;
    my $cfg   = shift;

    my $self = $class->SUPER::_new($cfg, $CLASS);

    ...
  }

  sub render
  {
    my $self = shift;

    ...
  }

DESCRIPTION

Top

This class implements the fully abstract ProgressMonitor interface and is what generally should be used as a base. It deals with tracking the state changes and cancellation and calls the subclass through 'render' at appropriate times. It is strict and throws exceptions if misused.

When extended it provides several accessors for 'protected' data, i.e. only for the use of subclasses. These accessors are prefixed with '_'.

Subclassing this normally entails only defining the render method.

See ProgressMonitor for the general description of a progress monitor behavior with regard to state etc.

Inherits from ProgressMonitor.

METHODS

Top

begin( $totalTicks )

Enters the active state from the preparing state, setting the total ticks that should be reached, or use undef to indicate that the number of ticks is unknown.

Throws X::InvalidState for an incorrect calling sequence.

end

Enters the done state from the active state, and the monitor can then not be used again.

Throws X::InvalidState for an incorrect calling sequence.

isCanceled

Returns the cancellation flag.

prepare

Enters the preparing state from the new state, and the monitor can now be used while the code is figuring out how many ticks it will need for the active state.

Throws X::ProgressMonitor::InvalidState for an incorrect calling sequence.

setCanceled( $boolean )

Sets the cancellation flag.

tick( $ticks )

Advances the tick count towards the total tick count (depending on if its is in the preparing state or if the total is unknown).

Throws X::ProgressMonitor::TooManyTicks if the tick count exceeds the total.

PROTECTED METHODS

Top

_new( $hashRef, $package )

The constructor, needs to be called by subclasses.

Configuration data: resolution (default => 8) Should not needed to be used. Makes sure to round the results down to the given size decimals so as to avoid wacky floating point rounding errors when using inexact floating point values in calculations (this happens when using subtasks).

  completeAtEnd (default => 1)
    Will automatically add any ticks not performed when end is called.

_get_cfg

Returns the configuration object.

_get_state

Returns the current state value.

_get_ticks

Returns the current tick value.

_get_totalTicks

Returns the total tick value.

AUTHOR

Top

Kenneth Olwing, <knth at cpan.org>

BUGS

Top

I wouldn't be surprised! If you can come up with a minimal test that shows the problem I might be able to take a look. Even better, send me a patch.

Please report any bugs or feature requests to bug-progressmonitor at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ProgressMonitor. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find general documentation for this module with the perldoc command:

    perldoc ProgressMonitor

ACKNOWLEDGEMENTS

Top

Thanks to my family. I'm deeply grateful for you!

COPYRIGHT & LICENSE

Top


ProgressMonitor documentation  | view source Contained in the ProgressMonitor distribution.