
//=============================================================================
/**
 *  @file    param_test.idl
 *
 *  $Id: param_test.idl 93679 2011-03-29 12:42:56Z johnnyw $
 *
 *  This IDL description is used to test all the parameter passing modes (in,
 *  inout, out, and return) for a number of IDL data types. The goal is to
 *  verify the correctness of the generated stubs and skeletons, and the
 *  the marshaling engine of TAO.
 *
 *  @author Aniruddha Gokhale
 */
//=============================================================================


#include <orb.idl>
#include "tao/AnyTypeCode/AnySeq.pidl"

interface Coffee
{
  struct Desc
  {
    string name;
  };

  attribute Desc description; // provides us the coffee object type
};

//typedef sequence<Coffee> ObjSeq;

interface Param_Test
{
  // Add exceptions to each

  // primitive types
  short test_short (in short s1,
                    inout short s2,
                    out short s3);

  // NOTE:  use unsigned long long instead of long long, because
  // unsigned long long has much better support on platforms that
  // do not have a native 64 bit int type.
  unsigned long long test_ulonglong (in unsigned long long s1,
                                     inout unsigned long long s2,
                                     out unsigned long long s3);

  // strings unbounded
  string test_unbounded_string (in string s1,
                                inout string s2,
                                out string s3);

  // strings bounded
  typedef string<128> short_string;
  short_string test_bounded_string (in short_string s1,
                                    inout short_string s2,
                                    out short_string s3);

  // wstrings unbounded
  wstring test_unbounded_wstring (in wstring ws1,
                                  inout wstring ws2,
                                  out wstring ws3);

  // wstrings bounded
  typedef wstring<128> short_wstring;
  short_wstring test_bounded_wstring (in short_wstring ws1,
                                      inout short_wstring ws2,
                                      out short_wstring ws3);

  // structures (fixed size)
  struct Fixed_Struct
  {
    long l;
    char c;
    short s;
    octet o;
    float f;
    boolean b;
    double d;
  };

  Fixed_Struct test_fixed_struct (in Fixed_Struct s1,
                                  inout Fixed_Struct s2,
                                  out Fixed_Struct s3);

  // = Sequences of long, strings, Var_Struct and Object
  // references...


  struct NameComponent
  {
    string id;
    string kind;
  };

  struct Step
  {
    NameComponent name;
    boolean process;
  };

  typedef sequence<Step> PathSpec;

  PathSpec test_unbounded_struct_sequence (in PathSpec s1,
                                           inout PathSpec s2,
                                           out PathSpec s3);
  CORBA::ShortSeq test_short_sequence (in CORBA::ShortSeq s1,
                                       inout CORBA::ShortSeq s2,
                                       out CORBA::ShortSeq s3);

  typedef sequence<short,32> Bounded_Short_Seq;
  Bounded_Short_Seq test_bounded_short_sequence (in Bounded_Short_Seq s1,
                                                 inout Bounded_Short_Seq s2,
                                                 out Bounded_Short_Seq s3);

  CORBA::LongSeq test_long_sequence (in CORBA::LongSeq s1,
                                     inout CORBA::LongSeq s2,
                                     out CORBA::LongSeq s3);

  typedef sequence<long,32> Bounded_Long_Seq;
  Bounded_Long_Seq test_bounded_long_sequence (in Bounded_Long_Seq s1,
                                               inout Bounded_Long_Seq s2,
                                               out Bounded_Long_Seq s3);

  CORBA::StringSeq test_strseq (in CORBA::StringSeq s1,
                                inout CORBA::StringSeq s2,
                                out CORBA::StringSeq s3);

  typedef sequence<string,32> Bounded_StrSeq;
  Bounded_StrSeq test_bounded_strseq (in Bounded_StrSeq s1,
                                      inout Bounded_StrSeq s2,
                                      out Bounded_StrSeq s3);

  CORBA::WStringSeq test_wstrseq (in CORBA::WStringSeq ws1,
                                  inout CORBA::WStringSeq ws2,
                                  out CORBA::WStringSeq ws3);

  typedef sequence<wstring,32> Bounded_WStrSeq;
  Bounded_WStrSeq test_bounded_wstrseq (in Bounded_WStrSeq ws1,
                                        inout Bounded_WStrSeq ws2,
                                        out Bounded_WStrSeq ws3);

  typedef sequence<Fixed_Struct> StructSeq;
  StructSeq test_struct_sequence (in StructSeq s1,
                                  inout StructSeq s2,
                                  out StructSeq s3);

  typedef sequence<Fixed_Struct,32> Bounded_StructSeq;
  Bounded_StructSeq test_bounded_struct_sequence (in Bounded_StructSeq s1,
                                                  inout Bounded_StructSeq s2,
                                                  out Bounded_StructSeq s3);

  typedef sequence<Coffee> Coffee_Mix;
  Coffee_Mix test_coffe_mix (in Coffee_Mix s1,
                             inout Coffee_Mix s2,
                             out Coffee_Mix s3);

  typedef sequence<Coffee,32> Bounded_Coffee_Mix;
  Bounded_Coffee_Mix test_bounded_coffe_mix (in Bounded_Coffee_Mix s1,
                                             inout Bounded_Coffee_Mix s2,
                                             out Bounded_Coffee_Mix s3);

  CORBA::AnySeq test_anyseq (in CORBA::AnySeq s1,
                             inout CORBA::AnySeq s2,
                             out CORBA::AnySeq s3);

/*  typedef sequence<any, 32> Bounded_AnySeq;
  Bounded_AnySeq test_bounded_anyseq (in Bounded_AnySeq s1,
  inout Bounded_AnySeq s2,
  out Bounded_AnySeq s3);
*/

  typedef string DUMMY;
  // variable structures
  struct Var_Struct
  {
    double dbl;
    DUMMY dummy1;
    boolean boole;
    DUMMY dummy2;
    short shrt;
    CORBA::StringSeq seq;
  };

  Var_Struct test_var_struct (in Var_Struct s1,
                              inout Var_Struct s2,
                              out Var_Struct s3);

  // nested structs (We reuse the var_struct defn above to make a very
  // complicated nested structure)
  struct Nested_Struct
  {
    Var_Struct vs;
  };

  Nested_Struct test_nested_struct (in Nested_Struct s1,
                                    inout Nested_Struct s2,
                                    out Nested_Struct s3);

  // object references
  Coffee make_coffee (); // make a Coffee object

  // test the parameter passing conventions for ObjRefs
  Coffee test_objref (in Coffee o1, inout Coffee o2, out Coffee o3);

  // test typecodes
  CORBA::TypeCode test_typecode (in CORBA::TypeCode t1,
                                 inout CORBA::TypeCode t2,
                                 out CORBA::TypeCode t3);

  // Anys. We try to pump in all kinds of data types thru these Anys
  any test_any (in any a1, inout any a2, out any a3);

  struct Objref_Struct
  {
    long x;
    Coffee y;
  };
  Objref_Struct test_objref_struct (in Objref_Struct t1,
                                    inout Objref_Struct t2,
                                    out Objref_Struct t3);
  // test structures that contain object references.

  // arrays (fixed)
  const unsigned long DIM1 = 10;
  typedef long Fixed_Array [DIM1];

  Fixed_Array test_fixed_array (in Fixed_Array l1,
                                inout Fixed_Array l2,
                                out Fixed_Array l3);

  // arrays (variable)
  const unsigned long DIM2 = 5;
  typedef string Var_Array [DIM2];

  Var_Array test_var_array (in Var_Array v1,
                            inout Var_Array v2,
                            out Var_Array v3);

  // Bounded and unbounced sequences of arrays.
  typedef sequence<Fixed_Array> ArraySeq;
  ArraySeq test_array_sequence (in ArraySeq s1,
                                inout ArraySeq s2,
                                out ArraySeq s3);

  typedef sequence<Fixed_Array, 32> Bounded_ArraySeq;
  Bounded_ArraySeq test_bounded_array_sequence (in Bounded_ArraySeq s1,
                                                inout Bounded_ArraySeq s2,
                                                out Bounded_ArraySeq s3);

  // Just to test report a problem
  exception Ooops {
    string reason;
    unsigned long input;
  };
  // To test what happens when an unexpected exception is thrown.
  exception BadBoy {
  };
  unsigned long test_exception (in unsigned long s1,
                                inout unsigned long s2,
                                out unsigned long s3)
    raises (Ooops);

  typedef short short_array[32];

  union Big_Union switch (short)
    {
    case 0:
      Fixed_Array the_array;
    case 1:
      Coffee the_interface;
    case 2:
      long the_long;
    case 3:
      short_array another_array;
    case 4:
      string the_string;
    case 5:
      CORBA::ShortSeq the_sequence;
    case 6:
      any the_any;
    case 7:
      octet the_octet;
    case 8:
      char the_char;
    case 9:
      boolean the_boolean;
    case 10:
      Var_Struct the_var_struct;
    case 11:
      Fixed_Struct the_fixed_struct;
      // case 12:
      // Other_Union the_union;
    };

  Big_Union test_big_union (in Big_Union u1,
                            inout Big_Union u2,
                            out Big_Union u3);

  enum Small_Union_Switch { A_LONG, A_SHORT };
  union Small_Union switch (Small_Union_Switch)
    {
    case A_LONG:
      long the_long;
    case A_SHORT:
      short the_short;
    };
  Small_Union test_small_union (in Small_Union u1,
                                inout Small_Union u2,
                                out Small_Union u3);

  // The following two structs are used to help compose
  // a complex Any for the test function below.
  struct level4
    {
      string level5_string;

      any level5_any;
    };

  struct level8
    {
      string level9_string;

      boolean level9_boolean;

      short level9_short;
    };

  any test_complex_any (in any ca1,
                        inout any ca2,
                        out any ca3);

  // Recursive structs. Contains a sequence of itself.
  struct Recursive_Struct;
  typedef sequence<Recursive_Struct> RecStructSeq;

  struct Recursive_Struct
    {
      long x;

      RecStructSeq children;
    };

  Recursive_Struct test_recursive_struct (in Recursive_Struct rs1,
                                          inout Recursive_Struct rs2,
                                          out Recursive_Struct rs3);

  // Recursive unions. We have one recursive union nested in a different
  // recursive union.
  union nested_rec_union;
  typedef sequence<nested_rec_union> NestedSeq;

  union nested_rec_union switch (short)
    {
      case 0: long value;
      case 1: NestedSeq nested_rec_member;
    };

  union Recursive_Union;
  typedef sequence<Recursive_Union> RecUnionSeq;

  union Recursive_Union switch (short)
    {
      case 0: RecUnionSeq rec_member;
      case 1: nested_rec_union nested_member;
    };

  Recursive_Union test_recursive_union (in Recursive_Union ru1,
                                        inout Recursive_Union ru2,
                                        out Recursive_Union ru3);

  // multidimensional arrays (fixed). The following will give rise to a 3
  // dimensional array. The following will define a 3-dimensional array of size
  // DIM1 X DIM2 X DIM3
  const unsigned long DIM3 = 3;

  typedef Fixed_Array Multdim_Array [DIM2][DIM3];

  Multdim_Array test_multdim_array (in Multdim_Array m1,
                                    inout Multdim_Array m2,
                                    out Multdim_Array m3);

  // sequence of typecodes
  //  typedef sequence<TypeCode> TypeCodeSeq;
  //  TypeCodeSeq test_tcseq (in TypeCodeSeq t1,  inout TypeCodeSeq t2, out TypeCodeSeq t3);

  void shutdown ();
  // Shutdown the server: this is useful to check for memory leaks,
  // performance results and in general to verify that orderly
  // shutdown is possible.

  // test simple objects
  //  Object test_object (in Object o1, inout Object o2, out Object o3);

};
