1 package Test::Valgrind::Report;
8 Test::Valgrind::Report - Base class for Test::Valgrind error reports.
16 our $VERSION = '1.16';
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>;
32 my $tvr = Test::Valgrind::Report->new(
38 Your usual constructor.
40 All options are mandatory :
46 C<kind> is the category of the report.
50 C<id> is an unique identifier for the report.
54 C<data> is the content.
62 $class = ref($class) || $class;
66 my $kind = delete $args{kind};
67 $class->_croak("Invalid kind $kind for $class")
68 unless $class->valid_kind($kind);
70 my $id = delete $args{id};
71 $class->_croak("Invalid identifier $id") unless defined $id and not ref $id;
73 my $data = delete $args{data};
84 my $diag_report = Test::Valgrind::Report->new_diag($data);
86 Constructs a report with kind C<'Diag'>, an auto-incremented identifier and the given C<$data>.
92 sub new_diag { shift->new(kind => 'Diag', id => ++$diag_id, data => $_[0]) }
96 my $kind = $tvr->kind;
98 Read-only accessor for the C<kind> option.
102 sub kind { $_[0]->{kind} }
108 Read-only accessor for the C<id> option.
112 sub id { $_[0]->{id} }
116 my $data = $tvr->data;
118 Read-only accessor for the C<data> option.
122 sub data { $_[0]->{data} }
128 Tells if a report has the C<'Diag'> kind, i.e. is a diagnostic.
132 sub is_diag { $_[0]->kind eq 'Diag' }
136 my @kinds = $tvr->kinds;
138 Returns the list of valid kinds for this report class.
140 Defaults to C<'Diag'>.
148 $tvr->valid_kind($kind);
150 Tells whether C<$kind> is a valid kind for this report class.
152 Defaults to true iff C<$kind eq 'Diag'>.
156 sub valid_kind { $_[1] eq 'Diag' }
164 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
166 You can contact me by mail or on C<irc.perl.org> (vincent).
170 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>.
171 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
175 You can find documentation for this module with the perldoc command.
177 perldoc Test::Valgrind::Report
179 =head1 COPYRIGHT & LICENSE
181 Copyright 2009,2010,2011,2013,2015 Vincent Pit, all rights reserved.
183 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
187 1; # End of Test::Valgrind::Report