[omniORB] Problem using Any constructor

Ernie van der Meer E.A.vanderMeer@phys.uu.nl
Thu, 5 Aug 1999 14:36:01 +0200


Hi All,

I have been trying to insert a structure into an Any without having the
Any copy the value. I need to insert objects of several tens of megabytes,
so I can't afford to have them copied all over the place. I found the
following CORBA::Any constructor:

    CORBA::Any::Any(TypeCode_ptr tc, void* value, Boolean release)

This looks like the thing I need. I use the following IDL for my test:

    typedef sequence<double> DoubleSeq;

    struct Point
    {
      long x, y, z;
      DoubleSeq ds;
    };

    interface Tester
    {
      any getVal();
    };

The .hh file generated by omniidl contains the following line:

    _CORBA_GLOBAL_VAR const CORBA::TypeCode_ptr _tc_Point

In my server, I implement the getVal() member function as follows:

    CORBA::Any *getVal()
    {
      Point *p = new Point;
      p->x = 10.0; 
      p->y = 11.0; 
      p->z = 12.0; 
      p->ds.length(5);
      p->ds[0] = 1.0;
      p->ds[1] = 2.0;
      p->ds[2] = 3.0;
      p->ds[3] = 4.0;
      p->ds[4] = 5.0;

      CORBA::Any *ret = new CORBA::Any(_tc_Point, p, 1);
      return ret;
    }

For some reason, the client does not receive the Point correctly. The x,
y and z members are okay, but the sequence member is completely screwed
up. I've tested similar code with Visibroker and Orbacus. No go on all
ORBs! This gives me the feeling I must be missing something bigtime.
Please, can anyone help me out of this one?

Please reply to me directly, as I am not on this mailing list.
-- 
Ernie van der Meer                     email: e.a.vandermeer@phys.uu.nl
Computational Physics department       tel  : (+31)(0)30-2532290
Faculty of physics and astronomy       fax  : (+31)(0)30-2537555
Utrecht University, Leuvenlaan 4
NL-3508TD Utrecht, The Netherlands.