NextPrevUpTopContentsIndex

1.8.5.2 A second example of multiple inheritance

Here is a further extension to the example in An example of multiple inheritance, with an additional interface i-foo-ex .that inherits from i-foo as in the following IDL:

[ uuid(7D9EB761-E4E5-11D5-BF02-000347024BE1) ]
interface IFooEx : IFoo
{
  HRESULT meth4();
}

This interface has the following additional implementations:

  1. An implementation defining all the methods in i-foo-ex :
  2. (define-com-implementation foo-ex-impl-1 ()
      ()
      (:interfaces i-foo-ex))
     
    (define-com-method meth1 ((this foo-ex-impl-1))
      s_ok)
     
    (define-com-method meth2 ((this foo-ex-impl-1))
      s_ok)
     
    (define-com-method meth3 ((this foo-ex-impl-1))
      s_ok)
     
    (define-com-method meth4 ((this foo-ex-impl-1))
      s_ok)
  3. A combined implementation, inheriting from step 3 from An example of multiple inheritance and step 1 above.
(define-com-implementation foo-ex-impl-2 (foo-impl-12
                                          foo-ex-impl-1)
  ()
  (:interfaces i-foo-ex))

In step 2 , the class foo-ex-impl-2 implements the interface i-foo-ex and is a subclass of foo-ex-impl-1 , which implements i-foo . When the following form is evaluated with p-foo-ex created from an instance of foo-ex-impl-2 :

(let ((object (make-instance 'foo-ex-impl-2)))
  (with-temp-interface (p-foo-ex)
      (nth-value 1 (query-object-interface
                    foo-ex-impl-2
                    object
                    'i-foo-ex))
    (with-com-interface (call-p-foo i-foo-ex) p-foo-ex
      (values (call-p-foo meth1)
              (call-p-foo meth2)
              (call-p-foo meth3)
              (call-p-foo meth4)))))

the four values are S_OK , E_NOTIMPL , S_OK and S_OK .

Note that, even though foo-ex-impl-2 only explicitly implements i-foo-ex , the methods meth1 , meth2 and meth3 were declared in its parent interface i-foo . This means that their definitions (including the "unimplemented" definition of meth2 ) are inherited from foo-impl (via foo-impl-12 ), because foo-impl-12 is before foo-ex-impl-2 in the class precedence list of foo-ex-impl-2 . Only meth4 , which is declared in i-foo-ex , is inherited from foo-ex-impl-1 .


LispWorks COM/Automation User Guide and Reference Manual - 17 Jul 2006

NextPrevUpTopContentsIndex