ATL inheritance from 2 different DLLs 
Author Message
 ATL inheritance from 2 different DLLs

I have been going thru alot of post today and I can't seem to put my
finger on the solution I need.

Using ATL I want to create 2 dlls with 1 interface each:

DLL1 -> I1
DLL2 -> I2

Interface I1 has the following methods:

I1 -> M1()
I1 -> M2()

Interface I2 has the following methods:

I2 -> M3()
I2 -> M4()

The tricky part though is that I need I2 to inherit the I1 methods (in
C++ terms I would say that I2 would derive from I1) without
duplicating any code so that I can change any DLL anytime I want. This
way an application that uses my component could call DLL2->I2->M1()
and be transparently redirected to DLL1->I1->M1(). Is this possible
using ATL?

I understand the use of templates to do the job but most of the
solutions I found seems to be for interfaces defined in the same DLL
only. Is this right?

Any help and pointers would be greatly appreciated.

Thanks

Patrick Moreau



Sun, 11 Jul 2004 15:23:45 GMT  
 ATL inheritance from 2 different DLLs
do u mean using I2 to aggregate I1?

Quote:
> I have been going thru alot of post today and I can't seem to put my
> finger on the solution I need.

> Using ATL I want to create 2 dlls with 1 interface each:

> DLL1 -> I1
> DLL2 -> I2

> Interface I1 has the following methods:

> I1 -> M1()
> I1 -> M2()

> Interface I2 has the following methods:

> I2 -> M3()
> I2 -> M4()

> The tricky part though is that I need I2 to inherit the I1 methods (in
> C++ terms I would say that I2 would derive from I1) without
> duplicating any code so that I can change any DLL anytime I want. This
> way an application that uses my component could call DLL2->I2->M1()
> and be transparently redirected to DLL1->I1->M1(). Is this possible
> using ATL?

> I understand the use of templates to do the job but most of the
> solutions I found seems to be for interfaces defined in the same DLL
> only. Is this right?

> Any help and pointers would be greatly appreciated.

> Thanks

> Patrick Moreau



Mon, 12 Jul 2004 12:14:24 GMT  
 ATL inheritance from 2 different DLLs
Yes, but my problem is I don't know where to start...

Can I do aggregation using 2 components from separate DLLs?

Quote:

> do u mean using I2 to aggregate I1?


> > I have been going thru alot of post today and I can't seem to put my
> > finger on the solution I need.

> > Using ATL I want to create 2 dlls with 1 interface each:

> > DLL1 -> I1
> > DLL2 -> I2

> > Interface I1 has the following methods:

> > I1 -> M1()
> > I1 -> M2()

> > Interface I2 has the following methods:

> > I2 -> M3()
> > I2 -> M4()

> > The tricky part though is that I need I2 to inherit the I1 methods (in
> > C++ terms I would say that I2 would derive from I1) without
> > duplicating any code so that I can change any DLL anytime I want. This
> > way an application that uses my component could call DLL2->I2->M1()
> > and be transparently redirected to DLL1->I1->M1(). Is this possible
> > using ATL?

> > I understand the use of templates to do the job but most of the
> > solutions I found seems to be for interfaces defined in the same DLL
> > only. Is this right?

> > Any help and pointers would be greatly appreciated.

> > Thanks

> > Patrick Moreau



Mon, 12 Jul 2004 01:22:32 GMT  
 ATL inheritance from 2 different DLLs
This cannot be done directly - aggregation is not an option. You
must use containment in addition to the interface derivation.

Let's say you have coclass CC1 implementing interface I1 in DLL1,
and coclass CC2 implementing I2 deriving from I1 in DLL2. You
have to implement the methods of both I1 and I2 in CC2. To
implement I1, you create an instance of CC1 and forward each
I1 method to this contained instance. See FinalConstruct and
FinalRelease - these are the places to create and release
respectively the contained COM object instance.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

Quote:

> Yes, but my problem is I don't know where to start...

> Can I do aggregation using 2 components from separate DLLs?


> > do u mean using I2 to aggregate I1?


> > > I have been going thru alot of post today and I can't seem to put my
> > > finger on the solution I need.

> > > Using ATL I want to create 2 dlls with 1 interface each:

> > > DLL1 -> I1
> > > DLL2 -> I2

> > > Interface I1 has the following methods:

> > > I1 -> M1()
> > > I1 -> M2()

> > > Interface I2 has the following methods:

> > > I2 -> M3()
> > > I2 -> M4()

> > > The tricky part though is that I need I2 to inherit the I1 methods (in
> > > C++ terms I would say that I2 would derive from I1) without
> > > duplicating any code so that I can change any DLL anytime I want. This
> > > way an application that uses my component could call DLL2->I2->M1()
> > > and be transparently redirected to DLL1->I1->M1(). Is this possible
> > > using ATL?

> > > I understand the use of templates to do the job but most of the
> > > solutions I found seems to be for interfaces defined in the same DLL
> > > only. Is this right?

> > > Any help and pointers would be greatly appreciated.

> > > Thanks

> > > Patrick Moreau



Mon, 12 Jul 2004 03:13:50 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Different heaps in different DLLs?

2. Implementation Inheritance w/ ATL 3.0

3. Interface Inheritance w/ ATL

4. C++ Inheritance in ATL - Again

5. C++ Inheritance in ATL

6. Inheritance in ATL COM object...

7. ATL inheritance/containment question

8. Interface Inheritance Problem with ATL

9. Polymorphism and Inheritance in ATL

10. ATL - inheritance question

11. ATL: Multiple Inheritance and Interface Resolution?

12. ATL Composite Controls and inheritance

 

 
Powered by phpBB® Forum Software