/src/lib/io/filter/monitored_output_stream.e
Specman e | 78 lines | 41 code | 9 blank | 28 comment | 1 complexity | 2c1b680de0e8a15c83864edc67d9708f MD5 | raw file
1-- This file is part of a Liberty Eiffel library. 2-- See the full copyright at the end. 3-- 4class MONITORED_OUTPUT_STREAM 5 -- 6 -- An output stream monitor. Monitored data goes to another output stream. 7 -- 8 -- See also MONITORED_INPUT_STREAM 9 -- 10 11inherit 12 FILTER_OUTPUT_STREAM 13 rename 14 connect_to as reconnect_to 15 end 16 17create {ANY} 18 connect_to 19 20feature {ANY} 21 monitor: OUTPUT_STREAM 22 23feature {} 24 local_can_disconnect: BOOLEAN True 25 26feature {FILTER_OUTPUT_STREAM} 27 filtered_put_character (c: CHARACTER) 28 do 29 stream.filtered_put_character(c) 30 if monitor.is_connected then 31 monitor.put_character(c) 32 end 33 end 34 35 filtered_flush 36 do 37 stream.filtered_flush 38 end 39 40feature {} 41 connect_to (a_stream: like stream; a_monitor: like monitor) 42 require 43 a_stream /= Void 44 a_monitor /= Void 45 do 46 a_stream.set_filter(Current) 47 stream := a_stream 48 monitor := a_monitor 49 ensure 50 stream = a_stream 51 monitor = a_monitor 52 end 53 54invariant 55 stream /= Void 56 monitor /= Void 57 58end -- class MONITORED_OUTPUT_STREAM 59-- 60-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file. 61-- 62-- Permission is hereby granted, free of charge, to any person obtaining a copy 63-- of this software and associated documentation files (the "Software"), to deal 64-- in the Software without restriction, including without limitation the rights 65-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 66-- copies of the Software, and to permit persons to whom the Software is 67-- furnished to do so, subject to the following conditions: 68-- 69-- The above copyright notice and this permission notice shall be included in 70-- all copies or substantial portions of the Software. 71-- 72-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 73-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 74-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 75-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 76-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 77-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 78-- THE SOFTWARE.