Copy policy for CAdapt<CComPtr<T>> 
Author Message
 Copy policy for CAdapt<CComPtr<T>>

I've created a copy policy class for a collection based on the
following STL map:

typedef std::map< CAdapt< CComBSTR >, CAdapt< CComPtr<IAObject> >
ContainerType;

Should I need to do anything in the init and destroy functions?  Or as
I'm using CComPtr's are they okay doing nothing?

class _CopyMapItem
{
public:
        static HRESULT copy(IAObject** pTo, ContainerType::value_type* pFrom)
        {
                CComPtr<IAObject> pTemp = pFrom->second.m_T;

                return pTemp.CopyTo(pTo);
        }

        static void init(IAObject** p) { ; }
        static void destroy(IAObject** p) { ; }

Quote:
};

Thanks in advance for your help,

Neil Blackburn



Sat, 19 Feb 2005 20:43:30 GMT  
 Copy policy for CAdapt<CComPtr<T>>

Quote:

> I've created a copy policy class for a collection based on the
> following STL map:

> typedef std::map< CAdapt< CComBSTR >, CAdapt< CComPtr<IAObject> >
> ContainerType;

> Should I need to do anything in the init and destroy functions?  Or as
> I'm using CComPtr's are they okay doing nothing?

You don't need to do init and destroy on the copy-to-CComPtr copy
policy, but you will also need a copy-to-raw pointer copy policy, and
this will require init and destroy.

e.g.
    template <class Interface>
    struct collection_copy_out
    {
        typedef Interface*                    destination_type;
        typedef CAdapt<CComPtr<Interface> >   source_type;

        static void init(destination_type* p) {
            _CopyInterface<Interface>::init(p);
        }

        static void destroy(destination_type* p) {
            _CopyInterface<Interface>::destroy(p);
        }

        static HRESULT copy(destination_type * pTo,
                            source_type const* pFrom) {
            // Have to use an intermediate because CopyTo is not const.
            CComPtr<Interface> ptrDest = pFrom->m_T;
            return ptrDest.CopyTo(pTo);
        }
    };



Sat, 19 Feb 2005 21:37:17 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. <<<<<<<Parsing help, please>>>>>>>>

2. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

3. <<<>>>Need C code advice with functions and sorting.<<<>>>

4. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

5. >>>Windows Service<<<

6. proposal: <basic.h>, <pascal.h>, <fortran.h>, <cobol.h>

7. <<<< C Grammar for yacc needed >>>>

8. - - - = = =<><> W e b - U S A <><>= = = - - -

9. >>>> * Get keypress * <<<<

10. <Ctrl>+<Key>

11. <<testing>>

12. >>I need help!<<(duh)

 

 
Powered by phpBB® Forum Software