Solved

Aggregation in ATL

Posted on 2001-07-02
4
710 Views
Last Modified: 2013-11-25
G'day, I'm back with (yet) another question on ATL.  I need to create an interface that aggregates another component.  Further more, I want this new interface to be a union of the inner interface and the outer.

Here's what I've got (some code removed for brevity):
--------------------------------------
interface IInnerObject : IDispatch
{
[id(1), helpstring("method Inner1")] HRESULT Inner1();
[id(2), helpstring("method Inner2")] HRESULT Inner2();
};

interface IOuter : IDispatch
{
[id(3), helpstring("method Outer1")] HRESULT Outer1();
};
// Extra code omitted

coclass InnerObject
{
[default] interface IInnerObject;
};

coclass Outer
{
[default] interface IOuter;
interface IInnerObject;
};
--------------------------------------
// COuter.h

BEGIN_COM_MAP(COuter)
     COM_INTERFACE_ENTRY(IOuter)
     COM_INTERFACE_ENTRY(IDispatch)
     COM_INTERFACE_ENTRY_AGGREGATE_BLIND(m_pAgg.p)
END_COM_MAP()

I've also overloaded FinalConstruct and FinalRelease to export the inner interface.  My test app (in VB) can see both interfaces just fine, though they are exposed as two interfaces, and not a union of the two.
0
Comment
Question by:InetMatt
4 Comments
 
LVL 6

Expert Comment

by:snoegler
ID: 6254937
>> , though they are exposed as two interfaces, and not a union of the two.
which is correct & expected behavior for aggregation ...

If you want to 'unify' two interfaces you must define a new interface which forwards the methods to the contained interfaces.
Suppose you have IFoo and IBar. How would you expect the 'unified' interface to appear to COM? As IFooBar? As IBarFoo :)
0
 
LVL 1

Accepted Solution

by:
ccaprar earned 50 total points
ID: 6264604
If you want to expose a single interface, just define your IOuter interface to contain the union of IInnerObject methods and the new methods specific to IOuter. In the methods of IOuter that correspond to IInnerObject, forward the request to the inner object method. And remove the macro COM_INTERFACE_ENTRY_AGGREGATE_BLIND from your COM MAP. Of course, you should create the inner object in your FinalConstruct and destroy in FinalRelease :)
0
 
LVL 11

Expert Comment

by:griessh
ID: 6825327
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "snoegler, ccaprar" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6875353
Per recommendation comment force/accepted by

Netminder
Community Support Moderator
Experts Exchange

snoegler: points for you at http://experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20278069
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 130
Least Squares Curve Fitting 4 117
What .NET website keeps me current? 9 80
boost::uuid crashes 17 41
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question