module: environment-protocols synopsis: Abstract descriptions of machines that can be connected to in order to do remote debugging. author: Paul Howard Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND ///// // Describes a connection to a machine, on which target applications can // be executed and debugged. // This class is instantiable, with NETWORK-ADDRESS being the single // required init keyword. Clients should always supply a as // the value for this keyword, although the slot is permitted to // hold the value #f for implementational reasons. // Callers of MAKE on this class must be prepared to handle errors // of the following classes: // define open abstract class () constant slot %network-address :: false-or(), required-init-keyword: network-address:; end class; ///// MACHINE-NETWORK-ADDRESS // Returns the network address of a . // Just returns the string "Local" for the environment's host machine, // since its network address can't be determined by the implementation // at the present time. (It also isn't necessary to know it, as far // as functionality is concerned). define function machine-network-address (m :: ) => (a :: ) m.%network-address | "Local" end function; define variable *environment-open-connections* = make(); define method initialize (m :: , #key) => () next-method(); add!(*environment-open-connections*, m); end method; ///// MACHINE-HOSTNAME // Returns the hostname of a . define open generic machine-hostname (m :: ) => (h :: ); define method machine-hostname (m :: ) => (h :: ) "Unknown" end method; ///// MACHINE-CONNECTION-OPEN? // Returns #t if the connection to the is known to be open, // and #f otherwise. // The back-end supplies the only applicable method. define open generic machine-connection-open? (m :: ) => (well? :: ); ///// ENVIRONMENT-HOST-MACHINE // Returns the instance of that corresponds to the machine // on which the environment is actually running. define variable $local-machine = #f; define function environment-host-machine () => (m :: ) unless ($local-machine) $local-machine := make(, network-address: #f) end unless; $local-machine end function; ///// DO-MACHINE-CONNECTIONS // Iterates a user-supplied function over all open s currently // known to the environment. // The function 'f' should have the signature () => (). // The keyword argument INCLUDE-LOCAL? is a boolean flag that determines // whether the environment's host machine is included in the // iteration. define function do-machine-connections (itr :: , #key include-local? = #t) if (include-local?) itr(environment-host-machine()) end if; for (connection in *environment-open-connections*) unless (connection == environment-host-machine()) if (connection.machine-connection-open?) itr(connection) end if end unless end for end function; ///// CLOSE-CONNECTION-TO-MACHINE // Frees up all implementational resources associated with the connection // to a specific , and makes it impossible to subsequently // use the same for further operations of any kind. // Clients of this function must be prepared to handle the following // error classes: // // define open generic close-connection-to-machine (m :: ) => (); // The default method performs front-end housekeeping. The implementation // will arrange to call this method first. define method close-connection-to-machine (m :: ) => () if (m == environment-host-machine()) error(make()) elseif (~m.machine-connection-open?) error(make(, failed-connection: m)) end if end method; ///// // The abstract parent class of all errors that can be signalled // during remote debugging operations. define abstract class () end class; ///// // Signalled when an attempt is made to access a after its // connection has been closed. A connection can only become closed // by using the function CLOSE-CONNECTION-TO-MACHINE. define class () constant slot failed-connection :: , required-init-keyword: failed-connection:; end class; ///// // Signalled when a client calls MAKE on if the underlying // implementation cannot obtain a connection to the specified network // address. define class () constant slot failed-network-address :: , required-init-keyword: network-address:; end class; ///// // Signalled when a client calls MAKE on if the supplied // password does not match the one stored on the remote server. define class () constant slot failed-password :: , required-init-keyword: password:; end class; ///// // Only signalled if a client attempts to call CLOSE-CONNECTION-TO- // MACHINE with the corresponding to the value of // ENVIRONMENT-HOST-MACHINE(). define class () end class;