OSGMFieldAdaptor.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *           Copyright (C) 2003 by the OpenSG Forum                          *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGMFIELDADAPTOR_H_
00040 #define _OSGMFIELDADAPTOR_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include "OSGBaseTypes.h"
00046 
00047 OSG_BEGIN_NAMESPACE
00048 
00052 template<class ValueT, class ParentT, Int32 iNamespace = 0>
00053 class MFieldAdaptor : public ParentT
00054 {
00055     /*==========================  PUBLIC  =================================*/
00056 
00057   public:
00058 
00059     typedef          MFieldAdaptor<ValueT, 
00060                                    ParentT,
00061                                    iNamespace>          Self;
00062 
00063     typedef          MFieldVector <ValueT    >          StorageType;
00064 
00065     typedef typename StorageType::reference             reference;
00066     typedef typename StorageType::const_reference       const_reference;
00067 
00068     typedef typename StorageType::iterator              iterator;
00069     typedef typename StorageType::const_iterator        const_iterator;
00070 
00071     typedef typename 
00072                     StorageType::reverse_iterator       reverse_iterator;
00073     typedef typename 
00074                     StorageType::const_reverse_iterator const_reverse_iterator;
00075 
00076 
00077     typedef          FieldTraits      <ValueT, 
00078                                        iNamespace>      MFieldTraits;
00079 
00080     typedef typename MFieldTraits::ArgumentType         ArgumentType;
00081 
00082     typedef typename
00083     boost::mpl::if_<boost::mpl::bool_<MFieldTraits::bIsPointerField>,
00084                     EditFCPtrMFieldHandle<Self>,
00085                     EditMFieldHandle     <Self>  >::type  EditHandle;
00086 
00087     typedef boost::shared_ptr<EditHandle> EditHandlePtr;
00088 
00089     typedef typename
00090     boost::mpl::if_<boost::mpl::bool_<MFieldTraits::bIsPointerField>,
00091                     GetFCPtrMFieldHandle<Self> ,
00092                     GetMFieldHandle     <Self> >::type  GetHandle;
00093 
00094     typedef boost::shared_ptr<GetHandle> GetHandlePtr;
00095 
00096     /*---------------------------------------------------------------------*/
00100     static const FieldType &getClassType(void);
00101 
00103     /*---------------------------------------------------------------------*/
00108     /*---------------------------------------------------------------------*/
00113     /*---------------------------------------------------------------------*/
00117     MFieldAdaptor(void);
00118     MFieldAdaptor(const MFieldAdaptor &source);
00119 
00121     /*---------------------------------------------------------------------*/
00125     ~MFieldAdaptor(void);
00126 
00128     /*---------------------------------------------------------------------*/
00132           reference operator [](UInt32 index);
00133     const_reference operator [](UInt32 index) const;
00134 
00136     /*---------------------------------------------------------------------*/
00140     iterator               begin    (void                              );
00141     iterator               end      (void                              );
00142 
00143     reverse_iterator       rbegin   (void                              );
00144     reverse_iterator       rend     (void                              );
00145 
00146     
00147     const_iterator         begin    (void                              ) const;
00148     const_iterator         end      (void                              ) const;
00149     
00150     const_reverse_iterator rbegin   (void                              ) const;
00151     const_reverse_iterator rend     (void                              ) const;
00152 
00153     reference              front    (void                              );
00154     const_reference        front    (void                              ) const;
00155     
00156     reference              back     (void                              );
00157     const_reference        back     (void                              ) const;
00158 
00159     iterator               insert   (iterator     pos, 
00160                                      ArgumentType value                );
00161     iterator               erase    (iterator     pos                  );
00162     
00163     iterator               find     (ArgumentType value                );
00164     const_iterator         find     (ArgumentType value                ) const;
00165 
00167     /*---------------------------------------------------------------------*/
00171           StorageType &getValues(void);
00172     const StorageType &getValues(void) const;
00173 
00175     /*---------------------------------------------------------------------*/
00180     /*---------------------------------------------------------------------*/
00185     /*---------------------------------------------------------------------*/
00190     /*---------------------------------------------------------------------*/
00195     /*---------------------------------------------------------------------*/
00200     /*---------------------------------------------------------------------*/
00205     /*---------------------------------------------------------------------*/
00210     /*---------------------------------------------------------------------*/
00215     /*=========================  PROTECTED  ===============================*/
00216 
00217   protected:
00218 
00219     /*---------------------------------------------------------------------*/
00223     static FieldType _fieldType;
00224 
00226     /*---------------------------------------------------------------------*/
00230 #ifdef OSG_LINUX_ICC
00231 #pragma warning( disable : 488 )
00232 #endif
00233 
00234     template<class To>
00235           To &dcast(void);
00236 
00237     template<class To>
00238     const To &dcast(void) const;
00239 
00240 #ifdef OSG_LINUX_ICC
00241 #pragma warning( default : 488 )
00242 #endif
00243 
00245     /*---------------------------------------------------------------------*/
00250     /*---------------------------------------------------------------------*/
00255     /*---------------------------------------------------------------------*/
00260     /*---------------------------------------------------------------------*/
00264 #if defined(OSG_TMPL_STATIC_MEMBER_NEEDS_HELPER_FCT)
00265     const FieldType &fieldTypeExportHelper(void);
00266 #endif
00267 
00269     /*==========================  PRIVATE  ================================*/
00270 
00271   private:
00272 
00273     typedef ParentT Inherited;
00274 
00276     void operator =(const MFieldAdaptor &source);
00277 };
00278 
00279 OSG_END_NAMESPACE
00280 
00281 #include "OSGMFieldAdaptor.inl"
00282 
00283 #endif /* _OSGMFIELDADAPTOR_H_ */