Solved

Aggregation in ATL

Posted on 2001-07-02
4
700 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

862 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now