Richard Clamp > Pipeline-3.12 > Pipeline

Download:
Pipeline-3.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  5
Open  0
View/Report Bugs
Module Version: 3.12   Source  

NAME ^

Pipeline - Generic pipeline interface

SYNOPSIS ^

  use Pipeline;
  my $pipeline = Pipeline->new();
  $pipeline->add_segment( @segments );
  $pipeline->dispatch();

DESCRIPTION ^

Pipelines are a mechanism to process data. They are designed to be plugged together to make fairly complex operations act in a fairly straightforward manner, cleanly, and simply.

USING THE PIPELINE MODULE ^

The usage of the generic pipeline module is fairly simple. You instantiate a Pipeline object by using the new() constructor.

Segments can be added to the pipeline with the add_segment method.

The store that the Pipeline will use can be set by calling the store() method later on. If a store is not set by the time a pipeline is executing then it will use a store of the type Pipeline::Store::Simple.

To start the pipeline running call the dispatch() method on your Pipeline object.

If a segment returns a Pipeline::Production object then the pipeline will be terminated early and the production will be returned to the user. Regardless of when the pipeline is terminated the pipeline's cleanup pipeline is executed. Segments can be added to the cleanup pipeline either explicitly by calling the cleanups method to get the cleanup pipeline and then adding the segment, or implicitly by returning a segment object from a segment.

To see what is being dispatched within a pipeline dispatch set the pipeline's debug_all value to true.

INHERITANCE

Pipelines are designed to be inherited from. The inheritance tree is somewhat warped and should look a little like this:

     MySegment --> Pipeline::Segment <--- Pipeline

In other words, everything is a pipeline segment.

METHODS ^

The Pipeline class inherits from the Pipeline::Segment class and therefore also has any additional methods that its superclass may have.

init( @_ )

Things to do at construction time. If you do override this, it will often be fairly important that you call and check the value of $self->SUPER::init(@_) to make sure that the setup is done correctly. Returns itself on success, undef on failure. The constructor will fail if you return a false value.

add_segment( LIST )

Adds a segment or segments to the pipeline. Returns itself.

get_segment( INTEGER )

Returns the segment located at the index specified by INTEGER

del_segment( INTEGER )

Deletes and returns the segment located at the index specified by INTEGER

process_results( ARRAYREF )

Examines each result of a segment and calls process_indv_result with each element of ARRAYREF. In the case that process_indv_result returns a production then it is returned to the caller.

process_indv_result( SCALAR )

Examines a single result and does the appripriate thing with it (ie, if it is an object it puts it into the store, if it is a production it returns it to the caller, and if it is a simple value it gets thrown away. In the case that a value is returned from process_indv_result the pipeline should terminate.

dispatch()

Starts the pipeline execution. It calls process_results on anything that a segment returns. The pipeline always returns the production or true.

dispatch_loop( Pipeline, [ ARRAYREF ] )

The dispatch_loop method performs the processing for the pipeline

start_dispatch

Prepares all elements of the pipeline to begin processing a segment.

end_dispatch

Cleans up all elements of the pipeline after processing a segment.

dispatch_segment( Pipeline::Segment )

The dispatch_segment method handles the execution of an individual segment object.

dispatcher( [Pipeline::Dispatch] )

The dispatcher method gets and sets the pipeline dispatcher object that will be used to traverse the pipeline.

cleanups()

Returns the cleanup pipeline. This is a pipeline in and of itself, and all the methods you can call on a pipeline can also be called on this.

cleanup()

Calls the dispatch method on the cleanup pipeline.

segments( [ value ] )

segments gets and sets the value of the pipeline list. At initialization this is set to an array reference.

debug_all( value )

Sets debug( value ) recursively for each segment in this pipeline.

SEE ALSO ^

Pipeline::Segment, Pipeline::Store, Pipeline::Store::Simple Pipeline::Production, Pipeline::Dispatch

AUTHORS ^

  James A. Duncan <jduncan@fotango.com>
  Leon Brocard <acme@astray.com>

COPYRIGHT ^

Copyright 2003 Fotango Ltd. Licensed under the same terms as Perl itself.

syntax highlighting: