[omniORB] Obtaining references out of factory

xanith@web.de xanith@web.de
Thu, 17 Jan 2002 11:27:30 +0100


Hi,

I got some problems with references to objects and how to handle them. I found several examples of 
how to cope with that but nothing worked with omniORB. Nevertheless I am quite sure I am doing the 
whole mistake. 

I want to implement a factory creating my objects:
idl:
interface Foo {
...
}
interface FooFactory {
	Foo create();
	Foo catch();
}

Everything works fine, except the catch method. I was only able to give back a new reference to a 
new object. But look at some code of the working creat() method.

vector <Foo_i> foolist;
Foo_i* myFoo, tmpFoo;
Foo_ptr FooFactory_i::create(int id) {
	myFoo = new Foo_i(id);
	foolist.push_back(*myFoo);
}

Then the mismatch in the catch() method:
Foo_ptr FooFactory_i::catch(int id) {
	//the following is working, but does create some new object
	tmpFoo = new Foo_i(foolist.begin().[id]
	return tmpFoo->_this();
}

I tried something like
	Foo_ptr tmpptr = foolist.begin().[id];
	return tmpptr->_this();
or also some programming with _narrow() a simple converted object.

The problem is that what comes out of my vector does not match to Foo_ptr and I am not capable to 
convert it. I really got that feeling doing something totally wrong again.

Would be really great if someone will be able to help me,
_xanth.

________________________________________________________________
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! 
Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13