OSGSFieldAdaptor.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 _OSGSFIELDADAPTOR_H_
00040 #define _OSGSFIELDADAPTOR_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include "OSGBaseTypes.h"
00046 #include "OSGFieldTraits.h"
00047 
00048 OSG_BEGIN_NAMESPACE
00049 
00053 template<class ValueT, class ParentT, Int32 iNamespace = 0>
00054 class SFieldAdaptor : public ParentT
00055 {
00056     /*==========================  PUBLIC  =================================*/
00057 
00058   public:
00059 
00060     typedef          SFieldAdaptor    <ValueT, 
00061                                        ParentT, 
00062                                        iNamespace>  Self;
00063 
00064     typedef          ValueT                         StoredType;
00065     typedef          ValueT                        &reference;
00066     typedef const    ValueT                        &const_reference;
00067 
00068     typedef          FieldTraits      <ValueT, 
00069                                        iNamespace>  SFieldTraits;
00070 
00071     typedef typename SFieldTraits::ArgumentType        ArgumentType;
00072 
00073     typedef typename
00074     boost::mpl::if_<boost::mpl::bool_<SFieldTraits::bIsPointerField>,
00075                     EditFCPtrSFieldHandle<Self>,
00076                     EditSFieldHandle     <Self>  >::type  EditHandle;
00077 
00078     typedef boost::shared_ptr<EditHandle> EditHandlePtr;
00079 
00080     typedef typename
00081     boost::mpl::if_<boost::mpl::bool_<SFieldTraits::bIsPointerField>,
00082                     GetFCPtrSFieldHandle<Self> ,
00083                     GetSFieldHandle     <Self> >::type  GetHandle;
00084 
00085     typedef boost::shared_ptr<GetHandle> GetHandlePtr;
00086 
00087     /*---------------------------------------------------------------------*/
00091     static const FieldType &getClassType(void);
00092 
00094     /*---------------------------------------------------------------------*/
00099     /*---------------------------------------------------------------------*/
00104     /*---------------------------------------------------------------------*/
00108              SFieldAdaptor(void                       );
00109              SFieldAdaptor(const SFieldAdaptor &source);
00110     explicit SFieldAdaptor(      ArgumentType   value );
00111 
00113     /*---------------------------------------------------------------------*/
00117     ~SFieldAdaptor(void);
00118 
00120     /*---------------------------------------------------------------------*/
00124           reference getValue(void);
00125     const_reference getValue(void) const;
00126 
00128     /*---------------------------------------------------------------------*/
00133     /*---------------------------------------------------------------------*/
00138     /*---------------------------------------------------------------------*/
00143     /*---------------------------------------------------------------------*/
00148     /*---------------------------------------------------------------------*/
00153     /*---------------------------------------------------------------------*/
00158     /*---------------------------------------------------------------------*/
00163     /*---------------------------------------------------------------------*/
00168     /*---------------------------------------------------------------------*/
00173     /*=========================  PROTECTED  ===============================*/
00174 
00175   protected:
00176 
00177     /*---------------------------------------------------------------------*/
00181     static FieldType _fieldType;
00182 
00184     /*---------------------------------------------------------------------*/
00188 #ifdef OSG_LINUX_ICC
00189 #pragma warning( disable : 488 )
00190 #endif
00191 
00192     template<class To>
00193           To &dcast(void);
00194 
00195     template<class To>
00196     const To &dcast(void) const;
00197 
00198 #ifdef OSG_LINUX_ICC
00199 #pragma warning( default : 488 )
00200 #endif
00201 
00203     /*---------------------------------------------------------------------*/
00208     /*---------------------------------------------------------------------*/
00213     /*---------------------------------------------------------------------*/
00218     /*---------------------------------------------------------------------*/
00222 #if defined(OSG_TMPL_STATIC_MEMBER_NEEDS_HELPER_FCT)
00223     const FieldType &fieldTypeExportHelper(void);
00224 #endif
00225 
00227     /*==========================  PRIVATE  ================================*/
00228 
00229   private:
00230 
00231     typedef ParentT Inherited;
00232 
00234     void operator =(const SFieldAdaptor &source);
00235 };
00236 
00237 OSG_END_NAMESPACE
00238 
00239 #include "OSGSFieldAdaptor.inl"
00240 
00241 #endif /* _OSGSFIELDADAPTOR_H_ */