Need help with this code.
Joachim Fabini
e9027595@student.tuwien.ac.at
Fri, 12 Dec 1997 10:04:09 +0100 (MET)
> I am new to the omniOrb and I am trying to port the code from orbix to
> omniOrb, so please bear with me for this simple question:
>
> I have the following two interface:
>
> interface counter
> {
> void setCount(in long aValue);
> long getCount();
>
> void incCount();
> void decCount();
> };
>
> interface counterFactory
> {
> counter newCounter();
> void freeCounter(in counter aCounter);
> };
>
> counter_ptr
> counterFactory_i::newCounter()
> {
>
> counter_ptr c = new counter_i();
> counter::_duplicate(c);
> return c;
> }
Hi,
As a first step pass the pointer to the boa (main function) as an argument
to your factory object's constructor, i.e.
counterFactory_i::counterFactory_i(CORBA::BOA_ptr boa)
{
// within your counterFactory_i object you declare a private variable
// CORBA::BOA_ptr _boa;.
_boa = boa;
}
afterwards, your newCounter() should look like:
counter_ptr counterFactory_i::newCounter()
{
// instantiate new object
counter_i* c = new counter_i();
// register object with boa (i.e tell boa that object is ready to
// receive requests
c->_obj_is_ready(_boa);
counter_ptr ptr = c->_this();
return counter::_duplicate(ptr);
}
That should work...
Hope it helps,
--Jo
PS: I'm also a newbie so if there's something non-CORBA compliant
in this solution please feel free to complain about it! ;-)