lib/openwfe/expressions/fe_sequence.rb in openwferu-0.9.15 vs lib/openwfe/expressions/fe_sequence.rb in openwferu-0.9.16
- old
+ new
@@ -28,12 +28,10 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#++
#
-# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
-#
#
# "made in Japan"
#
# John Mettraux at openwfe.org
@@ -55,64 +53,59 @@
#
class SequenceExpression < FlowExpression
names :sequence
- attr_accessor \
- :current_child_id
-
def apply (workitem)
- @current_child_id = -1
+ #store_itself
+ #
+ # remove that !
reply workitem
end
def reply (workitem)
- cfei = get_to_next_child()
+ cfei = next_child workitem.fei
- unless cfei
- reply_to_parent workitem
- return
- end
+ return reply_to_parent(workitem) \
+ unless cfei
#ldebug do
# "reply() self : \n#{self.to_s}\n" +
# "reply() next is #{@current_child_id} : #{cfei.to_debug_s}"
#end
- store_itself()
-
get_expression_pool.apply cfei, workitem
end
protected
- def get_to_next_child ()
+ #
+ # Returns the flowExpressionId of the next child to apply, or
+ # nil if the sequence is over.
+ #
+ def next_child (current_fei)
- #return nil if @children.length < 1
+ next_id = if (current_fei == self.fei)
+ 0
+ else
+ current_fei.child_id.to_i + 1
+ end
- @current_child_id += 1
+ loop do
- return nil if @current_child_id >= @children.length
+ break if next_id >= @children.length
- #ldebug do
- # "get_to_next_child() " +
- # "len: #{@children.length} / id: #{@current_child_id}"
- #end
+ child = @children[next_id]
+ return child if child.is_a?(FlowExpressionId)
- @children[@current_child_id..-1].each do |c|
-
- return c if c.kind_of? OpenWFE::FlowExpressionId
-
- @current_child_id += 1
+ next_id += 1
end
- nil
- #
- # did not find any child expression
+ nil
end
end
end