[omniORB] Return Struct o None

Antonio Beamud Montero antonio.beamud at gmail.com
Mon Mar 30 18:56:34 BST 2009


William Bauder escribió:
> CORBA doesn't allow nulls - try a discriminator union:
>
> idl:
> ...
> struct SInfo {
>      wstring id;
>      wstring address;
>      wstring tlf;
> }
>
> union SInfoDiscriminator switch(boolean)
> {
>   case TRUE: SInfo value;
> };
>
> I don't know python, so this is pseudocode:
>
> def get_personal_info(self, name):
>      if name in self.personal_dict:
>        return SInfoDiscrimitor().value(SInfo(self.personal_dict[name]['id'],
>                        self.personal_dict[name]['address'],
>                        self.personal_dict[name]['tlf']))
>        else:
>           return SInfoDiscrimitor()._default()
>
> On the client side:
>   sInfoDiscriminator=get_personal_info("...")
>   if sInfoDiscriminator._d()==TRUE
>     sInfo=sInfoDiscriminator.value()
>   else
>     sInfo=NULL
>
>   
Thanks for all your replies. For simplicity I've used the raise 
exception approach, but the union seems very interesting...

A lot of thanks.




More information about the omniORB-list mailing list