Show
Ignore:
Timestamp:
12/12/07 18:00:42 (9 months 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/Base/Field/OSGFieldTraits.h

    r1030 r1032  
    4343#endif 
    4444 
    45 #include "OSGIDString.h" 
    4645#include "OSGFieldForwards.h" 
     46#include "OSGFieldType.h" 
    4747#include "OSGLog.h" 
     48#include "OSGBinaryDataHandler.h" 
    4849#include "OSGContainerForwards.h" 
    4950 
     
    5455 
    5556OSG_BEGIN_NAMESPACE 
    56  
    57 class FieldType; 
    5857 
    5958#if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3) 
     
    465464}; 
    466465 
    467  
    468 namespace detail 
    469 { 
    470     template <class TypeT> 
    471     struct ExtractHandledSInternalField 
    472     { 
    473         typedef typename TypeT::HandledSInternalField type; 
    474     }; 
    475      
    476     template <class TypeT> 
    477     struct ExtractHandledSChildField 
    478     { 
    479         typedef typename TypeT::HandledSChildField type; 
    480     }; 
    481      
    482     template <class TypeT> 
    483     struct ExtractHandledSParentField 
    484     { 
    485         typedef typename TypeT::HandledSParentField type; 
    486     }; 
    487  
    488     template <class TypeT> 
    489     struct ExtractHandledSWeakField 
    490     { 
    491         typedef typename TypeT::HandledSWeakField type; 
    492     }; 
    493      
    494      
    495     template <class TypeT> 
    496     struct ExtractHandledMInternalField 
    497     { 
    498         typedef typename TypeT::HandledMInternalField type; 
    499     }; 
    500      
    501     template <class TypeT> 
    502     struct ExtractHandledMChildField 
    503     { 
    504         typedef typename TypeT::HandledMChildField type; 
    505     }; 
    506      
    507     template <class TypeT> 
    508     struct ExtractHandledMParentField 
    509     { 
    510         typedef typename TypeT::HandledMParentField type; 
    511     }; 
    512  
    513     template <class TypeT> 
    514     struct ExtractHandledMWeakField 
    515     { 
    516         typedef typename TypeT::HandledMWeakField type; 
    517     }; 
    518 } // namespace detail 
    519  
    520466struct FieldDescBase 
    521467{ 
     
    526472 
    527473template<class DescT,  
    528          enum  FieldCardinality FieldCardE, 
    529          enum  FieldCategory    FieldCatE  > 
     474         enum  FieldType::Cardinality FieldCardE> 
    530475class FieldDescription : public DescT::FieldDescParent 
    531476{ 
     
    533478 
    534479    typedef          FieldDescription<DescT, 
    535                                       FieldCardE, 
    536                                       FieldCatE  > Self; 
    537     typedef typename DescT::FieldDescParent        Inherited; 
    538  
    539     typedef typename EvalSwitch5< 
    540         FieldCatE == DataField, 
    541             boost::mpl::identity<SField<typename DescT::ValueType, 
    542                                                  DescT::iNamespace> >, 
    543         FieldCatE == InternalPointerField, 
    544             detail::ExtractHandledSInternalField<DescT>, 
    545         FieldCatE == ChildPointerField, 
    546             detail::ExtractHandledSChildField   <DescT>, 
    547         FieldCatE == ParentPointerField, 
    548             detail::ExtractHandledSParentField  <DescT>, 
    549         FieldCatE == WeakPointerField, 
    550             detail::ExtractHandledSWeakField    <DescT>, 
    551             boost::mpl::identity<void>                  >::type  HandledSField; 
    552      
    553     typedef typename EvalSwitch5< 
    554         FieldCatE == DataField, 
    555             boost::mpl::identity<MField<typename DescT::ValueType, 
    556                                                  DescT::iNamespace, 
    557                                         typename DescT::MFAlloc    > >, 
    558         FieldCatE == InternalPointerField, 
    559             detail::ExtractHandledMInternalField<DescT>, 
    560         FieldCatE == ChildPointerField, 
    561             detail::ExtractHandledMChildField   <DescT>, 
    562         FieldCatE == ParentPointerField, 
    563             detail::ExtractHandledMParentField  <DescT>, 
    564         FieldCatE == WeakPointerField, 
    565             detail::ExtractHandledMWeakField    <DescT>, 
    566             boost::mpl::identity<void>                   >::type HandledMField; 
    567      
    568     typedef typename  
    569         boost::mpl::if_c<FieldCardE == SingleField, 
    570                          HandledSField, 
    571                          HandledMField             >::type       HandledField; 
    572  
    573     typedef typename HandledField::GetHandle    GetHandle; 
    574     typedef typename HandledField::GetHandlePtr GetHandlePtr; 
    575  
    576     typedef typename HandledField::EditHandle    EditHandle; 
    577     typedef typename HandledField::EditHandlePtr EditHandlePtr; 
    578  
    579     struct SFieldFunctions 
    580     { 
    581         static void beginEdit(HandledField       *pField, 
    582                               UInt32              uiAspect, 
    583                               AspectOffsetStore  &oOffsets); 
    584  
    585         static bool isShared (HandledField       *pField  ); 
    586     }; 
    587  
    588     struct MFieldFunctions 
    589     { 
    590         static void beginEdit(HandledField       *pField, 
    591                               UInt32              uiAspect, 
    592                               AspectOffsetStore  &oOffsets); 
    593  
    594         static bool isShared (HandledField       *pField  ); 
    595     }; 
     480                                      FieldCardE>     Self; 
     481    typedef typename DescT::FieldDescParent           Inherited; 
     482 
     483    typedef typename boost::mpl::if_c< 
     484        FieldCardE == FieldType::SINGLE_FIELD, 
     485        SField<typename DescT::ValueType, 
     486                        DescT::iNamespace>, 
     487        MField<typename DescT::ValueType, 
     488                        DescT::iNamespace, 
     489               typename DescT::MFAlloc    >   >::type HandledField; 
     490 
     491    typedef typename HandledField::GetHandle          GetHandle; 
     492    typedef typename HandledField::GetHandlePtr       GetHandlePtr; 
     493 
     494    typedef typename HandledField::EditHandle         EditHandle; 
     495    typedef typename HandledField::EditHandlePtr      EditHandlePtr; 
    596496 
    597497    typedef typename 
    598         boost::mpl::if_<boost::mpl::bool_<(FieldCardE == SingleField)>, 
    599                          SFieldFunctions, 
    600                          MFieldFunctions>::type FieldFunctions; 
    601  
     498        boost::mpl::if_c< 
     499            FieldCardE == FieldType::SINGLE_FIELD, 
     500            typename Inherited::template SFieldFunctions<HandledField>, 
     501            typename Inherited::template MFieldFunctions<HandledField> >::type 
     502                                                      FieldFunctions; 
    602503 
    603504    virtual void beginEdit(Field              *pField, 
     
    611512    FieldDescription(const FieldType        &elementType, 
    612513                     const Char8            *szName, 
    613                      std::string             documentation, 
     514                     const std::string      &documentation, 
    614515                     const UInt32            uiFieldId, 
    615516                     const BitVector         vFieldMask, 
     
    617518                     const UInt32            uiFieldFlags, 
    618519                           FieldEditMethod   fEditMethod, 
    619                            FieldGetMethod    fGetMethod, 
    620                      const Char8            *defaultValue = NULL ); 
     520                           FieldGetMethod    fGetMethod    ); 
    621521 
    622522    FieldDescription(const FieldType            &elementType, 
    623523                     const Char8                *szName, 
    624                            std::string           documentation, 
     524                     const std::string          &documentation, 
    625525                     const UInt32                uiFieldId, 
    626526                     const BitVector             vFieldMask, 
     
    628528                     const UInt32                uiFieldFlags, 
    629529                           FieldIndexEditMethod  fIndexedEditMethod, 
    630                            FieldIndexGetMethod   fIndexedGetMethod, 
    631                      const Char8                *defaultValue = NULL ); 
     530                           FieldIndexGetMethod   fIndexedGetMethod  ); 
    632531 
    633532    FieldDescription(const FieldDescription &source); 
     
    643542    virtual FieldDescriptionBase *clone       (void         ) const; 
    644543 
    645     virtual GetFieldHandlePtr  createGetHandler (const Field *pField)
    646     virtual EditFieldHandlePtr createEditHandler(      Field *pField)
     544    virtual GetFieldHandlePtr  createGetHandler (Field const *pField) const
     545    virtual EditFieldHandlePtr createEditHandler(Field       *pField) const
    647546}; 
    648547