X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FIPC-MorseSignals.git;a=blobdiff_plain;f=lib%2FIPC%2FMorseSignals%2FReceiver.pm;fp=lib%2FIPC%2FMorseSignals%2FReceiver.pm;h=4ca5c1099889c6b8795472600a5ebf201499933c;hp=0000000000000000000000000000000000000000;hb=ddcc7c395d570f0ea20a8e9a242fcbfcc0e49522;hpb=13c16aeec1454ae58e932b393e827d6353c13231 diff --git a/lib/IPC/MorseSignals/Receiver.pm b/lib/IPC/MorseSignals/Receiver.pm new file mode 100644 index 0000000..4ca5c10 --- /dev/null +++ b/lib/IPC/MorseSignals/Receiver.pm @@ -0,0 +1,104 @@ +package IPC::MorseSignals::Receiver; + +use strict; +use warnings; + +use Carp qw/croak/; + +use Bit::MorseSignals::Receiver; +use base qw/Bit::MorseSignals::Receiver/; + +=head1 NAME + +IPC::MorseSignals::Receiver - Base class for IPC::MorseSignals receivers. + +=head1 VERSION + +Version 0.10 + +=cut + +our $VERSION = '0.10'; + +=head1 SYNOPSIS + + use IPC::MorseSignals::Receiver; + + local %SIG; + my $pants = new IPC::MorseSignals::Receiver \%SIG, done => sub { + print STDERR "GOT $_[1]\n"; + }; + +=head1 DESCRIPTION + +This module installs C<$SIG{qw/USR1 USR2/}> handlers and forwards the bits received to a L receiver. + +=head1 METHODS + +=head2 C + +Creates a new receiver object. Its arguments are passed to L, in particular the C callback. + +=cut + +sub new { + my $class = shift; + my $sig = shift; + $class = ref $class || $class || return; + croak 'The first argument must be a hash reference to the %SIG hash' + unless $sig and ref $sig eq 'HASH'; + my $self = bless $class->SUPER::new(@_), $class; + @{$sig}{qw/USR1 USR2/} = (sub { $self->push(0) }, sub { $self->push(1) }); + return $self; +} + +=pod + +IPC::MorseSignals::Receiver objects also inherit methods from L. + +=head1 EXPORT + +An object module shouldn't export any function, and so does this one. + +=head1 DEPENDENCIES + +L. + +L (standard since perl 5) is also required. + +=head1 SEE ALSO + +L, L. + +L, L, L. + +L for information about signals in perl. + +For truly useful IPC, search for shared memory, pipes and semaphores. + +=head1 AUTHOR + +Vincent Pit, C<< >>, L. + +You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince). + +=head1 BUGS + +Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. + +=head1 SUPPORT + +You can find documentation for this module with the perldoc command. + + perldoc IPC::MorseSignals::Receiver + +=head1 COPYRIGHT & LICENSE + +Copyright 2007-2008 Vincent Pit, all rights reserved. + +This program is free software; you can redistribute it and/or modify it +under the same terms as Perl itself. + +=cut + +1; # End of IPC::MorseSignals::Receiver