Need help with this code.

Bing Zhang bzhang@sohar.com
Fri, 12 Dec 1997 16:30:35 -0800


Thanks to everybody who replied, especially to Joachim, he wrote

> 
> 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! ;-)

I did exactly what he suggested and it works.

As all of you pointed out that I need to call obj_is_ready on the object
which lets the object receive messages. But Orbix does not explicitly
need the obj_is_ready function call? Any non-CORBA compliant?

Here is the Orbix implementation of the newCounter() function. Notice
that it is using TIE approach.

counter_ptr
counterFactory_i::newCounter()
{

 counter_ptr c = new TIE_counter(counter_i) (new counter_i);
 counter::_duplicate(c);
 return c;
}


P.S. I implement the freeCounter functions as followings:

void   counterFactory_i::freeCounter(counter_ptr c){

	CORBA::release(c);
}

-- 
------------------------------------------------------------------
Bing Zhang  bzhang@sohar.com | Sohar Inc.                         |
Tel:   (213)653-4717 X 118   | 8421 Wilshire Blvd., Suite 201     |
Fax:   (213)653-3624         | Beverly Hills, CA 90211-3204       |


Joachim Fabini wrote:
> 
> > 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,