X3DTypeFunctions.h

00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00024 //
00026 
00027 #ifndef __X3DTYPEFUNCTIONS_H__
00028 #define __X3DTYPEFUNCTIONS_H__
00029 
00030 #include "X3DTypes.h"
00031 #include "FieldTemplates.h"
00032 #include "SFNode.h"
00033 #include "MFNode.h"
00034 #include "SFFloat.h"
00035 #include "MFFloat.h"
00036 #include "SFDouble.h"
00037 #include "MFDouble.h"
00038 #include "SFTime.h"
00039 #include "MFTime.h"
00040 #include "SFInt32.h"
00041 #include "MFInt32.h"
00042 #include "SFVec2f.h"
00043 #include "MFVec2f.h"
00044 #include "SFVec3f.h"
00045 #include "MFVec3f.h"
00046 #include "SFVec4f.h"
00047 #include "MFVec4f.h"
00048 #include "SFVec2d.h"
00049 #include "MFVec2d.h"
00050 #include "SFVec3d.h"
00051 #include "MFVec3d.h"
00052 #include "SFVec4d.h"
00053 #include "MFVec4d.h"
00054 #include "SFBool.h"
00055 #include "MFBool.h"
00056 #include "SFString.h"
00057 #include "MFString.h"
00058 #include "SFColor.h"
00059 #include "MFColor.h"
00060 #include "SFColorRGBA.h"
00061 #include "MFColorRGBA.h"
00062 #include "SFRotation.h"
00063 #include "MFRotation.h"
00064 #include "SFQuaternion.h"
00065 #include "MFQuaternion.h"
00066 #include "SFMatrix3f.h"
00067 #include "MFMatrix3f.h"
00068 #include "SFMatrix3d.h"
00069 #include "MFMatrix3d.h"
00070 #include "SFMatrix4f.h"
00071 #include "MFMatrix4f.h"
00072 #include "SFMatrix4d.h"
00073 #include "MFMatrix4d.h"
00074 
00075 namespace H3D {
00076   namespace X3DTypes {
00077     inline const char* typeToString( X3DType t ) {
00078       switch( t ) {
00079       case     SFFLOAT: return "SFFloat";
00080       case     MFFLOAT: return "MFFloat";
00081       case    SFDOUBLE: return "SFDouble";
00082       case    MFDOUBLE: return "MFDouble";
00083       case      SFTIME: return "SFTime";
00084       case      MFTIME: return "MFTime";
00085       case     SFINT32: return "SFInt32";
00086       case     MFINT32: return "MFInt32";
00087       case     SFVEC2F: return "SFVec2f";
00088       case     MFVEC2F: return "MFVec2f";
00089       case     SFVEC2D: return "SFVec2d";
00090       case     MFVEC2D: return "MFVec2d";
00091       case     SFVEC3F: return "SFVec3f";
00092       case     MFVEC3F: return "MFVec3f";
00093       case     SFVEC3D: return "SFVec3d";
00094       case     MFVEC3D: return "MFVec3d";
00095       case     SFVEC4F: return "SFVec4f";
00096       case     MFVEC4F: return "MFVec4f";
00097       case     SFVEC4D: return "SFVec4d";
00098       case     MFVEC4D: return "MFVec4d";
00099       case      SFBOOL: return "SFBool";
00100       case      MFBOOL: return "MFBool";
00101       case    SFSTRING: return "SFString";
00102       case    MFSTRING: return "MFString";
00103       case      SFNODE: return "SFNode";
00104       case      MFNODE: return "MFNode";
00105       case     SFCOLOR: return "SFColor";
00106       case     MFCOLOR: return "MFColor";
00107       case SFCOLORRGBA: return "SFColorRGBA";
00108       case MFCOLORRGBA: return "MFColorRGBA";
00109       case  SFROTATION: return "SFRotation";
00110       case  MFROTATION: return "MFRotation";
00111       case  SFQUATERNION: return "SFQuaternion";
00112       case  MFQUATERNION: return "MFQuaternion";
00113       case  SFMATRIX3F: return "SFMatrix3f";
00114       case  MFMATRIX3F: return "MFMatrix3f";
00115       case  SFMATRIX4F: return "SFMatrix4f";
00116       case  MFMATRIX4F: return "MFMatrix4f";
00117       case  SFMATRIX3D: return "SFMatrix3d";
00118       case  MFMATRIX3D: return "MFMatrix3d";
00119       case  SFMATRIX4D: return "SFMatrix4d";
00120       case  MFMATRIX4D: return "MFMatrix4d";
00121       case UNKNOWN_X3D_TYPE: 
00122       default:return "UNKNOWN_X3D_TYPE";
00123       };
00124     }
00125 
00126     inline X3DType stringToType( const char *t ) {
00127       if( strcmp( t, "SFFloat" ) == 0 ) return SFFLOAT;
00128       else if( strcmp( t, "MFFloat" ) == 0 ) return MFFLOAT;
00129       else if( strcmp( t, "SFDouble" ) == 0 ) return SFDOUBLE;
00130       else if( strcmp( t, "MFDouble" ) == 0 ) return MFDOUBLE;
00131       else if( strcmp( t, "SFTime" ) == 0 ) return SFTIME;
00132       else if( strcmp( t, "MFTime" ) == 0 ) return MFTIME;
00133       else if( strcmp( t, "SFInt32" ) == 0 ) return SFINT32;
00134       else if( strcmp( t, "MFInt32" ) == 0 ) return MFINT32;
00135       else if( strcmp( t, "SFVec2f" ) == 0 ) return SFVEC2F;
00136       else if( strcmp( t, "MFVec2f" ) == 0 ) return MFVEC2F;
00137       else if( strcmp( t, "SFVec3f" ) == 0 ) return SFVEC3F;
00138       else if( strcmp( t, "MFVec3f" ) == 0 ) return MFVEC3F;
00139       else if( strcmp( t, "SFVec4f" ) == 0 ) return SFVEC4F;
00140       else if( strcmp( t, "MFVec4f" ) == 0 ) return MFVEC4F;
00141       else if( strcmp( t, "SFVec2d" ) == 0 ) return SFVEC2D;
00142       else if( strcmp( t, "MFVec2d" ) == 0 ) return MFVEC2D;
00143       else if( strcmp( t, "SFVec3d" ) == 0 ) return SFVEC3D;
00144       else if( strcmp( t, "MFVec3d" ) == 0 ) return MFVEC3D;
00145       else if( strcmp( t, "SFVec4d" ) == 0 ) return SFVEC4D;
00146       else if( strcmp( t, "MFVec4d" ) == 0 ) return MFVEC4D;
00147       else if( strcmp( t, "SFBool" ) == 0 ) return SFBOOL;
00148       else if( strcmp( t, "MFBool" ) == 0 ) return MFBOOL;
00149       else if( strcmp( t, "SFString" ) == 0 ) return SFSTRING;
00150       else if( strcmp( t, "MFString" ) == 0 ) return MFSTRING;
00151       else if( strcmp( t, "SFNode" ) == 0 ) return SFNODE;
00152       else if( strcmp( t, "MFNode" ) == 0 ) return MFNODE;
00153       else if( strcmp( t, "SFColor" ) == 0 ) return SFCOLOR;
00154       else if( strcmp( t, "MFColor" ) == 0 ) return MFCOLOR;
00155       else if( strcmp( t, "SFColorRGBA" ) == 0 ) return SFCOLORRGBA;
00156       else if( strcmp( t, "MFColorRGBA" ) == 0 ) return MFCOLORRGBA;
00157       else if( strcmp( t, "SFRotation" ) == 0 ) return SFROTATION;
00158       else if( strcmp( t, "MFRotation" ) == 0 ) return MFROTATION;
00159       else if( strcmp( t, "SFQuaternion" ) == 0 ) return SFQUATERNION;
00160       else if( strcmp( t, "MFQuaternion" ) == 0 ) return MFQUATERNION;
00161       else if( strcmp( t, "SFMatrix3f" ) == 0 ) return SFMATRIX3F;
00162       else if( strcmp( t, "MFMatrix3f" ) == 0 ) return MFMATRIX3F;
00163       else if( strcmp( t, "SFMatrix4f" ) == 0 ) return SFMATRIX4F;
00164       else if( strcmp( t, "MFMatrix4f" ) == 0 ) return MFMATRIX4F;
00165       else if( strcmp( t, "SFMatrix3d" ) == 0 ) return SFMATRIX3D;
00166       else if( strcmp( t, "MFMatrix3d" ) == 0 ) return MFMATRIX3D;
00167       else if( strcmp( t, "SFMatrix4d" ) == 0 ) return SFMATRIX4D;
00168       else if( strcmp( t, "MFMatrix4d" ) == 0 ) return MFMATRIX4D;
00169       else return UNKNOWN_X3D_TYPE;
00170     };
00171 
00172     inline Field *newFieldInstance( X3DTypes::X3DType t ) {
00173       switch( t ) {
00174       case X3DTypes::SFFLOAT: 
00175         return new SFFloat;
00176       case X3DTypes::MFFLOAT: 
00177         return new MFFloat;
00178       case X3DTypes::SFDOUBLE:
00179         return new SFDouble;
00180       case X3DTypes::MFDOUBLE:
00181         return new MFDouble;
00182       case X3DTypes::SFTIME:  
00183         return new SFTime;
00184       case X3DTypes::MFTIME:  
00185         return new MFTime;
00186       case X3DTypes::SFINT32: 
00187         return new SFInt32;
00188       case X3DTypes::MFINT32: 
00189         return new MFInt32;
00190       case X3DTypes::SFVEC2F: 
00191         return new SFVec2f;
00192       case X3DTypes::MFVEC2F: 
00193         return new MFVec2f;
00194       case X3DTypes::SFVEC2D: 
00195         return new SFVec2d;
00196       case X3DTypes::MFVEC2D: 
00197         return new MFVec2d;
00198       case X3DTypes::SFVEC3F: 
00199         return new SFVec3f;
00200       case X3DTypes::MFVEC3F: 
00201         return new MFVec3f;
00202       case X3DTypes::SFVEC3D: 
00203         return new SFVec3f;
00204       case X3DTypes::MFVEC3D: 
00205         return new MFVec3d;
00206       case X3DTypes::SFVEC4F: 
00207         return new SFVec4f;
00208       case X3DTypes::MFVEC4F: 
00209         return new MFVec4f;
00210       case X3DTypes::SFVEC4D: 
00211         return new SFVec4f;
00212       case X3DTypes::MFVEC4D: 
00213         return new MFVec4d;
00214       case X3DTypes::SFBOOL:  
00215         return new SFBool;
00216       case X3DTypes::MFBOOL:  
00217         return new MFBool;
00218       case X3DTypes::SFSTRING:
00219         return new SFString;
00220       case X3DTypes::MFSTRING:
00221         return new MFString;
00222       case X3DTypes::SFNODE:
00223         return new SFNode;
00224       case X3DTypes::MFNODE:
00225         return new MFNode;
00226       case X3DTypes::SFCOLOR:   
00227         return new SFColor;
00228       case X3DTypes::MFCOLOR:   
00229         return new MFColor;
00230       case X3DTypes::SFCOLORRGBA:    
00231         return new SFColorRGBA;
00232       case X3DTypes::MFCOLORRGBA:    
00233         return new MFColorRGBA;
00234       case X3DTypes::SFROTATION:
00235         return new SFRotation;
00236       case X3DTypes::MFROTATION:
00237         return new MFRotation;
00238       case X3DTypes::SFQUATERNION:
00239         return new SFQuaternion;
00240       case X3DTypes::MFQUATERNION:
00241         return new MFQuaternion;
00242       case X3DTypes::SFMATRIX3F:
00243         return new SFMatrix3f;
00244       case X3DTypes::MFMATRIX3F:
00245         return new MFMatrix3f;
00246       case X3DTypes::SFMATRIX4F:
00247         return new SFMatrix4f;
00248       case X3DTypes::MFMATRIX4F:
00249         return new MFMatrix4f;
00250       case X3DTypes::SFMATRIX3D:
00251         return new SFMatrix3d;
00252       case X3DTypes::MFMATRIX3D:
00253         return new MFMatrix3d;
00254       case X3DTypes::SFMATRIX4D:
00255         return new SFMatrix4d;
00256       case X3DTypes::MFMATRIX4D:
00257         return new MFMatrix4d;
00258       case X3DTypes::UNKNOWN_X3D_TYPE: 
00259       default: return NULL;
00260       }
00261     };
00262 
00263     inline Field *newFieldInstance( const char *t ) {
00264       return newFieldInstance( stringToType( t ) );
00265     };
00266       
00267   }
00268 }
00269 
00270 #endif

Generated on Thu Aug 24 12:38:35 2006 for H3D API by  doxygen 1.4.5