Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Aggregation in ATL

Posted on 2001-07-02
4
Medium Priority
?
721 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

604 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