/src/lib/io/filter/monitored_output_stream.e

http://github.com/tybor/Liberty · 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. --
  4. class 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. inherit
  11. FILTER_OUTPUT_STREAM
  12. rename
  13. connect_to as reconnect_to
  14. end
  15. create {ANY}
  16. connect_to
  17. feature {ANY}
  18. monitor: OUTPUT_STREAM
  19. feature {}
  20. local_can_disconnect: BOOLEAN True
  21. feature {FILTER_OUTPUT_STREAM}
  22. filtered_put_character (c: CHARACTER)
  23. do
  24. stream.filtered_put_character(c)
  25. if monitor.is_connected then
  26. monitor.put_character(c)
  27. end
  28. end
  29. filtered_flush
  30. do
  31. stream.filtered_flush
  32. end
  33. feature {}
  34. connect_to (a_stream: like stream; a_monitor: like monitor)
  35. require
  36. a_stream /= Void
  37. a_monitor /= Void
  38. do
  39. a_stream.set_filter(Current)
  40. stream := a_stream
  41. monitor := a_monitor
  42. ensure
  43. stream = a_stream
  44. monitor = a_monitor
  45. end
  46. invariant
  47. stream /= Void
  48. monitor /= Void
  49. end -- class MONITORED_OUTPUT_STREAM
  50. --
  51. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  52. --
  53. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  54. -- of this software and associated documentation files (the "Software"), to deal
  55. -- in the Software without restriction, including without limitation the rights
  56. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  57. -- copies of the Software, and to permit persons to whom the Software is
  58. -- furnished to do so, subject to the following conditions:
  59. --
  60. -- The above copyright notice and this permission notice shall be included in
  61. -- all copies or substantial portions of the Software.
  62. --
  63. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  64. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  65. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  66. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  67. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  68. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  69. -- THE SOFTWARE.