Hi,

using the "new" UNO features, in particular multiple inheritance, to
excess :), I stumbled upon the following problem:

Let's say we have

  interface XBar1 {
    interface XPropertySet;
  };
  interface XBar2 {
    interface XPropertySet;
  }
  interface XFoo {
    interface XBar1;
    interface XBar2;
  }

Now, in the UNO C++ language binding, consider:

  Reference< XFoo > xFoo = getSomeFoo();
  xFoo->getPropertyValue( somePropertyName() );

This yields a compiler error that "getPropertyValue" is ambiguous.
My first attempt to resolve this was

  xFoo->XBar1::getPropertyValue( somePropertyName() );

This compiles fine, but yields a linker error that the symbol
XPropertySet::getPropertyValue cannot be found. Thinking about it, the
linked is probably right to reject my stupid attempt :), but then I
still have my problem.

Okay, a working alternative to resolve this is

  static_cast< XBar1* >( xFoo.get() )->getPropertyValue(
    somePropertyName() )

This compiles and links fine. However, it has the disadvantage that
users of XFoo must *know* at least one base interface of XFoo which
unambiguously provides the XPropertySet functionality - which is
inconvinient.

Yet another alternative is

  Reference< XPropertySet > xFooProperties( xFoo, UNO_QUERY_THROW );
  xFooProperties->getPropertyValue( somePropertyName() );

This relieves the user from knowing the base class hierarchy of XFoo,
but the penalty is additional runtime costs. Also, it contradicts the
intention of the new UNO features, which were introduced to *save* the
syntactic and runtime overhead of all those queryInterface calls.



So far, I didn't find any satisfying solution to this problem.

Did I overlook something?

Are there better solutions in place ATM?

Are better solutions at least possible in theory (by, say, changing the
generated C++ header for XFoo to include a disambiguated
getPropertyValue method)?


Thanks & Ciao
Frank

PS: Interestingly, the Java language binding does not seem to suffer
    from this problem.
      XFoo foo = getSomeFoo();
      foo.getPropertyValue( somePropertyName() );
    compiles fine ...

-- 
- Frank Schönheit, Software Engineer         [EMAIL PROTECTED] -
- Sun Microsystems                      http://www.sun.com/staroffice -
- OpenOffice.org Database                   http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to