00001 #ifndef _OSGQBIT_H_
00002 #define _OSGQBIT_H_
00003
00004 #ifdef __sgi
00005 #pragma once
00006 #endif
00007
00008 #include <OSGConfig.h>
00009 #include <OSGSystemDef.h>
00010 #include <OSGBase.h>
00011
00012 #include <OSGBaseTypes.h>
00013 #include <OSGMField.h>
00014 #include <OSGSField.h>
00015
00016
00017 OSG_BEGIN_NAMESPACE
00018
00024 typedef UInt8 QBit;
00025
00032 template <>
00033 struct FieldDataTraits1<QBit> :
00034 public FieldTraitsIntegralRecurseMapper<QBit>
00035 {
00036 static DataType _type;
00037
00038 enum { StringConvertable = ToStringConvertable |
00039 FromStringConvertable };
00040
00041 static DataType &getType (void) { return _type; }
00042
00043 static Char8 *getSName (void) { return "SFQBit"; }
00044 static Char8 *getMName (void) { return "MFQBit"; }
00045
00046 static QBit getDefault (void) { return 0; }
00047
00048 static QBit getFromString( QBit &outVal,
00049 const Char8 *&inVal)
00050 {
00051 if(inVal == NULL)
00052 return 0;
00053
00054 if(inVal[0] == 'T' || inVal[0] == 't')
00055 {
00056 if(inVal[1] != 'R' && inVal[1] != 'r')
00057 {
00058 return 0;
00059 }
00060
00061 if(inVal[2] != 'U' && inVal[2] != 'u')
00062 {
00063 return 0;
00064 }
00065
00066 if(inVal[3] != 'E' && inVal[3] != 'e')
00067 {
00068 return 0;
00069 }
00070
00071 outVal = 1;
00072 }
00073 else if(inVal[0] == 'F' || inVal[0] == 'f')
00074 {
00075 if(inVal[1] != 'A' && inVal[1] != 'a')
00076 {
00077 return 0;
00078 }
00079
00080 if(inVal[2] != 'L' && inVal[2] != 'l')
00081 {
00082 return 0;
00083 }
00084
00085 if(inVal[3] != 'S' && inVal[3] != 's')
00086 {
00087 return 0;
00088 }
00089
00090 if(inVal[4] != 'E' && inVal[4] != 'e')
00091 {
00092 return 0;
00093 }
00094
00095 outVal = 0;
00096 }
00097 else if(inVal[0] == 'A' || inVal[0] == 'a')
00098 {
00099 if(inVal[1] != 'U' && inVal[1] != 'u')
00100 {
00101 return 0;
00102 }
00103
00104 if(inVal[2] != 'T' && inVal[2] != 't')
00105 {
00106 return 0;
00107 }
00108
00109 if(inVal[3] != 'O' && inVal[3] != 'o')
00110 {
00111 return 0;
00112 }
00113
00114 outVal = 2;
00115 }
00116 else
00117 {
00118 return 0;
00119 }
00120
00121 return outVal;
00122 }
00123
00124
00125 static void putToString (const QBit &inVal,
00126 std::string &outStr)
00127 {
00128 if(inVal == 1)
00129 {
00130 outStr.assign("TRUE");
00131 }
00132 else if(inVal == 0)
00133 {
00134 outStr.assign("FALSE");
00135 }
00136 else
00137 {
00138 outStr.assign("AUTO");
00139 }
00140 }
00141 };
00142
00147 typedef SField<QBit, 1> SFQBit;
00148
00149 #ifndef OSG_COMPILEQBITFIELDINST
00150 OSG_DLLEXPORT_DECL2(SField, QBit, 1, OSG_SYSTEMLIB_DLLTMPLMAPPING)
00151 #endif
00152
00153
00158 typedef MField<QBit, 1> MFQBit;
00159
00160 #ifndef OSG_COMPILEQBITFIELDINST
00161 OSG_DLLEXPORT_DECL2(MField, QBit, 1, OSG_SYSTEMLIB_DLLTMPLMAPPING)
00162 #endif
00163
00164 OSG_END_NAMESPACE
00165
00166 #endif