[omniORB] how to use _dispose() in factory?
Zsolt Zsoldos
zzsolt@home.com
Mon, 07 Sep 1998 19:24:35 -0400
Hi,
It maybe a silly newbie question, sorry...
I would like to create an object class with a factory for
generating and disposing objects dynamicaly. I defined the
following idl:
module modest
{
interface BaseObject
{
readonly attribute long status;
oneway void registerSink( in BaseObject sink );
};
interface BaseObjectFactory
{
BaseObject createObject();
oneway void destroyObject( in BaseObject me );
};
};
I am trying to implement the factory operations according to
the signature generated by the stubs:
modest::BaseObject_ptr BaseObjectFactoryImp::createObject()
{
BaseObjectImp *the_new_obj = new BaseObjectImp();
the_new_obj->_obj_is_ready( _boa );
modest::BaseObject_ptr ref_to_new_obj = the_new_obj->_this();
return ref_to_new_obj;
}
void BaseObjectFactoryImp::destroyObject( modest::BaseObject_ptr me )
{
me->_dispose();
CORBA::release( me );
}
However, I get a compiler error for me->_dispose(), saying that there
is no such member. I see that the _dispose() is defined in the
skeleton class _sk_BaseObjectFactory which inherits from
BaseObjectFactory. So it looks like, that I should call _dispose()
on my BaseObjectImp object and not on the ancestor BaseObject.
But the signatures as generated require me to use BaseObject_ptr
types. Can I just cast it in the destroyObject() method?
Or should I return a casted the_new_obj pointer from createObject()
and then cast it back in the destroyObject()?
Or is there another (clean) way to do this?
Thanks for your help,
Zsolt
--
Zsolt Zsoldos, PhD. e-mail: zzsolt@home.com
SimBioSys Inc. phone: 905 - 793 - 8617
716 Peter Robertson Blvd. fax: 905 - 793 - 4996
Brampton, Ont, L6R 1L6 Canada http://members.home.net/zzsolt/