[omniORB] How to init a tie pointer safely

Haarek Ryeng Haarek.Ryeng@datarespons.no
Fri, 03 Dec 1999 10:32:52 +0100


This is a multi-part message in MIME format.
--------------4925C9C1E5DF74B3BB951E9A
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

The CORBA::is_nil(_p->_this()) will obviously throw an
exception when _p == NULL, and the way I do the check today is
by "if (_p == NULL)".

Is there a better way to do this?

- Haarek Ryeng

PS! I'll try to send only one mail next time.. (to little
coffee- yet :-) )

Haarek Ryeng wrote:

> What is the preferred way to initialise a pointer to a
> tie-class?
> And how do I maintain this pointer safely?
>
> Ex:
> Tie-class: _tie_A<A_i*,false>
> Impl-class: A_i
>
> class A_i
> {
>     // some defs......
>     _tie_A< A_i*,false >* _p;
> };
>
> A_i::A_i()
> {
>    _p = NULL // Alright?
> }
>
> A_i::InterfaceFactory()
> {
>   if ( CORBA::is_nil(_p->-this()) ) // Is this the safe way
> to check
>                                    //for a valid interface
> through the tie pointer?
>   {
>      try
>      {
>           _p = new _tie_A<A_i*,false>(this);
>           boa->obj_is_ready(_p);
>       }
>      catch( bad_alloc)
>      {
>         _p = ?  // What do I initialise it to so that the
> above “is_nil”
>                     //check is safe?
>      }
>   }// end if
> }// end factory function
>
> Any comments?
>
> Regards,
>
> Haarek Ryeng

--------------4925C9C1E5DF74B3BB951E9A
Content-Type: text/x-vcard; charset=us-ascii;
 name="haarek.ryeng.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Hårek Ryeng
Content-Disposition: attachment;
 filename="haarek.ryeng.vcf"

begin:vcard 
adr;dom:;;;N-1322 HØVIK;;;
n:Ryeng;Hårek
x-mozilla-html:FALSE
org:Data Respons AS
version:2.1
email;internet:haarek.ryeng@datarespons.no
title:M.sci (computers & signal processing)
tel;fax:67112050
tel;home:90196734
tel;work:67112071
x-mozilla-cpt:;0
fn:Hårek Ryeng
end:vcard

--------------4925C9C1E5DF74B3BB951E9A--