X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FTool.pm;h=a1211af7fb3a3dedaf668ca290980d677cfa15db;hb=8a51ed6220d0fb2e29c669011bdf733c347b60f4;hp=9bd530f5a43f17ffc2c64a560b76dc0a22ce5653;hpb=01942f85f66b0e5468e198fd0101c2e9686fd118;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Tool.pm b/lib/Test/Valgrind/Tool.pm index 9bd530f..a1211af 100644 --- a/lib/Test/Valgrind/Tool.pm +++ b/lib/Test/Valgrind/Tool.pm @@ -58,7 +58,11 @@ sub new { return $tool->new(%args); } - bless { }, $class; + my $self = bless { }, $class; + + $self->started(undef); + + $self; } =head2 C @@ -116,7 +120,7 @@ Defaults to the empty list. =cut -sub args { } +sub args { } =head2 C @@ -128,25 +132,43 @@ This method must be implemented when subclassing. sub suppressions_tag; +=head2 C + +Specifies whether the tool is running (C<1>), stopped (C<0>) or was never started (C). + +=cut + +sub started { @_ <= 1 ? $_[0]->{started} : ($_[0]->{started} = $_[1]) } + =head2 C Called when the C<$session> starts. -Defaults to void. +Defaults to set L. =cut -sub start { } +sub start { + my ($self) = @_; + + $self->_croak('Tool already started') if $self->started; + $self->started(1); + + return; +} =head2 C Wraps around either L or L 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 { @@ -178,11 +200,18 @@ sub parse_analysis; Called when the C<$session> finishes. -Defaults to void. +Defaults to clear L. =cut -sub finish { } +sub finish { + my ($self) = @_; + + return unless $self->started; + $self->started(0); + + return; +} =head1 SEE ALSO