1 package Test::Valgrind::Report;
8 Test::Valgrind::Report - Base class for Test::Valgrind error reports.
16 our $VERSION = '1.00';
18 use base qw/Test::Valgrind::Carp/;
20 =head2 C<< new kind => $kind, id => $id, data => $data >>
22 Your usual constructor.
24 All options are mandatory :
30 C<kind> is the category of the report.
34 C<id> is an unique identifier for the report.
38 C<data> is the content.
46 $class = ref($class) || $class;
50 my $kind = delete $args{kind};
51 $class->_croak("Invalid kind $kind for $class")
52 unless $class->valid_kind($kind);
54 my $id = delete $args{id};
55 $class->_croak("Invalid identifier $id") unless defined $id and not ref $id;
57 my $data = delete $args{data};
66 =head2 C<< new_diag $data >>
68 Constructs an object with kind C<'Diag'>, an auto-incremented identifier and the given C<$data>.
74 sub new_diag { shift->new(kind => 'Diag', id => ++$diag_id, data => $_[0]) }
78 Read-only accessor for the C<kind> option.
82 sub kind { $_[0]->{kind} }
86 Read-only accessor for the C<id> option.
90 sub id { $_[0]->{id} }
94 Read-only accessor for the C<data> option.
98 sub data { $_[0]->{data} }
102 Tells if a report has the C<'Diag'> kind, i.e. is a diagnostic.
106 sub is_diag { $_[0]->kind eq 'Diag' }
110 Returns the list of valid kinds for this report class.
112 Defaults to C<'Diag'>.
118 =head2 C<valid_kind $kind>
120 Tells whether C<$kind> is a valid kind for this report class.
122 Defaults to true iff C<$kind eq 'Diag'>.
126 sub valid_kind { $_[1] eq 'Diag' }
134 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
136 You can contact me by mail or on C<irc.perl.org> (vincent).
140 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>.
141 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
145 You can find documentation for this module with the perldoc command.
147 perldoc Test::Valgrind::Report
149 =head1 COPYRIGHT & LICENSE
151 Copyright 2009 Vincent Pit, all rights reserved.
153 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
157 1; # End of Test::Valgrind::Report