| 1 | # Copyrights 2011-2020 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||
| 5 | # This code is part of distribution IOMux. Meta-POD processed with OODoc | ||||||||||
| 6 | # into POD and HTML manual-pages. See README.md | ||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||
| 8 | |||||||||||
| 9 | package IOMux::Open; | ||||||||||
| 10 | 2 | ▶ | use vars '$VERSION'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | $VERSION = '1.01'; | |||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | use Log::Report 'iomux'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 2 | my %modes = | |||||||||
| 20 | ( '-|' => 'IOMux::Pipe::Read' | ||||||||||
| 21 | , '|-' => 'IOMux::Pipe::Write' | ||||||||||
| 22 | , '|-|' => 'IOMux::IPC' | ||||||||||
| 23 | , '|=|' => 'IOMux::IPC' | ||||||||||
| 24 | , '>' => 'IOMux::File::Write' | ||||||||||
| 25 | , '>>' => 'IOMux::File::Write' | ||||||||||
| 26 | , '<' => 'IOMux::File::Read' | ||||||||||
| 27 | , tcp => 'IOMux::Net::TCP' | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | sub import(@) | ||||||||||
| 31 | 3 | ▶ | { my $class = shift; | ||||||||
|
Subroutine
import: called CC=4 SCAR=14.3
| |||||||||||
| 32 | 3 | foreach my $mode (@_) | |||||||||
| 33 | 2 | ▶ | { my $impl = $modes{$mode} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | or error __x"unknown mode {mode} in use {pkg}" | ||||||||||
| 35 | , mode => $mode, pkg => $class; | ||||||||||
| 36 | 2 | eval "require $impl"; | |||||||||
| 37 | 2 | ▶ | panic $@ if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | sub new($@) | ||||||||||
| 43 | 4 | ▶ | { my ($class, $mode) = (shift, shift); | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||
| 44 | 4 | ▶ | my $real = $modes{$mode} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | or error __x"unknown mode '{mode}' to open() on mux", mode => $mode; | ||||||||||
| 46 | |||||||||||
| 47 | 4 | ▶ | $real->can('open') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | or error __x"package {pkg} for mode '{mode}' not required by {me}" | ||||||||||
| 49 | , pkg => $real, mode => $mode, me => $class; | ||||||||||
| 50 | |||||||||||
| 51 | 4 | $real->open($mode, @_); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | #-------------- | ||||||||||
| 55 | |||||||||||
| 56 | 2 | 1; | |||||||||