1 package Test::Valgrind::Report;
8 Test::Valgrind::Report - Base class for Test::Valgrind error reports.
16 our $VERSION = '1.13';
20 This class provides a generic API for messages (the so-called I<reports>) generated by the parser, filtered by the tool and the command, and handled by the action.
21 The tool has authority for deciding in which subclass of this one reports should be blessed.
23 Reports are classified by I<kinds>.
24 The C<Diag> kind is reserved for diagnostics.
28 use base qw<Test::Valgrind::Carp>;
30 =head2 C<< new kind => $kind, id => $id, data => $data >>
32 Your usual constructor.
34 All options are mandatory :
40 C<kind> is the category of the report.
44 C<id> is an unique identifier for the report.
48 C<data> is the content.
56 $class = ref($class) || $class;
60 my $kind = delete $args{kind};
61 $class->_croak("Invalid kind $kind for $class")
62 unless $class->valid_kind($kind);
64 my $id = delete $args{id};
65 $class->_croak("Invalid identifier $id") unless defined $id and not ref $id;
67 my $data = delete $args{data};
76 =head2 C<< new_diag $data >>
78 Constructs a report with kind C<'Diag'>, an auto-incremented identifier and the given C<$data>.
84 sub new_diag { shift->new(kind => 'Diag', id => ++$diag_id, data => $_[0]) }
88 Read-only accessor for the C<kind> option.
92 sub kind { $_[0]->{kind} }
96 Read-only accessor for the C<id> option.
100 sub id { $_[0]->{id} }
104 Read-only accessor for the C<data> option.
108 sub data { $_[0]->{data} }
112 Tells if a report has the C<'Diag'> kind, i.e. is a diagnostic.
116 sub is_diag { $_[0]->kind eq 'Diag' }
120 Returns the list of valid kinds for this report class.
122 Defaults to C<'Diag'>.
128 =head2 C<valid_kind $kind>
130 Tells whether C<$kind> is a valid kind for this report class.
132 Defaults to true iff C<$kind eq 'Diag'>.
136 sub valid_kind { $_[1] eq 'Diag' }
144 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
146 You can contact me by mail or on C<irc.perl.org> (vincent).
150 Please report any bugs or feature requests to C<bug-test-valgrind at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
151 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
155 You can find documentation for this module with the perldoc command.
157 perldoc Test::Valgrind::Report
159 =head1 COPYRIGHT & LICENSE
161 Copyright 2009,2010,2011 Vincent Pit, all rights reserved.
163 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
167 1; # End of Test::Valgrind::Report