Added feature to manipulate easily the chain of filters.

This commit is contained in:
2016-10-21 19:39:42 +02:00
parent dff9007aa6
commit 53f4f64596
2 changed files with 40 additions and 13 deletions

View File

@@ -1,6 +1,5 @@
note
description: "Objects than can pre-process incoming data and post-process outgoing data."
author: "Olivier Ligot"
date: "$Date$"
revision: "$Revision$"
@@ -9,9 +8,23 @@ deferred class
feature -- Access
next: detachable WSF_FILTER
next: detachable WSF_FILTER assign set_next
-- Next filter
last: WSF_FILTER
-- Last filter in the chain following `next'.
do
from
Result := Current
until
not attached Result.next as l_next
loop
Result := l_next
end
ensure
is_closing: Result /= Void and then Result.next = Void
end
feature -- Element change
set_next (a_next: like next)
@@ -22,6 +35,24 @@ feature -- Element change
next_set: next = a_next
end
append (a_filter: attached like next)
-- Append `a_filter' to the `last' filter.
do
last.set_next (a_filter)
end
insert_after (a_filter: attached like next)
-- Append `a_filter' to the `last' filter.
local
f: like next
do
f := next
set_next (a_filter)
if f /= Void then
a_filter.append (f)
end
end
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)

View File

@@ -29,22 +29,19 @@ feature {NONE} -- Initialization
deferred
end
append_filter (a_filter: WSF_FILTER)
-- Append `a_filter' to the end of the `filter' chain.
do
filter.append (a_filter)
end
append_filters (a_filters: ITERABLE [WSF_FILTER])
-- Append collection `a_filters' of filters to the end of the `filter' chain.
local
f: like filter
l_next_filter: detachable like filter
do
from
f := filter
l_next_filter := f.next
until
l_next_filter = Void
loop
f := l_next_filter
l_next_filter := f.next
end
check f_attached_without_next: f /= Void and then f.next = Void end
f := filter.last
across
a_filters as ic
loop
@@ -59,5 +56,4 @@ feature -- Access
filter: WSF_FILTER
-- Filter
end