Rocco Caputo > Reflex > Reflex::POE::Wheel

Download:
Reflex-0.099.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.099   Source  

NAME ^

Reflex::POE::Wheel - Base class for POE::Wheel wrappers.

VERSION ^

This document describes version 0.099, released on April 21, 2013.

SYNOPSIS ^

There is no concise synopsis at this time. Setting up a new Reflex::POE::Wheel is rather involved. The source for Reflex::POE::Wheel::Run may serve as an example.

DESCRIPTION ^

Reflex::POE::Wheel is a base class for Reflex objects that wrap and watch POE::Wheel objects. Subclasses define a handful of methods that describe the wheels they wrap. Reflex::POE::Wheel will use the configuration to validate constructor parameters, map wheel events to Reflex events, and map positional callback parameters to named ones.

It's rather handy once you get used to it.

Public Attributes

wheel

Currently Reflex::POE::Wheel exposes the raw POE::Wheel via its wheel() attribute. This will be undefined if the wheel hasn't been set up yet.

Public Methods

wheel_id

The wheel_id() method returns the ID of the POE::Wheel being managed. $foo->wheel()->ID() can also be used instead.

demolish_wheel

Cause the internal wheel to be demolished. Provided as a method since some wheels may require special handling.

put

put() sends its parameters to the POE::Wheel's put() method.

        $reflex_poe_wheel->put("one", "two");

Required Subclass Methods

These subclass methods are used to configure subclasses for their chosen POE::Wheel objects.

event_to_index

event_to_index() maps POE::Wheel events to consecutive integer event IDs. event_emit_names() will provide Reflex-friendly event names based on the event IDs. event_param_names() will provide parameter names that correspond to the wheel's positional parameters.

This mapping is from Reflex::POE::Wheel::Run. It will make more sense in the context of event_emit_names() and event_param_names().

        sub event_to_index {
                return(
                        {
                                StdinEvent  => 0,
                                StdoutEvent => 1,
                                StderrEvent => 2,
                                ErrorEvent  => 3,
                                CloseEvent  => 4,
                        },
                );
        }

event_emit_names

event_emit_names() returns an array reference that maps Reflex::POE::Wheel's event IDs to Reflex-friendly event names.

Here's an example from Reflex::POE::Wheel::Run. The wheel's StdinEvent (ID 0) is emitted as "stdin" (the 0th element in event_emit_names()). StdoutEvent becomes "stdout", and so on.

        sub event_emit_names {
                return(
                        [
                                'stdin',  # StdinEvent
                                'stdout', # StdoutEvent
                                'stderr', # StderrEvent
                                'error',  # ErrorEvent
                                'closed', # ClosedEvent
                        ],
                );
        }

event_param_names

event_param_names() returns an array reference that maps Reflex::POE::Wheel's event IDs to Reflex-friendly lists of parameter names. The underlying POE::Wheel's positional parameters will be mapped to these names before the Reflex object emits them.

Here's yet another example from Reflex::POE::Wheel::Run. StdinEvent and StdoutEvent each return two parameters. The Reflex object will emit their ARG0 as the named parameter "output", and ARG1 becomes the named parameter "wheel_id".

        sub event_param_names {
                return(
                        [
                                [ "wheel_id" ],
                                [ "output", "wheel_id" ],
                                [ "output", "wheel_id" ],
                                [ "operation", "errnum", "errstr", "wheel_id", "handle_name" ],
                                [ "wheel_id" ],
                        ]
                );
        }

wheel_class

wheel_class() returns a simple string---the class name of the wheel to construct.

valid_params

The valid_params() method returns a hash reference keyed on valid constructor parameters. Values don't matter at this time. Reflex::POE::Wheel uses this hash reference to pre-validate construction of underlying POE::Wheel objects.

POE::Wheel::Run takes quite a lot of parameters, most of which are optional.

        sub valid_params {
                return(
                        {
                                CloseOnCall => 1,
                                Conduit => 1,
                                Filter => 1,
                                Group => 1,
                                NoSetPgrp => 1,
                                NoSetSid => 1,
                                Priority => 1,
                                Program => 1,
                                ProgramArgs => 1,
                                StderrDriver => 1,
                                StderrFilter => 1,
                                StdinDriver => 1,
                                StdinFilter => 1,
                                StdioDriver => 1,
                                StdioFilter => 1,
                                StdoutDriver => 1,
                                StdoutFilter => 1,
                                User => 1,
                        }
                );
        }

CAVEATS ^

The demolish() name is heading towards deprecation in favor of something shorter and more widely recognized, perhaps stop(). The jury is still out, however.

Methods are not yet converted automatically. It seems more sensible to provide a native Reflex::Base interface. On the other hand, it may be possible for Moose's "handles" attribute option to pass the wheel's methods through the wrapper. More investigation is required.

wheel() or wheel_id() will be deprecated, depending upon which is considered redundant.

SEE ALSO ^

Please see those modules/websites for more information related to this module.

BUGS AND LIMITATIONS ^

You can make new bug reports, and view existing ones, through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Reflex.

AUTHOR ^

Rocco Caputo <rcaputo@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Rocco Caputo.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

AVAILABILITY ^

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/Reflex/.

DISCLAIMER OF WARRANTY ^

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

syntax highlighting: