Re: [orbitcpp-list] More questions...
Status: Beta
Brought to you by:
philipd
From: Phil D. <ph...@us...> - 2000-09-18 09:13:11
|
Hi Mike, Mike Bond writes: > I was noticing in some of your test code that after calling > orb->string_to_object() you call obj->_narrow(). If my understanding > is correct, this is essentially a cast mechanism. > Yep, > My first question is why is this done in orbitcpp but not in ORBit, is > it simply because C++ handles casting differently or is there more to it? Nothing fancy - it's just a difference in the specs. C object refs are typedef'd void ptrs anyway, so you can use them interchangably without the compiler complaining. C++ object refs are statically typechecked by the compiler, and so you need a safe way to do the casts. > Also, the implementation of _narrow() appears to be calling _duplicate(), > is it truly allocating a new object and copying as the name suggests, or > just doing some refcounting? > The duplicate() semantically copies the object *reference*, not the object itself (and CORBA::Object::release() releases the object ref, but doesn't delete the object). Under the hood, reference counting is done by the Orbit C core. > Also, does one need to call CORBA::release() separately for both the > reference returned by string_to_object() as well as the reference > returned by _narrow()? > Yep, because they are 2 seperate refs. (However, if you use _vars, this is done automatically when the ref goes out of scope) Hope this helps, Phil. |