/src/lib/io/internal/filterable.e

http://github.com/tybor/Liberty · Specman e · 114 lines · 62 code · 13 blank · 39 comment · 0 complexity · 531d6873db7f71ef46768039802b22f0 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. deferred class FILTERABLE
  5. --
  6. -- The ability to be filtered (typically a stream of characters).
  7. --
  8. insert
  9. ANY
  10. feature {ANY}
  11. is_connected: BOOLEAN
  12. -- True if the stream is connected. Only in that case can data be transferred via this stream.
  13. deferred
  14. end
  15. disconnect
  16. -- Try to disconnect the stream. Note that it *does not* ensure that the stream will effectively be
  17. -- disconnected (some terminal streams, for instance, are always connected) but the feature can be
  18. -- used to "shake off" filters.
  19. require
  20. is_connected
  21. can_disconnect
  22. deferred
  23. ensure
  24. not is_filtered
  25. end
  26. is_filtered: BOOLEAN
  27. -- True if some filter is using this stream as backend. Use that filter instead.
  28. do
  29. Result := filter /= Void
  30. end
  31. detach
  32. -- Shake off the filter.
  33. deferred
  34. ensure
  35. not is_filtered
  36. end
  37. can_disconnect: BOOLEAN
  38. -- True if the stream can be safely disconnected (without data loss, etc.)
  39. require
  40. is_connected
  41. deferred
  42. end
  43. feature {FILTER}
  44. set_filter (a_filter: like filter)
  45. -- Used by the filter itself to get attached
  46. require
  47. a_filter /= Void
  48. do
  49. filter := a_filter
  50. ensure
  51. filter = a_filter
  52. end
  53. filter: FILTER
  54. -- The filter that uses this stream as backend
  55. filtered_descriptor: INTEGER
  56. -- Find the descriptor of the terminal stream... Filters do not have descriptors of their own
  57. require
  58. is_connected
  59. filtered_has_descriptor
  60. deferred
  61. end
  62. filtered_has_descriptor: BOOLEAN
  63. -- True if the underlying terminal stream has a descriptor
  64. require
  65. is_connected
  66. deferred
  67. end
  68. filtered_stream_pointer: POINTER
  69. -- Find the pointer of the terminal stream... Filters do not have pointers of their own
  70. require
  71. is_connected
  72. filtered_has_stream_pointer
  73. deferred
  74. end
  75. filtered_has_stream_pointer: BOOLEAN
  76. -- True if the underlying terminal stream has a pointer
  77. require
  78. is_connected
  79. deferred
  80. end
  81. end -- class FILTERABLE
  82. --
  83. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  84. --
  85. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  86. -- of this software and associated documentation files (the "Software"), to deal
  87. -- in the Software without restriction, including without limitation the rights
  88. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  89. -- copies of the Software, and to permit persons to whom the Software is
  90. -- furnished to do so, subject to the following conditions:
  91. --
  92. -- The above copyright notice and this permission notice shall be included in
  93. -- all copies or substantial portions of the Software.
  94. --
  95. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  96. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  97. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  98. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  99. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  100. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  101. -- THE SOFTWARE.