line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Basset::Machine::State; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#Basset::Machine::State, copyright and (c) 2004, 2006 James A Thomason III |
4
|
|
|
|
|
|
|
#Basset::Machine::State is distributed under the terms of the Perl Artistic License. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=pod |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Basset::Machine::State - used to create machine states. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 AUTHOR |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Jim Thomason, jim@jimandkoka.com |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Read the pod on L for more information on machines. Basset::Machine::State |
19
|
|
|
|
|
|
|
is a mostly abstract superclass for states defined to work with machines. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package Some::Machine::Foozle; |
22
|
|
|
|
|
|
|
use base 'Basset::Machine::State'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub main { |
25
|
|
|
|
|
|
|
my $self = shift; |
26
|
|
|
|
|
|
|
my $machine = $self->machine; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#do interesting things. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return $machine->transition('beezle'); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
states live under their machine ('My::Machine' requires 'My::Machine::State1', 'My::Machine::State2', etc.) |
34
|
|
|
|
|
|
|
and are entered via the method ->main, which the machine calls when the state is entered. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$VERSION = '1.01'; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
1221
|
use Basset::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
41
|
|
|
|
|
|
|
our @ISA = Basset::Object->pkg_for_type('object'); |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
44
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item machine |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The machine associated with this state. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->add_attr('machine'); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item main |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
abstract super method. You will need to override this with the code for your state. This |
71
|
|
|
|
|
|
|
implementation only aborts the machine. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub main { |
78
|
0
|
|
|
0
|
1
|
|
return shift->machine->abort("Cannot enter state : no main method", "BMS-01"); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |