// File: ETF.idl

// Taken from OMG document mars/2003-02-01, Extensible Transport Framework,
// slightly adapted, AS

#ifndef _ETF_IDL_
#define _ETF_IDL_

# pragma prefix "omg.org"
# include "orb.idl"
# include "IOP.idl"
# include "GIOP.idl"
# include "RTCORBA.idl"
# include "TimeBase.idl"
# ifdef _NO_LOCAL_
# define local
# endif

module ETF
{
  typedef sequence<octet> Buffer;
  typedef sequence<octet> ObjectKey;

  local interface Profile
  {
    void marshal(inout IOP::TaggedProfile tagged_profile,
                 inout IOP::TaggedComponentSeq components);
    // marshal() must set data.profile_data.length()
    // to the index of the last octet marshalled + 1
    unsigned long hash();
    Profile copy();
    boolean is_match(in Profile prof);
    readonly attribute GIOP::Version version;

    // proposed additions to ETF standard below this line

    void set_object_key (in ObjectKey key);
    ObjectKey get_object_key();

    readonly attribute long tag;
  };

  local interface Connection
  {
    void write(in boolean is_first,
               in boolean is_last,
               in Buffer data,
               in unsigned long offset,
               in unsigned long length,
               in TimeBase::TimeT time_out);
    void read(inout Buffer data,
              in unsigned long offset,
              in unsigned long min_length,
              in unsigned long max_length,
              in TimeBase::TimeT time_out);
    // transport needs to set data.length() to
    // offset + number of bytes actually read
    void flush();
    void connect(in Profile server_profile,
                 in TimeBase::TimeT time_out);
    void close();
    boolean is_connected();
    Profile get_server_profile();
    boolean is_data_available();
    boolean wait_next_data(in TimeBase::TimeT time_out);
    readonly attribute boolean supports_callback;
    readonly attribute boolean use_handle_time_out;
  };

  local interface Handle
  {
    boolean add_input(in Connection conn);
    // Tells ORB that a new connection has come in
    // ORB returns false if it rejects new connection
    void signal_data_available(in Connection conn);
    void closed_by_peer (in Connection conn);
  };

  local interface Listener
  {
    void set_handle(in Handle up);
    Connection accept();
    void listen();
    void destroy();
    void completed_data(in Connection conn) ;
    readonly attribute Profile endpoint;
  };

  local interface Factories
  {
    Connection create_connection (in RTCORBA::ProtocolProperties props);

    Listener create_listener (in RTCORBA::ProtocolProperties props,
                              in unsigned long stacksize,
                              in RTCORBA::Priority base_priority);

    Profile demarshal_profile (inout IOP::TaggedProfile tagged_profile,
                               out IOP::TaggedComponentSeq components);

	// JacORB addition to ETF draft
    Profile decode_corbaloc (in string corbaloc);

    readonly attribute IOP::ProfileId profile_tag;
  };

  // Optional zero copy connection interface

  local interface BufferList
  {
    unsigned long add_buffer(in unsigned long size, inout Buffer buf);
    // Adds an additional buffer to the list.
    // Returns the zero-origin index of the added buffer.
    // buf.length() should be set to the actual size of the
    // memory allocated whether more or less than size.
    readonly attribute unsigned long num_buffers;
    void get_buffer(in unsigned long index, inout Buffer buf);
    // populates the buf argument with the pointer to data
    void release_buffers();
  };

  local interface ConnectionZeroCopy : Connection
  {
    BufferList create_buffer_list();
    void write_zc(inout BufferList data,
                  in TimeBase::TimeT time_out);
    void read_zc(inout BufferList data,
                 in unsigned long min_length,
                 in TimeBase::TimeT time_out);
  };
};
#endif // _ETF_IDL_
