| Pipeline documentation | Contained in the Pipeline distribution. |
Pipeline::Store - defines the interface for Pipeline store classes
use Pipeline::Store; # interface class, does very little
Pipeline::Store provides a constructor and a generic get/set interface
for any class implementing a store to sit on a Pipeline. Pipeline stores
are singletons inside the dispatch process. Ie, if you attempt to construct
a pipeline store in between the dispatch method being called on a pipeline
segment and having the method return a value then you will get the same
store as that segments store() method.
The Pipeline class inherits from the Pipeline::Base class and therefore
also has any additional methods that its superclass may have.
The new method constructs a new Pipeline::Store object and calls
the init method. If the transaction flat is set then it returns
the current store singleton.
The init method is called by new() to do any construction-time initialization
of an object.
Sets the transaction flag, which makes the store object that this is called on a singleton until end_transaction is called.
Clears the transaction flag, which lets you construct new pipeline stores.
The store method gets or sets the store in a Pipeline::Store object. Unless init
is changed the store is set at construction time to a hash reference.
Does nothing in Pipeline::Store - exists as a placeholder for subclasses.
Does nothing in Pipeline::Store - exists as a placeholder for subclasses.
Pipeline, Pipeline::Store::Simple, Pipeline::Store::ISA
Copyright 2003 Fotango Ltd. All Rights Reserved
This module is released under the same license as Perl itself.
James A. Duncan <jduncan@fotango.com>
| Pipeline documentation | Contained in the Pipeline distribution. |
package Pipeline::Store; use strict; use warnings::register; use Pipeline::Base; use base qw( Pipeline::Base ); our $VERSION = "3.12"; sub new { my $class = shift; if ( $class->in_transaction() ) { return $::TRANSACTION_STORE; } else { my $store = $class->SUPER::new( @_ ); } } sub start_transaction { my $self = shift; $::TRANSACTION = 1; $::TRANSACTION_STORE = $self; } sub in_transaction { my $self = shift; $::TRANSACTION; } sub end_transaction { my $self = shift; if ($self->in_transaction && $self == $::TRANSACTION_STORE) { $::TRANSACTION = 0; } else { $self->emit("cannot clear transaction unless it is called by the same object"); } } sub init { my $self = shift; if ($self->SUPER::init( @_ ) && ref($self) ne 'Pipeline::Store') { return 1; } else { return 0; } } sub set { throw Pipeline::Error::Abstract; } sub get { throw Pipeline::Error::Abstract; } sub DESTROY { my $self = shift; $self->end_transaction; } 1;