return $tool->new(%args);
}
- bless { }, $class;
+ my $self = bless { }, $class;
+
+ $self->started(undef);
+
+ $self;
}
=head2 C<new_trainer>
=cut
-sub args { }
+sub args { }
=head2 C<suppressions_tag $session>
sub suppressions_tag;
+=head2 C<started>
+
+Specifies whether the tool is running (C<1>), stopped (C<0>) or was never started (C<undef>).
+
+=cut
+
+sub started { @_ <= 1 ? $_[0]->{started} : ($_[0]->{started} = $_[1]) }
+
=head2 C<start $session>
Called when the C<$session> starts.
-Defaults to void.
+Defaults to set L</started>.
=cut
-sub start { }
+sub start {
+ my ($self) = @_;
+
+ $self->_croak('Tool already started') if $self->started;
+ $self->started(1);
+
+ return;
+}
=head2 C<parse $session, $fh>
Wraps around either L</parse_suppressions> or L</parse_analysis> depending on the running mode of the C<$session>.
+Croaks if the tool isn't started.
=cut
sub parse {
my ($self, $sess, $fh) = @_;
+ $self->_croak('Tool isn\'t started') unless $self->started;
+
if ($sess->do_suppressions) {
$self->parse_suppressions($sess, $fh);
} else {
Called when the C<$session> finishes.
-Defaults to void.
+Defaults to clear L</started>.
=cut
-sub finish { }
+sub finish {
+ my ($self) = @_;
+
+ return unless $self->started;
+ $self->started(0);
+
+ return;
+}
=head1 SEE ALSO