[omniORB] Re: DynAny & CORBA 2.3 spec.
Francois Laflamme
francois.laflamme@voxco.com
Thu, 25 May 2000 12:25:23 -0400
Thanks for your help David,
We`ve try the following code with the orb v.2.8 and we get an assertion
failure from debug heap pointer (under vc++ v6) when the Any_var goes out of
scope.
//////////////////////////
{
CORBA::DynAny_var da;
CORBA::Any_var a;
da = Orb->create_basic_dyn_any(CORBA::_tc_long);
da->insert_long(1);
a = da->to_any();
da->destroy();
}
//////////////////////////
Should we absolutly use the v.3 to make it running?
Thanks again!
Olivier & Frangois
> -----Original Message-----
> From: David Riddoch [mailto:djr@uk.research.att.com]
> Sent: 25 mai, 2000 03:59
> To: Olivier Thiboutot
> Cc: 'omniorb@uk.research.att.com'; omniorb-list@uk.research.att.com
> Subject: [omniORB] Re: DynAny & CORBA 2.3 spec.
>
>
> On Wed, 24 May 2000, Olivier Thiboutot wrote:
>
> > We want to use OmniORB as or broker but we are not able to build
> > dynamic complexe structure with DynAny and pass them as Any... like
> >
> > struct ToPass
> > {
> > short Mine;
> > long MyLongArray[25];
> > }
>
> Why not? Try this...
>
> /////////////////////////////////////////////////////////////
> #include <omniORB3/CORBA.h>
>
>
> CORBA::TypeCode_ptr create_tc(CORBA::ORB_ptr orb)
> {
> CORBA::TypeCode_var a = orb->create_array_tc(25, CORBA::_tc_long);
>
> CORBA::StructMemberSeq m;
> m.length(2);
> m[0].name = (const char*) "Mine";
> m[0].type = CORBA::TypeCode::_duplicate(CORBA::_tc_short);
> m[1].name = (const char*) "MyLongArray";
> m[1].type = CORBA::TypeCode::_duplicate(a);
>
> return orb->create_struct_tc("IDL:ToPass:1.0", "ToPass", m);
> }
>
>
> CORBA::DynAny_ptr create_DynAny(CORBA::ORB_ptr orb,
> CORBA::TypeCode_ptr
> tc)
> {
> CORBA::DynStruct_var ds = orb->create_dyn_struct(tc);
>
> ds->insert_short(5);
>
> CORBA::DynAny_var d = ds->current_component();
> CORBA::DynArray_var da = CORBA::DynArray::_narrow(d);
>
> for( int i = 0; i < 25; i++ )
> da->insert_long(i);
>
> return ds._retn();
> }
>
>
> int main(int argc, char** argv)
> {
> CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
>
> CORBA::TypeCode_var tc = create_tc(orb);
>
> CORBA::DynAny_var d = create_DynAny(orb, tc);
>
> CORBA::Any_var a = d->to_any();
>
> return 0;
> }
> /////////////////////////////////////////////////////////////
>
>
> > trying to build this with DynAny and having MyLongArray to be in
> > fact a Seqence looks impossible... to transfert to a Any.
>
> It is certainly not impossible. Perhaps the above example
> will give you
> enough of a hint...
>
>
> Cheers,
> David
>
>
> PS. Its probably best if you send such queries to
> <omniorb-list@uk.research.att.com> in future please.