Added feature to manipulate easily the chain of filters.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
note
|
note
|
||||||
description: "Objects than can pre-process incoming data and post-process outgoing data."
|
description: "Objects than can pre-process incoming data and post-process outgoing data."
|
||||||
author: "Olivier Ligot"
|
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
@@ -9,9 +8,23 @@ deferred class
|
|||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
next: detachable WSF_FILTER
|
next: detachable WSF_FILTER assign set_next
|
||||||
-- Next filter
|
-- 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
|
feature -- Element change
|
||||||
|
|
||||||
set_next (a_next: like next)
|
set_next (a_next: like next)
|
||||||
@@ -22,6 +35,24 @@ feature -- Element change
|
|||||||
next_set: next = a_next
|
next_set: next = a_next
|
||||||
end
|
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
|
feature -- Basic operations
|
||||||
|
|
||||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
|||||||
@@ -29,22 +29,19 @@ feature {NONE} -- Initialization
|
|||||||
deferred
|
deferred
|
||||||
end
|
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_filters (a_filters: ITERABLE [WSF_FILTER])
|
||||||
-- Append collection `a_filters' of filters to the end of the `filter' chain.
|
-- Append collection `a_filters' of filters to the end of the `filter' chain.
|
||||||
local
|
local
|
||||||
f: like filter
|
f: like filter
|
||||||
l_next_filter: detachable like filter
|
l_next_filter: detachable like filter
|
||||||
do
|
do
|
||||||
from
|
f := filter.last
|
||||||
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
|
|
||||||
across
|
across
|
||||||
a_filters as ic
|
a_filters as ic
|
||||||
loop
|
loop
|
||||||
@@ -59,5 +56,4 @@ feature -- Access
|
|||||||
filter: WSF_FILTER
|
filter: WSF_FILTER
|
||||||
-- Filter
|
-- Filter
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user