]> git.vpit.fr Git - perl/modules/IPC-MorseSignals.git/blob - lib/IPC/MorseSignals/Receiver.pm
Importing IPC-MorseSignals-0.14.tar.gz
[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.14
18
19 =cut
20
21 our $VERSION = '0.14';
22
23 =head1 SYNOPSIS
24
25     use IPC::MorseSignals::Receiver;
26
27     local %SIG;
28     my $pants = new IPC::MorseSignals::Receiver \%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 Creates a new receiver object. Its arguments are passed to L<Bit::MorseSignals::Receiver/new>, in particular the C<done> callback.
41
42 =cut
43
44 sub new {
45  my $class = shift;
46  my $sig   = shift;
47  $class = ref $class || $class || return;
48  croak 'The first argument must be a hash reference to the %SIG hash'
49   unless $sig and ref $sig eq 'HASH';
50  my $self = bless $class->SUPER::new(@_), $class;
51  @{$sig}{qw/USR1 USR2/} = (sub { $self->push(0) }, sub { $self->push(1) });
52  return $self;
53 }
54
55 =pod
56
57 IPC::MorseSignals::Receiver objects also inherit methods from L<Bit::MorseSignals::Receiver>.
58
59 =head1 EXPORT
60
61 An object module shouldn't export any function, and so does this one.
62
63 =head1 DEPENDENCIES
64
65 L<Bit::MorseSignals::Receiver>.
66
67 L<Carp> (standard since perl 5) is also required.
68
69 =head1 SEE ALSO
70
71 L<IPC::MorseSignals>, L<IPC::MorseSignals::Emitter>.
72
73 L<Bit::MorseSignals>, L<Bit::MorseSignals::Emitter>, L<Bit::MorseSignals::Receiver>.
74
75 L<perlipc> for information about signals in perl.
76
77 For truly useful IPC, search for shared memory, pipes and semaphores.
78
79 =head1 AUTHOR
80
81 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
82
83 You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince).
84
85 =head1 BUGS
86
87 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>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
88
89 =head1 SUPPORT
90
91 You can find documentation for this module with the perldoc command.
92
93     perldoc IPC::MorseSignals::Receiver
94
95 =head1 COPYRIGHT & LICENSE
96
97 Copyright 2007-2008 Vincent Pit, all rights reserved.
98
99 This program is free software; you can redistribute it and/or modify it
100 under the same terms as Perl itself.
101
102 =cut
103
104 1; # End of IPC::MorseSignals::Receiver