Specification of package Tgx.Ios







 ========================================================================= --
 ===                                                                   === --
 ===                 Top Graph'X CORBA Implementation                  === --
 ===                                                                   === --
 ===                 Copyright (c) 1996, Top Graph'X.                  === --
 ===                                                                   === --
 ===                     --- Copyright Notice ---                      === --
 ===                                                                   === --
 ===    This software is protected as an unpublished work under the    === --
 ===     Copyright Act of 1976.  All rights reserved.  Top Graph'X.    === --
 ===                                                                   === --
 ========================================================================= --

 modif{0} 16/01/02 (JM) : ajout pour MIOP 

with System ;
with Tgx.Atomic ;
with Ada.Unchecked_Deallocation ;
package Tgx.Ios is
   Connection_Lost : exception ;
   
 modif{0} 16/01/02 (JM) : ajout pour MIOP 
   Bad_Service     : exception ;
 end_{0}

   Connection_Retries    : Natural := 3 ;
   Connection_Timeout    : Duration := 1.0 ;
   Connection_Timeout_S  : Natural := 1 ;
   Connection_Timeout_Us : Natural := 0 ;

   type Io_Channel ;
   type Io_Channel_Access is access all Io_Channel'class ;

   type Io_Flag is (Input_Ready, Output_Ready, Down) ;
   subtype Active_Io_Flag is Io_Flag range Input_Ready .. Output_Ready ;

   type Io_Status is array (Io_Flag) of Boolean ;
   Initial_Status : constant Io_Status := Io_Status'
      (Input_Ready => False, Output_Ready => False, Down => True) ;

   type Multiple_Io_Channel ;

   type Multiple_Io_Access is access all Multiple_Io_Channel'class ;

   
   protected type Io_Semaphore is
      pragma Priority (System.Priority'last);

       Owner must be set once at channel creation
       Further calls will have no effect
      procedure Set_Owner (Channel : in Io_Channel_Access) ;

       To indicate the current operating state of a channel
      procedure Set_State_Flag ( Flag  : in Io_Flag ;
                                 Value : in Boolean := True) ;
      procedure Set_State (State : in Io_Status) ;

       To allow blocking operations at the task level
      entry Ready_For_Input ;
      entry Ready_For_Output ;
   private
      Owner  : Io_Channel_Access ;  back pointer to the guarded channel
      Status : Io_Status := Initial_Status ;  current status
   end Io_Semaphore ;

   type Read_Checker is access procedure (Channel : in Io_Channel_Access) ;

   
   { Main Class : Io_Channel
    The semaphore is visible to allow asynchronous operations
   type Io_Channel is abstract tagged limited
   record
      Group      : Multiple_Io_Access ;  Multiplexed group to which it belongs
      Status     : Io_Status := Initial_Status ;  current status
      No_Guard   : Boolean := False ;
      Is_Server  : Boolean := False ;
      Is_Oneway  : Boolean := False ;
      Is_Reader  : Boolean := False ;
      Nb_Read    : aliased Tgx.Atomic.Count := 0 ;
      Read_Check : Read_Checker ;
      Guardian   : Io_Semaphore ;
   end record ;

   type Io_Channel_Array is array (Positive range <>) of Io_Channel_Access ;
   type Io_Channel_Table is access all Io_Channel_Array ;

   procedure Open (This : access Io_Channel) is abstract;

   procedure Close (This : access Io_Channel) is abstract ;

    To know the current operating state of a channel
   function State (This : access Io_Channel) return Io_Status ;

   function Is_Readable (This : access Io_Channel) return Boolean ;

   function Is_Writable (This : access Io_Channel) return Boolean ;

   function Is_Alive (This : access Io_Channel) return Boolean ;
   } Main Class : Io_Channel
   
    Derived Classes
   
   { Io_Server
   type Io_Server is abstract new Io_Channel with null record ;
   type Io_Server_Access is access all Io_Server'class ;
    A server is ready for input when a connection request is pending

   { Io_Connection
   type Io_Connection is abstract new Io_Channel with
   record
      Server : Io_Server_Access ;
   end record ;
   type Io_Connection_Access is access all Io_Connection'class ;

   procedure Read ( This   : access Io_Connection ;
                    Buffer : in System.Address ;
                    Number : in out Natural ) is abstract ;

   procedure Write ( This   : access Io_Connection ;
                     Buffer : in System.Address ;
                     Number : in Natural ) is abstract ;

   function Bytes_Per_Io_Unit (This : access Io_Connection)
      return Natural is abstract ;

   function Amount_Readable (This : access Io_Connection)
      return Natural is abstract ;

    Accept a new connection on the given server
    Set No_Guard to true if reading is not multiplexed (eg use blocking read)
   procedure New_Connection ( Server   : access Io_Server ;
                              No_Guard : in Boolean := True;
                              Result   : in out Io_Connection_Access) is abstract ;
   
    Returns the URL indicating the sending client
   function Url (Client   : access Io_Connection)
      return Standard.String is abstract ;

    Returns the URL used by clients to connect to server
   function Url (Server   : access Io_Server)
      return Standard.String is abstract ;
    } Io_Server and Io_Connection


    { Multiple_Io_Channel
    Multiple_Io_Channel is designed for multiplexed ios
   type Io_Channel_Pair is array (Active_Io_Flag) of Positive ;
   type Multiple_Io_Channel is new Io_Channel with
   record
      Last     : Io_Channel_Pair := (1, 1) ;
      Members  : Io_Channel_Table ;
      Used     : Natural := 0 ;
   end record ;

   procedure Open (This : access Multiple_Io_Channel) ;

   procedure Close (This : access Multiple_Io_Channel) ;

    Add a member (server or connection) to the given multiplexed group
   procedure Add ( This   : access Multiple_Io_Channel ;
                   Member : in Io_Channel_Access ) ;

    Remove a member (server or connection) from the given multiplexed group
   procedure Remove ( This   : access Multiple_Io_Channel ;
                      Member : in Io_Channel_Access ) ;

    Return the next ready (or down) member
   function Next_Ready ( This : access Multiple_Io_Channel ;
                         Flag : in Active_Io_Flag) return Io_Channel_Access ;

   procedure Free is new Ada.Unchecked_Deallocation
      (Object => Io_Channel'class, Name => Io_Channel_Access) ;
   } Multiple_Io_Channel

   
    modif{0} : ajout pour MIOP
   
   { Io_Datagram_Emission class
   type Io_Datagram_Emission  is abstract new Io_Connection with null record ;
   type Io_Datagram_Emission_access is access all Io_Datagram_Emission'class ;

    open a connection, close a connection, write : inherited   

    read a stream : (implementation raises an exception)
   procedure Read ( This   : access Io_Datagram_Emission ;
                    Buffer : in System.Address ;
                    Number : in out Natural ) ;

    Bytes_Per_Io_Unit : (implementation raises an exception)
   function Bytes_Per_Io_Unit (This : access Io_Datagram_Emission) return Natural ;

    Amount_Readable : (implementation raises an exception)
   function Amount_Readable (This : access Io_Datagram_Emission) return Natural ;
   
   } Io_Datagram_Emission class
   
   { Io_Datagram_Reception class
   type Io_Datagram_Reception  is abstract new Io_Connection with null record ;
   type Io_Datagram_Reception_access is access all Io_Datagram_Reception'class ;

    open a connection, close a connection, read : inherited   

    write a stream : (implementation raises an exception)
   procedure Write ( This   : access Io_Datagram_Reception ;
                     Buffer : in System.Address ;
                     Number : in Natural ) ;
   } Io_Datagram_Reception class
   
    end_{0}

   type String_Pointer is access all Standard.String ;
   procedure Free is new Ada.Unchecked_Deallocation
      (Object =>  Standard.String, Name => String_Pointer ) ;
   
end Tgx.Ios ;



List of definition uses










This page was generated by PrismTech's ada2html on Friday Mai 12 2006 16:18