[omniORB] object creation
Stefan Seefeld
seefelds@MAGELLAN.UMontreal.CA
Thu, 25 Nov 1999 17:50:33 +0000
Hi,
with the BOA, an object creation in omniORB was completed
after the _obj_is_ready() method had been called. Only then
could it be dereferenced by _this().
What about the POA ? From when on can I use _this() ?
The question is important since I often happen to create
pairs of objects which associate each other like in a
parent-child relationship:
Graphic_var child = factory->foo();
Graphic_var parent = factory->bar(child);
So with the BOA, the factory had to do
Graphic_ptr Factory::bar(Graphic_ptr child)
{
GraphicImpl *parent = new GraphicImpl;
parent->_obj_is_ready(CORBA::BOA::getBOA());
parent->addChild(child);
// register parent here to local GC
return parent->_this();
};
What I now try to figure out, is, whether the 'addChild'
can be called from within the parent's constructor, since
it involves a call to
child->addParent(Graphic_var(_this()));
In general, with the BOA I had to introduce lots of 'init()' like
functions which finish the construction after registering the object
with the object adapter. My point is that if the POA works differently,
this could simplify the code quite a bit.
The above factory method for the parent for example could simply look like
Graphic_ptr Factory::bar(Graphic_ptr child)
{
GraphicImpl *parent = new GraphicImpl(child);
// register parent here to local GC
return parent->_this();
}
Thanks, Stefan
_______________________________________________________
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds@magellan.umontreal.ca
_______________________________________________________
...ich hab' noch einen Koffer in Berlin...