[omniORB] simple question on general Corba

Carl Thompson cet@carlthompson.net
Tue, 11 Sep 2001 13:40:37 -0700


I am wrong here.  The C++ mapping for CORBA attributes does in fact use 
overloaded functions.  I am not sure where I got what I wrote...  Sorry 
for any inconvenience.

Carl Thompson

Carl Thompson wrote:
> Sveta Shasharina wrote:
> 
>> Hi!
>>
>> I never used attributes before and decided to use them instead od 
>> structs because I want inheritance and thus have to go with interfaces 
>> with attributes:
>>
>> interface Unit {
>>     attribute string name;
>> }
>>
>> interface Param : Unit {
>>     attribute double value;
>> }
> 
> 
> Your IDL is exactly equivalent to this one:
> 
> interface Unit {
>     string get_name();
>     void set_name(in string n);
> }
> 
> interface Param : Unit {
>     double get_value();
>     void set_value(in double d);
> }
> 
> Therefore it should be implemented like this:
> 
>> class UnitImpl : public virtual POA_Unit {
>>     char* get_name() {return CORBA::string_dup(name);}
>>     void set_name(const char* n) {name = n;}
>> }
>>
>> class ParamImpl: public virtual POA_Param, public UnitImpl {
>>     CORBA::double get_value() {return value;}
>>     void set_value(CORBA::double d) {value = d;}
>> };
> 
> 
> Note that CORBA does not allow overloaded operations as you attempted.
> 
> Also note that some prominent people consider it bad form to use 
> attributes; you should explicitly define you get_ and set_ operations in 
> your IDL instead (as I showed, above).  Using attributes yields no 
> benefits and has some drawbacks (impossible to specify exceptions).
> 
> I'm not sure whether it's necessary, but I would use CORBA::string_dup() 
>  for the return of get_name().
> 
>> Thanks,
>> Svetlana Shasharina -- sveta@txcorp.com
> 
> 
> Carl Thompson
> 
>