note description: "[ Base implementation for all connection streams, both reading and writing. ]" legal : "See notice at end of class." status : "See notice at end of class."; author : "Paul Bates (paul.a.bates@gmail.com)" date : "$Date$" revision: "$Revision$" deferred class PRT_STREAM inherit C_OPERABLE export {NONE} all {ANY} is_successful, last_error_code end USABLE_I feature {NONE} -- Initialization make (a_connection: PRT_CONNECTION) -- Initializes a port stream using a port connection. -- -- `a_connection': A port connection. require a_connection_attached: attached a_connection a_connection_is_interface_usable: a_connection.is_interface_usable do address := a_connection.address ensure address_set: address = a_connection.address end make_with_offset (a_connection: PRT_CONNECTION; a_offset: like base_offset) -- Initializes a port stream using a port connection. -- -- `a_connection': A port connection. -- `a_offset': An offset to apply to the port connection. require a_connection_attached: attached a_connection a_connection_is_interface_usable: a_connection.is_interface_usable a_offset_small_enough: a_connection.address + a_offset <= {NATURAL_16}.max_value do base_offset := a_offset make (a_connection) ensure address_set: address = a_connection.address address_offset_set: base_offset = a_offset end feature -- Access address: NATURAL_32 -- The actual port address. base_offset: NATURAL_32 -- A port address base offset. feature -- Query port_address: NATURAL_16 -- Calculate port address, taking `base_offset' into account -- -- `Result': The complete port address required for an operation on `connection' do Result := (address + base_offset).to_natural_16 ensure result_positive: Result > 0 end invariant address_positive: address > 0 addresses_small_enough: address + base_offset <= {NATURAL_16}.max_value end