]> git.vpit.fr Git - perl/modules/IPC-MorseSignals.git/blob - lib/IPC/MorseSignals/Receiver.pm
Put each POD sentence on its own line
[perl/modules/IPC-MorseSignals.git] / lib / IPC / MorseSignals / Receiver.pm
1 package IPC::MorseSignals::Receiver;
2
3 use strict;
4 use warnings;
5
6 use Carp qw/croak/;
7
8 use Bit::MorseSignals::Receiver;
9 use base qw/Bit::MorseSignals::Receiver/;
10
11 =head1 NAME
12
13 IPC::MorseSignals::Receiver - Base class for IPC::MorseSignals receivers.
14
15 =head1 VERSION
16
17 Version 0.16
18
19 =cut
20
21 our $VERSION = '0.16';
22
23 =head1 SYNOPSIS
24
25     use IPC::MorseSignals::Receiver;
26
27     local %SIG;
28     my $pants = IPC::MorseSignals::Receiver->new(\%SIG, done => sub {
29      print STDERR "GOT $_[1]\n";
30     });
31
32 =head1 DESCRIPTION
33
34 This module installs C<$SIG{qw/USR1 USR2/}> handlers and forwards the bits received to an underlying L<Bit::MorseSignals> receiver.
35
36 =head1 METHODS
37
38 =head2 C<new>
39
40     my $imr = IPC::MorseSignals::Receiver->new(%bmr_options);
41
42 Creates a new receiver object.
43 Its arguments are passed to L<Bit::MorseSignals::Receiver/new>, in particular the C<done> callback.
44
45 =cut
46
47 sub new {
48  my $class = shift;
49  my $sig   = shift;
50  $class = ref $class || $class || return;
51  croak 'The first argument must be a hash reference to the %SIG hash'
52   unless $sig and ref $sig eq 'HASH';
53  my $self = bless $class->SUPER::new(@_), $class;
54  @{$sig}{qw/USR1 USR2/} = (sub { $self->push(0) }, sub { $self->push(1) });
55  return $self;
56 }
57
58 =pod
59
60 IPC::MorseSignals::Receiver objects also inherit methods from L<Bit::MorseSignals::Receiver>.
61
62 =head1 EXPORT
63
64 An object module shouldn't export any function, and so does this one.
65
66 =head1 DEPENDENCIES
67
68 L<Bit::MorseSignals::Receiver>.
69
70 L<Carp> (standard since perl 5) is also required.
71
72 =head1 SEE ALSO
73
74 L<IPC::MorseSignals>, L<IPC::MorseSignals::Emitter>.
75
76 L<Bit::MorseSignals>, L<Bit::MorseSignals::Emitter>, L<Bit::MorseSignals::Receiver>.
77
78 L<perlipc> for information about signals in perl.
79
80 For truly useful IPC, search for shared memory, pipes and semaphores.
81
82 =head1 AUTHOR
83
84 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
85
86 You can contact me by mail or on C<irc.perl.org> (vincent).
87
88 =head1 BUGS
89
90 Please report any bugs or feature requests to C<bug-ipc-morsesignals-receiver at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-MorseSignals>.
91 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
92
93 =head1 SUPPORT
94
95 You can find documentation for this module with the perldoc command.
96
97     perldoc IPC::MorseSignals::Receiver
98
99 =head1 COPYRIGHT & LICENSE
100
101 Copyright 2007,2008,2013 Vincent Pit, all rights reserved.
102
103 This program is free software; you can redistribute it and/or modify it
104 under the same terms as Perl itself.
105
106 =cut
107
108 1; # End of IPC::MorseSignals::Receiver