/* -*- C++ -*- */
// $Id: cubit.idl 45744 2002-07-26 13:10:22Z elliott_c $

interface Cubit
{
  // = TITLE
  //    Defines an interface that encapsulates operations that cube
  //    numbers.
  //
  // = DESCRIPTION
  //    This interface encapsulates operations that cube
  //    octets, shorts, longs, structs and unions.

  oneway void cube_oneway ();
  // Test the basic latency of a nil oneway operation.

  void cube_void ();
  // Test the basic latency of a nil operation.

  octet cube_octet (in octet o);
  // cube an octet

  short cube_short (in short s);
  // cube a short

  long  cube_long (in long l);
  // cube a long

  struct Many
  {
    octet o;            // + 3 bytes padding (normally) ...
    long l;
    short s;            // + 2 bytes padding (normally) ...
  };

  Many cube_struct (in Many values);
  // Cube a struct

  any cube_any(in any value);

  any cube_any_struct(in any value);

  enum discrim
  {
    e_0th,
    e_1st,
    e_2nd,
    e_3rd
  };
  // Enumeration of the different elements in a union.

  union oneof switch (discrim)
    {
      // this is an easy union to interpret; no padding
      // is needed between discriminant and value.
    case e_0th:
      octet o;
    case e_1st:
      short s;
    case e_2nd:
      long l;
    case e_3rd:
      Many cm;

      // default:
      // Many cm;
    };
  // Union of different types.

  oneof cube_union (in oneof values);
  // cube a union.

  typedef sequence<long> long_seq;
  void cube_long_sequence (in long_seq input,
                           out long_seq output);
  // Cube several longs.

  typedef sequence<octet> octet_seq;
  void cube_octet_sequence (in octet_seq input, out octet_seq output);
  // Cube an octet sequence.

  typedef sequence<Many> many_seq;
  void cube_many_sequence (in many_seq input,
                           out many_seq output);
  // Cube several manys.

  oneway void shutdown ();
  // shutdown the application.

  // = The following types provide a torture-test for structs.
  struct RtiPacketHeader
  {
    unsigned long packetLength; // this is probably redundant
    unsigned short federationHandle;
    unsigned long channelHandle;
    unsigned long packetColor;
  };

  struct HandleValuePair
  {
    unsigned short handle;
    octet_seq data;
  };

  enum MessageHeaderTypes
  {
    objectUpdate,
    interaction
    // others omitted
  };

  typedef sequence<HandleValuePair> HandleValuePairSeq;
  struct RtiObjectUpdateMessageHeader
  {
    unsigned long updateLength; // probably redundant
    unsigned long updateTag;
    unsigned long objectHandle;
    double timestamp;
    unsigned long long eventRetractionHandle;
    unsigned short classHandle;
    unsigned short sendingFederateHandle;
    string userTag;
    octet_seq regionData;
    octet transportationHandle;
    octet orderingHandle;
    HandleValuePairSeq messagePayload;
  };

  struct RtiInteractionMessageHeader
  {
    unsigned long updateLength;
    // similar to object update
  };

  union MessageUnion switch(MessageHeaderTypes)
    {
    case objectUpdate:
      RtiObjectUpdateMessageHeader oumh;
    case interaction:
      RtiInteractionMessageHeader imh;
    };

  typedef sequence <MessageUnion> MessageUnionSeq;
  struct RtiPacket
  {
    RtiPacketHeader packetHeader;
    MessageUnionSeq msgs;
  };

  void cube_rti_data (in RtiPacket input,
                      out RtiPacket output);
  
  // A work around for problems with SHMIOP since this test uses
  // this. 
  void ping ();
};

interface Cubit_Factory
{
  // = TITLE
  //    Creates Cubit objects.

  Cubit make_cubit ();
};
