[omniORB] Object Factory
David Riddoch
djr@uk.research.att.com
Tue, 2 Nov 1999 17:51:59 +0000 (GMT)
Hi Ryan,
You cannot simply return an _var type -- it will hold onto the reference
and release it before the method returns. Either use tempo._retn() or
even more simply do this:
case TONE:
cout << "Making a new ThingOne!" << endl;
tone = new ThingOne_impl();
tone->_obj_is_ready( tone->_boa() );
return tone->_this();
Hope that helps,
David
On Tue, 2 Nov 1999, ryan.tecco wrote:
>
> Hello all. In this following simple code for an object factory:
>
> ThingOne_ptr makeThing( Type type )
> {
> ThingOne_var tempo;
> ThingTwo_var tempt;
> ThingThree_var tempth;
> ThingFour_var tempf;
> switch( type ) {
> case TONE:
> cout << "Making a new ThingOne!" << endl;
> tone = new ThingOne_impl();
> tone->_obj_is_ready( tone->_boa() );
> tempo = tone->_this();
> return tempo;
> break;
> case TTWO:
> cout << "Making a new ThingTwo!" << endl;
> ttwo = new ThingTwo_impl();
> ttwo->_obj_is_ready( ttwo->_boa() );
> tempt = ttwo->_this();
> return tempt;
> break;
>
> ...and so on through the different types
>
> I get the client to recieve a valid (non-nil) object reference, but
> subsequent attempts to contact the object raise a "OBJECT_NOT_EXIST"
> exception.
>
> Any thing simple I am not doing off the bat?
>
> --------------
> ryan.tecco
> 734.476.6646
> the university of michigan
> "i'll never forget my life
> as a carrot."
>
>
>