make a copy for multi-level component 
Author Message
 make a copy for multi-level component

hi..
i think the kernel of the question is how to use an
interface pointer.will you can give me a suggestion?
suppose..
interface ImeRectangle : IDispatch
{
[propget, id(1), ..] HRESULT l([out, retval] double *pVal);
[propput, id(1), ..] HRESULT l([in] double newVal);
[id(5), helpstring("method Copy"), hidden] HRESULT Copy
(ImeRectangle* irectangle);

Quote:
};

STDMETHODIMP CmeRectangle::Copy(ImeRectangle *irectangle)
{
double dblTmp;
irectangle->get_l(&dblTmp);
m_l=dblTmp;//m_l is a member variable to storage the
property
return S_OK;

Quote:
}

interface ImeFeature : IDispatch
{
[propget, ..] HRESULT Bounds([out, retval] ImeRectangle*
*pVal);
[propput, ..] HRESULT Bounds([in] ImeRectangle* newVal);
[id(11), helpstring("method Copy2"), hidden] HRESULT Copy2
([in] ImeFeature *p);

Quote:
};      

STDMETHODIMP CmeFeature::get_Bounds(ImeRectangle **pVal)
{
...
return m_pBounds->QueryInterface(IID_ImeRectangle,(void**)
pVal);
...

Quote:
}

STDMETHODIMP CmeFeature::put_Bounds(ImeRectangle *newVal)
{
        m_pBounds->Copy(newVal);
        return S_OK;
Quote:
}

how to make a copy from a CmeFeature to the other one?
for example, how to implement the method "Copy2" of
CmeFeature to make a copy?


Fri, 29 Apr 2005 15:49:52 GMT  
 make a copy for multi-level component
This depends on whether you want deep copy or shallow copy. E.g.
(JavaScript-like code):

var boundsRect = imeFeature.Bounds;
boundsRect.l = 123;

Do you want imeFeature.Bounds affected by the last statement? The way
you have coded get_Bounds, it will be. But the way you have coded
put_Bounds suggests you want each ImeFeature instance to have its own
copy of Bounds object. get_Bounds uses shallow copy, put_Bounds uses
deep copy. Decide which way you want it.

The same with Copy2. Consider this:

var imeFeatureCopy = imeFeature.Copy2;
imeFeatureCopy.Bounds.l = 123;
alert(imeFeature.Bounds.l);

What do you want to be shown? The original value of imeFeature.Bounds,
or 123? Depending on this, you need to perform a shallow copy (just copy
and AddRef the pointer) or deep copy (use Copy to initalize a separate
instance of ImeRectangle).
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> hi..
> i think the kernel of the question is how to use an
> interface pointer.will you can give me a suggestion?
> suppose..
> interface ImeRectangle : IDispatch
> {
> [propget, id(1), ..] HRESULT l([out, retval] double *pVal);
> [propput, id(1), ..] HRESULT l([in] double newVal);
> [id(5), helpstring("method Copy"), hidden] HRESULT Copy
> (ImeRectangle* irectangle);
> };

> STDMETHODIMP CmeRectangle::Copy(ImeRectangle *irectangle)
> {
> double dblTmp;
> irectangle->get_l(&dblTmp);
> m_l=dblTmp;//m_l is a member variable to storage the
> property
> return S_OK;
> }

> interface ImeFeature : IDispatch
> {
> [propget, ..] HRESULT Bounds([out, retval] ImeRectangle*
> *pVal);
> [propput, ..] HRESULT Bounds([in] ImeRectangle* newVal);
> [id(11), helpstring("method Copy2"), hidden] HRESULT Copy2
> ([in] ImeFeature *p);
> };

> STDMETHODIMP CmeFeature::get_Bounds(ImeRectangle **pVal)
> {
> ...
> return m_pBounds->QueryInterface(IID_ImeRectangle,(void**)
> pVal);
> ...
> }

> STDMETHODIMP CmeFeature::put_Bounds(ImeRectangle *newVal)
> {
> m_pBounds->Copy(newVal);
> return S_OK;
> }
> how to make a copy from a CmeFeature to the other one?
> for example, how to implement the method "Copy2" of
> CmeFeature to make a copy?



Sat, 30 Apr 2005 05:58:09 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. making sounds without low level assembler

2. Making a Dialog Remain Top Level

3. Multi-Level WinForm Inheritance Problem

4. Multi level macro definition

5. Multi-level break and elimination of GOTO

6. Multi-level break and elimination of G

7. Multi-level piped processes from C

8. Suggestions needed for MULTI-LEVEL SORTING.

9. Enabling multi-level undo in CRichEditView

10. C++ library for multi-level undo and transaction rollback

11. How to create multi-level toolbar???

12. warning messages using multi level map templates

 

 
Powered by phpBB® Forum Software