PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

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