Solved

Aggregation in ATL

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Least Squares Curve Fitting 4 77
Need a complete list of ASP.NET page load events 3 46
Windows ICD FFU Issue 4 38
VIDEO DATASOURCE Control Resize issue 2 20
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

777 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