| 1 | package Zing::Logic::Simple; | ||
| 2 | |||
| 3 | use 5.014; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | use registry 'Zing::Types'; | ||
| 9 | use routines; | ||
| 10 | |||
| 11 | use Data::Object::Class; | ||
| 12 | |||
| 13 | extends 'Zing::Logic'; | ||
| 14 | |||
| 15 | use Zing::Flow; | ||
| 16 | |||
| 17 | our $VERSION = '0.26'; # VERSION | ||
| 18 | |||
| 19 | # METHODS | ||
| 20 | |||
| 21 | method flow() { | ||
| 22 | my $step_0 = Zing::Flow->new( | ||
| 23 | name => 'on_register', | ||
| 24 | code => fun($step, $loop) { $self->trace('on_register')->($self) } | ||
| 25 | ); | ||
| 26 | my $step_1 = $step_0->next(Zing::Flow->new( | ||
| 27 | name => 'on_perform', | ||
| 28 | code => fun($step, $loop) { $self->trace('on_perform')->($self) } | ||
| 29 | )); | ||
| 30 | my $step_2 = $step_1->next(Zing::Flow->new( | ||
| 31 | name => 'on_reset', | ||
| 32 | code => fun($step, $loop) { $self->trace('on_reset')->($self) } | ||
| 33 | )); | ||
| 34 | |||
| 35 | $step_0 | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; | ||
| 39 | |||
| 40 | =encoding utf8 | ||
| 41 | |||
| 42 | =head1 NAME | ||
| 43 | |||
| 44 | Zing::Logic::Simple - Simple Logic | ||
| 45 | |||
| 46 | =cut | ||
| 47 | |||
| 48 | =head1 ABSTRACT | ||
| 49 | |||
| 50 | Simple Process Logic Chain | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | =head1 SYNOPSIS | ||
| 55 | |||
| 56 | package Simple; | ||
| 57 | |||
| 58 | use parent 'Zing::Simple'; | ||
| 59 | |||
| 60 | package main; | ||
| 61 | |||
| 62 | use Zing::Logic::Simple; | ||
| 63 | |||
| 64 | my $logic = Zing::Logic::Simple->new(process => Simple->new); | ||
| 65 | |||
| 66 | # $logic->execute; | ||
| 67 | |||
| 68 | =cut | ||
| 69 | |||
| 70 | =head1 DESCRIPTION | ||
| 71 | |||
| 72 | This package provides the logic (or logic chain) to be executed by the simple | ||
| 73 | process event-loop. | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | =head1 INHERITS | ||
| 78 | |||
| 79 | This package inherits behaviors from: | ||
| 80 | |||
| 81 | L<Zing::Logic> | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | =head1 LIBRARIES | ||
| 86 | |||
| 87 | This package uses type constraints from: | ||
| 88 | |||
| 89 | L<Zing::Types> | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | =head1 ATTRIBUTES | ||
| 94 | |||
| 95 | This package has the following attributes: | ||
| 96 | |||
| 97 | =cut | ||
| 98 | |||
| 99 | =head2 interupt | ||
| 100 | |||
| 101 | interupt(Interupt) | ||
| 102 | |||
| 103 | This attribute is read-only, accepts C<(Interupt)> values, and is optional. | ||
| 104 | |||
| 105 | =cut | ||
| 106 | |||
| 107 | =head2 on_perform | ||
| 108 | |||
| 109 | on_perform(CodeRef) | ||
| 110 | |||
| 111 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||
| 112 | |||
| 113 | =cut | ||
| 114 | |||
| 115 | =head2 on_receive | ||
| 116 | |||
| 117 | on_receive(CodeRef) | ||
| 118 | |||
| 119 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||
| 120 | |||
| 121 | =cut | ||
| 122 | |||
| 123 | =head2 on_register | ||
| 124 | |||
| 125 | on_register(CodeRef) | ||
| 126 | |||
| 127 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||
| 128 | |||
| 129 | =cut | ||
| 130 | |||
| 131 | =head2 on_reset | ||
| 132 | |||
| 133 | on_reset(CodeRef) | ||
| 134 | |||
| 135 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||
| 136 | |||
| 137 | =cut | ||
| 138 | |||
| 139 | =head2 on_suicide | ||
| 140 | |||
| 141 | on_suicide(CodeRef) | ||
| 142 | |||
| 143 | This attribute is read-only, accepts C<(CodeRef)> values, and is optional. | ||
| 144 | |||
| 145 | =cut | ||
| 146 | |||
| 147 | =head2 process | ||
| 148 | |||
| 149 | process(Process) | ||
| 150 | |||
| 151 | This attribute is read-only, accepts C<(Process)> values, and is required. | ||
| 152 | |||
| 153 | =cut | ||
| 154 | |||
| 155 | =head1 METHODS | ||
| 156 | |||
| 157 | This package implements the following methods: | ||
| 158 | |||
| 159 | =cut | ||
| 160 | |||
| 161 | =head2 flow | ||
| 162 | |||
| 163 | flow() : Flow | ||
| 164 | |||
| 165 | The flow method builds and returns the logic flow for the process event-loop. | ||
| 166 | |||
| 167 | =over 4 | ||
| 168 | |||
| 169 | =item flow example #1 | ||
| 170 | |||
| 171 | # given: synopsis | ||
| 172 | |||
| 173 | my $flow = $logic->flow; | ||
| 174 | |||
| 175 | =back | ||
| 176 | |||
| 177 | =cut | ||
| 178 | |||
| 179 | =head2 signals | ||
| 180 | |||
| 181 | signals() : HashRef | ||
| 182 | |||
| 183 | The signals method builds and returns the process signal handlers. | ||
| 184 | |||
| 185 | =over 4 | ||
| 186 | |||
| 187 | =item signals example #1 | ||
| 188 | |||
| 189 | # given: synopsis | ||
| 190 | |||
| 191 | my $signals = $logic->signals; | ||
| 192 | |||
| 193 | =back | ||
| 194 | |||
| 195 | =cut | ||
| 196 | |||
| 197 | =head1 AUTHOR | ||
| 198 | |||
| 199 | Al Newkirk, C<awncorp@cpan.org> | ||
| 200 | |||
| 201 | =head1 LICENSE | ||
| 202 | |||
| 203 | Copyright (C) 2011-2019, Al Newkirk, et al. | ||
| 204 | |||
| 205 | This is free software; you can redistribute it and/or modify it under the terms | ||
| 206 | of the The Apache License, Version 2.0, as elucidated in the L<"license | ||
| 207 | file"|https://github.com/iamalnewkirk/zing/blob/master/LICENSE>. | ||
| 208 | |||
| 209 | =head1 PROJECT | ||
| 210 | |||
| 211 | L<Wiki|https://github.com/iamalnewkirk/zing/wiki> | ||
| 212 | |||
| 213 | L<Project|https://github.com/iamalnewkirk/zing> | ||
| 214 | |||
| 215 | L<Initiatives|https://github.com/iamalnewkirk/zing/projects> | ||
| 216 | |||
| 217 | L<Milestones|https://github.com/iamalnewkirk/zing/milestones> | ||
| 218 | |||
| 219 | L<Contributing|https://github.com/iamalnewkirk/zing/blob/master/CONTRIBUTE.md> | ||
| 220 | |||
| 221 | L<Issues|https://github.com/iamalnewkirk/zing/issues> | ||
| 222 | |||
| 223 | =cut |