POE - A Perl Object Environment


NAME

POE - A Perl Object Environment


SUPPORTED PLATFORMS

This module is not included with the standard ActivePerl distribution. It is available as a separate download using PPM.

SYNOPSIS

  # Basic usage:
  use POE;
  # create initial sessions here
  $poe_kernel->run();
  exit;
  # Typical usage:
  use POE qw( Wheel::SocketFactory Wheel::ReadWrite
              Driver::SysRW Filter::Line
            );
  # create initial sessions here
  $poe_kernel->run();
  exit;


DESCRIPTION

The POE distribution contains a handful of different modules, each doing something different.

When a program uses the POE module, the mandatory POE::Kernel and POE::Session classes are included. Other modules may be included in the parameter to ``use POE''. POE.pm will prepend ``POE::'' to the module names for you.


CONCEPTUAL OVERVIEW

POE's features are separated into three major sections. Sections are called ``layers'' in the documentation because each builds atop others.

  +-----------+ +--------------+
  | I/O Layer | | Object Layer |
  +-----------+ +--------------+
       /|\            /|\         Commands (to events layer)
        |              |
        |              |
       \|/            \|/         Events (from events layer)
  +----------------------------+
  |        Events Layer        |
  +----------------------------+

Events are also used to pass messages between Sessions.

This is a description of each layer, starting with the lowest and working upwards:

Events Layer

POE's events layer consists of two classes. These classes are always included when a program uses POE. They may also be used separately wherever their exported constants are needed.

POE::Kernel contains the state transition event queue and functions to manage resources (including events). Later on, these functions will be referred to as ``resource commands''. The Kernel will generate events to indicate when watched resources (via a resource command) become active.

POE::Session instances are state machines. They consist of bundles of related states. States may be code references, object methods or package subroutines. States are invoked whenever a queued transition event is dispatched. State transitions may be enqueued by states themselves or by active resources.

I/O Layer

The I/O layer contains one or more libraries that abstract file I/O. Currently there is only one abstraction library, fondly known as ``Wheels''. The ``Wheels'' abstraction consists of groups of classes.

One type of object does only low-level file I/O. These are the Driver objects.

A second type of object translates between raw octet streams and protocol packets. These are the Filter objects.

The final type of object provides a functional interface to file I/O, as well as the select logic to glue Drivers and Filters together. These are the Wheel objects.

Here is a rough picture of the Wheels I/O abstraction:

  +----------------------------------------------------------+
  | Session                                                  |
  |                                                          |
  | +------------+  +-------+     +--------+    +--------+   |
  | |States      |  |       |     |        |    |        |   |
  | |            |  |       |     |        |    |        |   |
  | |Command     |  |       |     | Filter |    |        |   |
  | |events    --|->|       |<--->|        |--->|        |   |
  | |            |  | Wheel |     |        |    | Driver |   |
  | |Functions --|->|       |     +--------+    |        |<--|--> File 
  | |            |  |       |                   |        |   |
  | |Response    |  |       |-> Select Events ->|        |   |
  | |events    <-|--|       |                   |        |   |
  | +------------+  +-------+                   +--------+   |
  |   |   /|\         |  /|\                                 |
  |   |    |          |   |                                  |
  +---|----|----------|---|----------------------------------+
      |    |          |   |
      |    |          |   |   Commands (Session -> Kernel)
      |    |          |   |   & Events (Kernel -> Session)
     \|/   |         \|/  |
  +----------------------------------------------------------+
  |                                                          |
  |                          Kernel                          |
  |                                                          |
  +----------------------------------------------------------+

Object Layer

The Object layer consists of one or more libraries that implement code objects. Currently there are two ways code objects can be created.

First, code may exist as plain Perl subroutines, objects and packages. This is the oldest object layer, and it is often the best for most programming tasks.

The second object layer is still in its infancy. Right now it consists of four classes:

Curator. This is the object manager. It embodies inheritance, attribute fetching and storage, method invocation and security.

Repository. This is the object database. It provides a consistent interface between the Curator and whatever database it hides.

Object. This is a Perl representation of a Repository object. It hides the Curator and Repository behind an interface that resembles a plain Perl object.

Runtime. This is a namespace where Object methods are run. It contains the public functions from Curator, Repository and Object, and it may one day run within a Safe compartment.

The obligatory ASCII art:

  +--------------------------------------------------+
  |                     Runtime                      |
  | +----------------+                               |
  | | Object Methods |-------> Public Functions      |
  | +----------------+                               |
  |   /|\                          |                 |
  +----|---------------------------|-----------------+
       |                           |
       | Events                    |  Commands
       |                          \|/
  +--------------------------------------------------+
  |                                                  |
  |  +------------+     Curator                      |
  |  |            |                                  |
  |  |  Sessions  |  +-------------------------------+
  |  |            |  |
  |  +------------+  |   +------------+   +--======--+
  |    /|\     |     |<->| Repository |<->| Database |
  +-----|------|-----+   +------------+   +--======--+
        |      |
        |      |   Events & Commands
        |     \|/
  +--------------------------------------------------+
  |                                                  |
  |                      Kernel                      |
  |                                                  |
  +--------------------------------------------------+


EXAMPLES

As of this writing there are 24 sample programs. Each illustrates and tests some aspect of POE use. They are included in the POE distribution archive, but they are not installed. If POE was installed via the CPAN shell, then you should be able to find them in your .cpan/build/POE-(version) directory.

Events Layer Examples

These sample programs demonstrate and exercise POE's events layer and resource management functions.

I/O Layer Examples

These sample programs demonstrate and exercise POE's default I/O layer.

Object Layer Examples

This program illustrates POE's Object Layer, which is still in early development.

Proofs of Concepts

Proofs of concepts mainly show how to do something with POE. In some cases, they prove that the concept is possible, even though it wasn't considered while POE was being designed.


SEE ALSO


BUGS

The Object Layer is still in early design and implementation, so it's not documented yet.

There are no automated regression tests.


AUTHORS & COPYRIGHTS

POE is brought to you by the following people:

Contributors

All contributions are Copyright 1998-1999 by their respective contributors. All rights reserved. Contributions to POE are free software, and they may be redistributed and/or modified under the same terms as Perl itself.

Author