Solved

Aggregation in ATL

Posted on 2001-07-02
4
698 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
Comment Utility
>> , 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

772 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

12 Experts available now in Live!

Get 1:1 Help Now