Show
Ignore:
Timestamp:
12/12/07 18:00:42 (1 year ago)
Author:
cneumann
Message:

added: generic interface
changed: factory functions return RefPtr?

The unittests don't pass right now, because of the change
to the factory functions, which leads to containers
being immediately destroyed as they are not assigned to
a RefPtr?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Source/System/FieldContainer/Base/OSGContainerDefines.h

    r874 r1032  
    181181 
    182182#define OSG_RC_CREATE_DECL                                                    \ 
    183     static ObjPtr create(void) 
     183    static ObjRefPtr create(void) 
    184184 
    185185#define OSG_RC_CREATE_EMPTY_DECL                                              \ 
     
    187187 
    188188#define OSG_FC_SHALLOWCOPY_DECL                                               \ 
    189     virtual OSG::FieldContainerPtr shallowCopy(void) const 
     189    virtual OSG::FieldContainerRefPtr shallowCopy(void) const 
    190190 
    191191#define OSG_FB_SHALLOWCOPY_DECL                                               \ 
     
    205205 
    206206#define OSG_FC_SHALLOWCOPY_DEF(OSG_CLASS)                                     \ 
    207     OSG::FieldContainerPtr OSG_CLASS::shallowCopy(void) const                 \ 
     207    OSG::FieldContainerRefPtr OSG_CLASS::shallowCopy(void) const              \ 
     208    {                                                                         \ 
     209        ObjPtr returnValue;                                                   \ 
     210                                                                              \ 
     211        newPtr<Self>(returnValue, this);                                      \ 
     212                                                                              \ 
     213        return FieldContainerRefPtr(returnValue);                             \ 
     214    }  
     215 
     216#define OSG_FB_SHALLOWCOPY_DEF(OSG_CLASS)                                     \ 
     217    OSG::FieldBundleP OSG_CLASS::shallowCopy(void) const                      \ 
    208218    {                                                                         \ 
    209219        ObjPtr returnValue;                                                   \ 
     
    214224    }  
    215225 
    216 #define OSG_FB_SHALLOWCOPY_DEF(OSG_CLASS)                                     \ 
    217     OSG::FieldBundleP OSG_CLASS::shallowCopy(void) const                      \ 
    218     {                                                                         \ 
    219         ObjPtr returnValue;                                                   \ 
    220                                                                               \ 
    221         newPtr<Self>(returnValue, this);                                      \ 
    222                                                                               \ 
    223         return returnValue;                                                   \ 
    224     }  
    225  
    226226#define OSG_FC_SHALLOWCOPY_TMPL_DEF(OSG_CLASS, OSG_TMPL_PARAM, INLINE)        \ 
    227227    template < class OSG_TMPL_PARAM > INLINE                                  \ 
    228     OSG::FieldContainerPtr                                                    \ 
     228    OSG::FieldContainerRefPtr                                                 \ 
    229229        OSG_CLASS< OSG_TMPL_PARAM >::shallowCopy(void) const                  \ 
    230230    {                                                                         \ 
     
    233233        Self::template newPtr<Self>(returnValue, this);                       \ 
    234234                                                                              \ 
    235         return returnValue;                                                   \ 
     235        return FieldContainerRefPtr(returnValue);                             \ 
    236236    } 
    237237 
     
    263263#define OSG_RC_CREATE_INL_DEF(OSG_CLASS)                                      \ 
    264264    inline                                                                    \ 
    265     OSG_CLASS::ObjPtr OSG_CLASS::create(void)                                 \ 
    266     {                                                                         \ 
    267         ObjPtr fc;                                                            \ 
     265    OSG_CLASS::ObjRefPtr OSG_CLASS::create(void)                              \ 
     266    {                                                                         \ 
     267        ObjRefPtr fc;                                                         \ 
    268268                                                                              \ 
    269269        if(getClassType().getPrototype() != OSGNullFC)                        \ 
    270          fc = dynamic_cast<Self::ObjPtr>(                                     \ 
    271              getClassType().getPrototype()->shallowCopy());                   \ 
     270            fc = boost::dynamic_pointer_cast<Self>(                           \ 
     271                getClassType().getPrototype()->shallowCopy());                \ 
    272272                                                                              \ 
    273273        return fc;                                                            \ 
     
    276276#define OSG_FC_CREATE_TMPL_DEF(OSG_CLASS, OSG_TMPL_PARAM, INLINE)             \ 
    277277    template < class OSG_TMPL_PARAM > INLINE                                  \ 
    278     typename OSG_CLASS < OSG_TMPL_PARAM >::ObjPtr                             \ 
     278    typename OSG_CLASS < OSG_TMPL_PARAM >::ObjRefPtr                          \ 
    279279        OSG_CLASS< OSG_TMPL_PARAM >::create(void)                             \ 
    280280    {                                                                         \ 
    281         ObjPtr fc;                                                            \ 
     281        ObjRefPtr fc;                                                         \ 
    282282                                                                              \ 
    283283        if(getClassType().getPrototype() != OSGNullFC)                        \ 
    284284        {                                                                     \ 
    285          OSG::FieldContainerPtr temp_ptr =                                    \ 
    286              getClassType().getPrototype()->shallowCopy();                    \ 
    287          fc = dynamic_cast<typename Self::ObjPtr>(temp_ptr);                  \ 
     285            fc = boost::dynamic_pointer_cast<Self>(                           \ 
     286                getClassType().getPrototype()->shallowCopy());                \ 
    288287        }                                                                     \ 
    289288                                                                              \ 
     
    300299        if(getClassType().getPrototype() != OSGNullFC)                        \ 
    301300        {                                                                     \ 
    302          OSG::FieldBundleP temp_ptr =                                         \ 
    303              getClassType().getPrototype()->shallowCopy();                    \ 
    304          fc = dynamic_cast<typename Self::ObjPtr>(temp_ptr);                  \ 
     301            fc = dynamic_cast<Self::ObjPtr>(                                  \ 
     302                getClassType().getPrototype()->shallowCopy());                \ 
    305303        }                                                                     \ 
    306304                                                                              \ 
     
    323321#define OSG_FC_CREATE_SPECIALIZED_TMPL_DEF(OSG_CLASS, OSG_TMPL_PARAM)         \ 
    324322    template <> OSG_DLL_EXPORT                                                \ 
    325     OSG_CLASS < OSG_TMPL_PARAM >::ObjPtr                                      \ 
     323    OSG_CLASS < OSG_TMPL_PARAM >::ObjRefPtr                                   \ 
    326324        OSG_CLASS< OSG_TMPL_PARAM >::create(void)                             \ 
    327325    {                                                                         \ 
    328         ObjPtr fc;                                                            \ 
     326        ObjRefPtr fc;                                                         \ 
    329327                                                                              \ 
    330328        if(getClassType().getPrototype() != OSGNullFC)                        \ 
    331329        {                                                                     \ 
    332          OSG::FieldContainerPtr temp_ptr =                                    \ 
    333              getClassType().getPrototype()->shallowCopy();                    \ 
    334          fc = dynamic_cast<Self::ObjPtr>(temp_ptr);                           \ 
     330            fc = boost::dynamic_pointer_cast<Self>(                           \ 
     331                getClassType().getPrototype()->shallowCopy());                \ 
    335332        }                                                                     \ 
    336333                                                                              \