Re: How to access a C++ class object from the aggregated interface-class
From: Naanthaa N (naanthaan2k_at_yahoo.com)
Date: 03/16/04
- Next message: KJ: "Re: ATL DHTML reference problem"
- Previous message: Tony: "port problem"
- In reply to: Alexander Nickolov: "Re: How to access a C++ class object from the aggregated interface-class"
- Next in thread: Alexander Nickolov: "Re: How to access a C++ class object from the aggregated interface-class"
- Reply: Alexander Nickolov: "Re: How to access a C++ class object from the aggregated interface-class"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 16 Mar 2004 02:41:08 -0800
Hi,
>From the FAQ 7, It looks like that we can use templates in the CSinkAgg to access the variables (i.e., CSrcObj instance) in the CSinkObj class. i,e., by passing CSinkObj as a template argument to CSinkAgg and there we can accesss CSrcObj instance. Apart from the 'code bloat', this technique could be useful. Is my understaning correct?
-Naanthaa N
----- Alexander Nickolov wrote: -----
To finish what Igor started, some techniques for source code reuse
with ATL COM objects are detailed in these two FAQ articles:
http://www.mvps.org/vcfaq/com/7.htm
http://www.mvps.org/vcfaq/com/8.htm
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message news:ejoCh3rCEHA.4080@TK2MSFTNGP09.phx.gbl...
> "Naanthaa N" <naanthaan2k@yahoo.com> wrote in message
> news:B8E75A60-BB25-4543-B79E-2C933997E966@microsoft.com...
>> Hello there,
>> I have a class called CSinkAgg -associated with
> ISinkAgg. This class is being aggregated into CSinkObj, i.e., I am
> creating the instance of ISinkAgg at CSinkObj::FinalConstruct. Now, I
> have an instance of another class, called CSrcObj at CSinkObject. How
> do i access CSrcObj's instance from CSinkAgg? Pls do help me!
>> You don't. Aggregation is a technique for binary reuse, not for source
> level reuse. With aggregation, you don't have C++ classes - you have COM
> components that expose interfaces.
>> So, you can make CSrcObj a COM object and have it implement an interface
> you define, say ISrcObj. CSinkAgg can also implement an interface that
> has a method that accepts ISrcObj* as a parameter. CSinkObj will call
> this method right after creating CSinkAgg.
>> But before you do all this, reconsider the wisdom of using aggregation
> in the first place. Again, aggregation is appropriate when you want to
> reuse a component for which you don't have the source code or which you
> want to isolate in a separate module for some reason. It appears that
> you have source for all three components, and all three are implemented
> in the same module. In this case, regular C++ reuse techniques are much
> easier and more flexible.
> --
> With best wishes,
> Igor Tandetnik
>> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken
>>
- Next message: KJ: "Re: ATL DHTML reference problem"
- Previous message: Tony: "port problem"
- In reply to: Alexander Nickolov: "Re: How to access a C++ class object from the aggregated interface-class"
- Next in thread: Alexander Nickolov: "Re: How to access a C++ class object from the aggregated interface-class"
- Reply: Alexander Nickolov: "Re: How to access a C++ class object from the aggregated interface-class"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|