[omniORB] Casting C++- to CORBA-objects

Glenn A. Hochberg ghochberg@att.com
Tue, 10 Oct 2000 08:41:39 -0400


> I have already existing "raw" C++-code without CORBA. I'm not allowed
> to change the C++-code in any way, and my CORBA-methods must call the
> C++-methods. Most of them return a pointer to a new C++-object, and
> that is the problem, since all of the four possible down-cast
> (dynamic_cast, static_cast, reinterpret_cast, and () typecasts) are
> not allowed and not specified. And _narrow is only accepting
> everything that is of type CORBA::Object_ptr or derived from it.
>
> Does someone know a method for safe casting? Or maybe a WRAPPER-object
> might be the solution, but since I never implemented one, I would be
> very glad about a short "pseudocode"-notation with a constructor and
> a method like CorbaFooA_ptr CorbaFooB_i::getCorbaFooA().

Casting won't work here, since your C++ classes do not inherit from CORBA
skeletons.  Sounds like a wrapper approach is what you want.  You may be
able to use the tie template classes generated by the IDL compiler for
this.  See the omniORB User Manual at
http://www.uk.research.att.com/omniORB/doc/3.0/omniORB/omniORB002.html#toc14

Check your book too--look for a section on tie templates.

This is the delegation model--your CORBA class holds onto a pointer to
your original C++ class, and deletes it in it's destructor.

    -Glenn
--
Glenn A. Hochberg  | "Any activity becomes creative when the doer
AT&T Labs          |  cares about doing it right, or doing it better."
ghochberg@att.com  |      -John Updike