[omniORB] simple question on general Corba

Duncan Grisby dgrisby@uk.research.att.com
Tue, 11 Sep 2001 18:03:51 +0100


On Tuesday 11 September, "Sveta Shasharina" wrote:

> So, the signatures of the calls for accessors and modifiers
> are overloaded as I expected. (I derived it from looking 
> at the skeleton h-file.)  Although, one of the omni 
> correspondents (Carl) suggested that I should
> use get_name and set_name.  By the way, I was using orbacus
> for this exersize, not omniorb.  Is there a difference?

Carl was wrong. Attributes are mapped to two identically named
functions in C++. It doesn't matter which ORB you use. In the Python
mapping, they are mapped to _get_foo() and _set_foo().

> I understood Duncan's points about benefits of using struct
> versus intrerfaces with attributes.  The problem is that I
> do want inheritance, so I could use classes polymorphically.
> To illustrate what I need, I will give this in C++ mapping:

If you know all the "derived" types at the time you write the IDL, you
can use a union:

  enum UnitKind { UNIT_PARAM, UNIT_OPTION };

  union UnitValue switch (UnitKind) {
    case UNIT_PARAM:  double d_value;
    case UNIT_OPTION: long   int_value;
  };

  struct Unit {
    string    name;
    string    unit;
    string    operation;
    UnitValue value;
  };


If you don't know the types, an Any is the right thing to use.

Another option might be to use objects by value, but omniORB doesn't
support them yet.

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --