Acme-FSM

 view release on metacpan or  search on metacpan

lib/FSM.pm  view on Meta::CPAN

Special flag associated with next I<{state}> in a I<[turn]>
(covered in details in L<B<process()>|/process()> method description).
B<(note)> It may be applied to a I<[turn]> of I<{fst}> or I<{state}>.

=item blackboard

Shamelesly stolen from B<DMA::FSM>.
Originally, it meant some opaque HASH passed around in B<DMA::FSM::FSM()>
where
user-code could store it's own ideas and such.
Now it's an object blessed into B<Acme::FSM>
(for user-code still, I<{fsm}> has nothing to do with it).

=item entry

Layout of state records (see below) isn't particularly complicated.
However it's far from being uniform.
I<entry> is a placeholder name for any component of (unspecified) state record
when any semantics is irrelevant.
See also I<[turn]> and B<switch()> below.

lib/FSM.pm  view on Meta::CPAN

=cut

my @options = qw| diag_level namespace source dumper |;
sub connect     {
    my( $self, $opts ) = ( shift @_, shift @_ );
    ref $opts eq q|HASH|                                      or croak sprintf
      q|[connect]: {options} HASH is required, got (%s) instead|, ref $opts;
    my( $trailer, $leader );
    if( ref $self eq '' )           {
        $trailer = ref $_[0] eq q|HASH|;
        $self = bless { _ => { fst => $trailer ? shift @_ : { @_ }}}, $self;
        $leader = q|clean init with| }
    else                            {
        $trailer = @_;
        $self = bless { _ => { %{$self->{_}} }}, ref $self;
        $leader = q|stealing|        }
    $self->{_}{$_} = delete $opts->{$_} // $self->{_}{$_}    foreach @options;
    $self->{_}{diag_level} //= 1;
    $self->diag( 3, q|%s (%i) items in FST|,
      $leader, scalar keys %{$self->{_}{fst}} );

    $self->carp( qq|($_): unknown option, ignored| )      foreach keys %$opts;
    $self->carp( q|(source): unset| )       unless defined $self->{_}{source};
    $trailer = ref $_[0] eq q|HASH| ? keys %{$_[0]} : @_          if $trailer;
    $self->carp( qq|ignoring ($trailer) FST items in trailer| )   if $trailer;

lib/FSM.pm  view on Meta::CPAN

        { namespace => 'Secret::Namespace' },
        alpha => {
            switch => 'bravo_sn'
        }
    );

Separate class:

    package Secret::Class;

    sub new { bless { }, shift }
    sub bravo_sc {
        shift;
        shift % 42, ''
    }

    package Regular::Class;
    use Secret::Class;
    use Acme::FSM;
    
    my $not_bb = Secret::Class->new;

t/base/query.t  view on Meta::CPAN

use parent qw| Acme::FSM |;

sub shift_shift       {
    my $bb          = shift @_;
    $bb->{bull}     = shift @main::flags;
    $bb->{shambles} = shift @_                                          if @_;
    shift @main::flags }

package t::TestSuite::havoc;

sub new { bless { }, shift @_ }

sub shift_shift       {
    my $bb       = shift @_;
    $bb->{mess}  = shift @main::flags;
    $bb->{slops} = shift @_                                             if @_;
    shift @main::flags }

package main;
use version 0.77; our $VERSION = version->declare( v2.3.2 );

t/base/query_dumper.t  view on Meta::CPAN

use parent qw| Acme::FSM |;

sub shift_shift       {
    my $bb        = shift @_;
    $bb->{matrixone}  = shift @main::flags;
    $bb->{CSSC} = shift @_                                              if @_;
    shift @main::flags }

package t::TestSuite::dumper;

sub new { bless { }, shift @_ }

sub shift_shift       {
    my $bb           = shift @_;
    $bb->{aegis} = shift @main::flags;
    $bb->{slash_briefcase}   = shift @_                                 if @_;
    shift @main::flags }

package main;
use version 0.77; our $VERSION = version->declare( v2.3.2 );

t/base/query_source.t  view on Meta::CPAN

use parent qw| Acme::FSM |;

sub shift_shift       {
    my $bb        = shift @_;
    $bb->{Ashevill_pm}  = shift @main::flags;
    $bb->{Anchorage_pm} = shift @_                                      if @_;
    shift @main::flags }

package t::TestSuite::source;

sub new { bless { }, shift @_ }

sub shift_shift       {
    my $bb           = shift @_;
    $bb->{Torino_pm} = shift @main::flags;
    $bb->{Lund_pm}   = shift @_                                         if @_;
    shift @main::flags }

package main;
use version 0.77; our $VERSION = version->declare( v2.3.2 );

t/base/query_switch.t  view on Meta::CPAN

use parent qw| Acme::FSM |;

sub push_push                    {
    my $bb        = shift @_;
    $bb->{MKS}    = shift @main::flags;
    $bb->{CS_RCS} = shift @_                                            if @_;
    return !0, shift @main::flags }

package t::TestSuite::switch;

sub new { bless { }, shift @_ }

sub push_push                    {
    my $bb          = shift @_;
    $bb->{jedi_vcs} = shift @main::flags;
    $bb->{gat}      = shift @_                                          if @_;
    return !0, shift @main::flags }

package main;
use version 0.77; our $VERSION = version->declare( v2.3.4 );



( run in 1.001 second using v1.01-cache-2.11-cpan-de7293f3b23 )