Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGBaseTypeTraits.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *           Copyright (C) 2000-2002,2002 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 _OSGBASETYPETRAITS_H_
00040 #define _OSGBASETYPETRAITS_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #ifndef _OSGBASETYPES_H_
00046 #error not for direct use, please include OSGBaseTypes.h instead
00047 #endif
00048 
00049 #include <OSGGL.h>
00050 #include <limits>
00051 
00052 // The undef's are needed otherwise the numeric_limits won't work (GV)
00053 
00054 #if defined(max)
00055 #undef max
00056 #endif
00057 
00058 #if defined(min)
00059 #undef min
00060 #endif
00061 
00062 OSG_BEGIN_NAMESPACE
00063 
00067 struct OSG_BASE_DLLMAPPING TypeTraitsBase
00068 {
00069 #ifdef GV_CHECK_CHECK
00070     static const  bool               IsPOD    = true;
00071     static const  MathTypeProperties MathProp = BoolValue;
00072 
00073     static const  bool               BitsSet     = true ;
00074     static const  bool               BitsClear   = false;
00075 
00076     static        bool              getZeroElement(void)
00077     {
00078         return false;
00079     }
00080 
00081     static        bool              getOneElement (void)
00082     {
00083         return true;
00084     }
00085 
00086     static        bool              getMax        (void)
00087     {
00088         return true;
00089     }
00090 
00091     static        bool              getMin        (void)
00092     {
00093         return false;
00094     }
00095 #endif
00096 };
00097 
00101 template <class LookupTypeT>
00102 struct TypeTraits : public TypeTraitsBase
00103 {
00104     static const bool IsPOD = false;
00105 
00106 #ifdef OSG_MICROSOFT_COMPILER_HACKS
00107     typedef LookupTypeT RealReturnType;
00108 #endif
00109 };
00110 
00111 #if defined(__hpux)
00112 template <class LookupTypeT> 
00113 const bool TypeTraits<LookupTypeT>::IsPOD;
00114 #endif
00115 
00116 
00120 template <>
00121 struct TypeTraits<bool> : public TypeTraitsBase
00122 {
00123     static const  bool               IsPOD     = true;
00124     static const  MathTypeProperties MathProp  = BoolValue;
00125 
00126     static const  bool               BitsSet   = true ;
00127     static const  bool               BitsClear = false;
00128 
00129 
00130     static        bool               getZeroElement(void)
00131     {
00132         return false;
00133     }
00134 
00135     static        bool               getOneElement (void)
00136     {
00137         return true;
00138     }
00139 
00140     static        bool               getMax        (void)
00141     {
00142         return true;
00143     }
00144 
00145     static        bool               getMin        (void)
00146     {
00147         return false;
00148     }
00149 };
00150 
00151 
00155 template <>
00156 struct TypeTraits<UInt8> : public TypeTraitsBase
00157 {
00158     typedef       Real32             RealReturnType;
00159 
00160 
00161     static const  bool               IsPOD     = true;
00162     static const  MathTypeProperties MathProp  = IntValue;
00163 
00164     static const  UInt8              BitsSet   = 0xFF;
00165     static const  UInt8              BitsClear = 0x00;
00166 
00167 
00168     static        UInt8              getZeroElement(void)
00169     {
00170         return 0;
00171     }
00172 
00173     static        UInt8              getOneElement (void)
00174     {
00175         return 1;
00176     }
00177 
00178     static        UInt8              getMax        (void)
00179     {
00180         return std::numeric_limits<UInt8>::max();
00181     }
00182 
00183     static        UInt8              getMin        (void)
00184     {
00185         return std::numeric_limits<UInt8>::min();
00186     }
00187 
00188 
00189     static Real32      getFraction  (UInt8 val)
00190     {
00191         return (Real32(val) / Real32(getMax()));
00192     };
00193 
00194     static UInt8       getPortion   (Real32 val)
00195     {
00196 #ifdef OSG_WIN32_ICL
00197 #pragma warning (disable : 810)
00198 #endif
00199         return UInt8((val * Real32(getMax())));
00200 #ifdef OSG_WIN32_ICL
00201 #pragma warning (default : 810)
00202 #endif
00203     };
00204 
00205 
00206     static UInt8       getFromString(const Char8 *szString)
00207     {
00208         if(szString != NULL)
00209         {
00210             return UInt8(strtoul(szString, NULL, 0));
00211         }
00212         else
00213         {
00214             return getZeroElement();
00215         }
00216     }
00217 
00218     static std::string putToString  (const UInt8 val)
00219     {
00220         Char8 buffer[10];
00221 
00222         sprintf(buffer, "%u", val);
00223 
00224         return std::string(buffer);
00225     }
00226 };
00227 
00228 
00232 template <>
00233 struct TypeTraits<Int8> : public TypeTraitsBase
00234 {
00235     typedef       Real32             RealReturnType;
00236 
00237 
00238     static const  bool               IsPOD       = true;
00239     static const  MathTypeProperties MathProp    = IntValue;
00240 
00241     static const  Int8               BitsSet     =    -1; //0xFF;
00242     static const  Int8               BitsClear   =  0x00;
00243 
00244 
00245     static        Int8               getZeroElement(void)
00246     {
00247         return 0;
00248     }
00249 
00250     static        Int8               getOneElement (void)
00251     {
00252         return 1;
00253     }
00254 
00255     static        Int8               getMin        (void)
00256     {
00257         return std::numeric_limits<Int8>::min();
00258     }
00259 
00260     static        Int8               getMax        (void)
00261     {
00262         return std::numeric_limits<Int8>::max();
00263     }
00264 
00265 
00266     static Real32      getFraction  (Int8   val)
00267     {
00268         return (Real32(val) / Real32(getMax()));
00269     };
00270 
00271     static Int8        getPortion   (Real32 val)
00272     {
00273         return (Int8) (val * Real32(getMax()));
00274     };
00275 
00276 
00277     static Int8        getFromString(const Char8 *szString)
00278     {
00279         if(szString != NULL)
00280         {
00281             return Int8(strtol(szString, NULL, 0));
00282         }
00283         else
00284         {
00285             return getZeroElement();
00286         }
00287     }
00288 
00289     static std::string putToString  (const Int8 val)
00290     {
00291         Char8 buffer[10];
00292 
00293         sprintf(buffer, "%i", val);
00294 
00295         return std::string(buffer);
00296     }
00297 };
00298 
00299 
00303 template <>
00304 struct TypeTraits<UInt16> : public TypeTraitsBase
00305 {
00306     typedef       Real32             RealReturnType;
00307 
00308 
00309     static const  bool               IsPOD       = true;
00310     static const  MathTypeProperties MathProp    = IntValue;
00311 
00312     static const  UInt16             BitsSet     = 0xFFFF;
00313     static const  UInt16             BitsClear   = 0x0000;
00314 
00315 
00316     static        UInt16             getZeroElement(void)
00317     {
00318         return 0;
00319     }
00320 
00321     static        UInt16             getOneElement (void)
00322     {
00323         return 1;
00324     }
00325     
00326     static        UInt16             getMax        (void)
00327     {
00328         return std::numeric_limits<UInt16>::max();
00329     }
00330 
00331     static        UInt16             getMin        (void)
00332     {
00333         return std::numeric_limits<UInt16>::min();
00334     }
00335 
00336 
00337     static Real32      getFraction  (UInt16 val)
00338     {
00339         return (Real32(val) / Real32(getMax()));
00340     };
00341 
00342     static UInt16      getPortion   (Real32 val)
00343     {
00344         return (UInt16) (val * Real32(getMax()));
00345     };
00346 
00347 
00348     static UInt16      getFromString(const Char8 *szString)
00349     {
00350         if(szString != NULL)
00351         {
00352             return UInt16(strtoul(szString, NULL, 0));
00353         }
00354         else
00355         {
00356             return getZeroElement();
00357         }
00358     }
00359 
00360     static std::string putToString  (const UInt16 val)
00361     {
00362         Char8 buffer[10];
00363 
00364 //      Check WIN32 Version
00365 #ifdef WIN32
00366         sprintf(buffer, "%u", UInt32(val));
00367 #else
00368         sprintf(buffer, "%u", val);
00369 #endif
00370 
00371         return std::string(buffer);
00372     }
00373 };
00374 
00375 
00379 template <>
00380 struct TypeTraits<Int16> : public TypeTraitsBase
00381 {
00382     typedef       Real32             RealReturnType;
00383 
00384 
00385     static const  bool               IsPOD       = true;
00386     static const  MathTypeProperties MathProp    = IntValue;
00387 
00388     static const  Int16              BitsSet     =      -1; //0xFFFF;
00389     static const  Int16              BitsClear   =  0x0000;
00390 
00391 
00392     static        Int16              getZeroElement(void)
00393     {
00394         return 0;
00395     }
00396 
00397     static        Int16              getOneElement (void)
00398     {
00399         return 1;
00400     }
00401 
00402     static        Int16              getMax        (void)
00403     {
00404         return std::numeric_limits<Int16>::max();
00405     }
00406 
00407     static        Int16              getMin        (void)
00408     {
00409         return std::numeric_limits<Int16>::min();
00410     }
00411 
00412 
00413     static Real32      getFraction  (Int16  val)
00414     {
00415         return (Real32(val) / Real32(getMax()));
00416     };
00417 
00418     static Int16       getPortion   (Real32 val)
00419     {
00420         return (Int16) (val * Real32(getMax()));
00421     };
00422 
00423 
00424     static Int16       getFromString(const Char8 *szString)
00425     {
00426         if(szString != NULL)
00427         {
00428             return Int16(strtol(szString, NULL, 0));
00429         }
00430         else
00431         {
00432             return getZeroElement();
00433         }
00434     }
00435 
00436     static std::string putToString  (const Int16 val)
00437     {
00438         Char8 buffer[10];
00439 
00440         sprintf(buffer, "%i", val);
00441 
00442         return std::string(buffer);
00443     }
00444 };
00445 
00446 
00450 template <>
00451 struct TypeTraits<UInt32> : public TypeTraitsBase
00452 {
00453     typedef       Real32                RealReturnType;
00454 
00455 
00456     static const  bool               IsPOD       = true;
00457     static const  MathTypeProperties MathProp    = IntValue;
00458 
00459     static const  UInt32             BitsSet     = 0xFFFFFFFF;
00460     static const  UInt32             BitsClear   = 0x00000000;
00461 
00462 
00463     static        UInt32             getZeroElement(void)
00464     {
00465         return 0;
00466     }
00467 
00468     static        UInt32             getOneElement (void)
00469     {
00470         return 1;
00471     }
00472 
00473     static        UInt32             getMax        (void) 
00474     { 
00475         return std::numeric_limits<UInt32>::max();
00476     }
00477 
00478     static        UInt32             getMin        (void)
00479     {
00480         return std::numeric_limits<UInt32>::min();
00481     }
00482 
00483 
00484     static Real32      getFraction  (UInt32 val)
00485     {
00486         return (Real32(val) / Real32(getMax()));
00487     };
00488 
00489     static UInt32      getPortion   (Real32 val)
00490     {
00491         return (UInt32) (val * Real32(getMax()));
00492     };
00493 
00494 
00495     static UInt32      getFromString(const Char8 *szString)
00496     {
00497         if(szString != NULL)
00498         {
00499             return UInt32(strtoul(szString, NULL, 0));
00500         }
00501         else
00502         {
00503             return getZeroElement();
00504         }
00505     }
00506 
00507     static std::string putToString  (const UInt32 val)
00508     {
00509         Char8 buffer[15];
00510 
00511         sprintf(buffer, "%u", val);
00512 
00513         return std::string(buffer);
00514     }
00515 };
00516 
00517 
00521 template <>
00522 struct TypeTraits<Int32> : public TypeTraitsBase
00523 {
00524     typedef       Real32             RealReturnType;
00525 
00526 
00527     static const  bool               IsPOD       = true;
00528     static const  MathTypeProperties MathProp    = IntValue;
00529 
00530     static const  Int32              BitsSet     =  0xFFFFFFFF;
00531     static const  Int32              BitsClear   =  0x00000000;
00532 
00533 
00534     static        Int32              getZeroElement(void)
00535     {
00536         return 0;
00537     }
00538 
00539     static        Int32              getOneElement (void)
00540     {
00541         return 1;
00542     }
00543 
00544     static        Int32              getMax        (void)
00545     {
00546         return std::numeric_limits<Int32>::max(); 
00547     }
00548 
00549     static        Int32              getMin        (void)
00550     {
00551         return std::numeric_limits<Int32>::min();
00552     }
00553 
00554 
00555     static Real32      getFraction  (Int32  val)
00556     {
00557         return (Real32(val) / Real32(getMax()));
00558     };
00559 
00560     static Int32       getPortion   (Real32 val)
00561     {
00562         return (Int32) (val * Real32(getMax()));
00563     };
00564 
00565 
00566     static Int32       getFromString(const Char8 *szString)
00567     {
00568         if(szString != NULL)
00569         {
00570             return Int32(strtol(szString, NULL, 0));
00571         }
00572         else
00573         {
00574             return getZeroElement();
00575         }
00576     }
00577 
00578     static std::string putToString  (const Int32 val)
00579     {
00580         Char8 buffer[15];
00581 
00582         sprintf(buffer, "%i", val);
00583 
00584         return std::string(buffer);
00585     }
00586 };
00587 
00588 
00592 template <>
00593 struct TypeTraits<UInt64> : public TypeTraitsBase
00594 {
00595     typedef       Real32             RealReturnType;
00596 
00597 
00598     static const  bool               IsPOD       = true;
00599     static const  MathTypeProperties MathProp    = IntValue;
00600 
00601 #ifdef OSG_LONGLONG_HAS_LL
00602     static const  UInt64             BitsSet     = 0xFFFFFFFFFFFFFFFFLL;
00603     static const  UInt64             BitsClear   = 0x0000000000000000LL;
00604 
00605     static const  UInt64             Zero        = 0x0000000000000000LL;
00606     static const  UInt64             One         = 0x0000000000000001LL;
00607 #else
00608     static const  UInt64             BitsSet     = 0xFFFFFFFFFFFFFFFF;
00609     static const  UInt64             BitsClear   = 0x0000000000000000;
00610 
00611     static const  UInt64             Zero        = 0x0000000000000000;
00612     static const  UInt64             One         = 0x0000000000000001;
00613 #endif
00614  
00615 
00616 
00617     static        UInt64             getZeroElement(void)
00618     {
00619         return 0;
00620     }
00621 
00622     static        UInt64             getOneElement (void)
00623     {
00624         return 1;
00625     }
00626 
00627 
00628     static        UInt64             getMax        (void)         
00629     {
00630         return std::numeric_limits<UInt64>::max();
00631     }
00632 
00633     static        UInt64             getMin        (void)
00634     {
00635         return std::numeric_limits<UInt64>::min();
00636     }
00637 
00638 
00639     static Real32      getFraction  (UInt64 val)
00640     {
00641         return (Real32(val) / Real32(getMax()));
00642     };
00643 
00644     static UInt64      getPortion   (Real32 val)
00645     {
00646         return (UInt64) (val * Real32(getMax()));
00647     };
00648 
00649 
00650     static UInt64      getFromString(const Char8 *szString)
00651     {
00652         if(szString != NULL)
00653         {
00654 #ifndef WIN32
00655             return UInt64(strtoull(szString, NULL, 0));
00656 #else
00657             return _atoi64(szString);
00658 #endif
00659         }
00660         else
00661         {
00662             return getZeroElement();
00663         }
00664     }
00665 
00666     static std::string putToString  (const UInt64 val)
00667     {
00668         Char8 buffer[25];
00669 
00670         sprintf(buffer, "%llu", val);
00671 
00672         return std::string(buffer);
00673     }
00674 };
00675 
00676 
00680 template <>
00681 struct TypeTraits<Int64> : public TypeTraitsBase
00682 {
00683     typedef       Real32 RealReturnType;
00684 
00685 
00686     static const  bool               IsPOD       = true;
00687     static const  MathTypeProperties MathProp    = IntValue;
00688 
00689 #ifdef OSG_LONGLONG_HAS_LL
00690     static const  Int64              BitsSet     =  0xFFFFFFFFFFFFFFFFLL;
00691     static const  Int64              BitsClear   =  0x0000000000000000LL;
00692 #else
00693     static const  Int64              BitsSet     =  0xFFFFFFFFFFFFFFFF;
00694     static const  Int64              BitsClear   =  0x0000000000000000;
00695 #endif
00696 
00697 
00698     static        Int64              getZeroElement(void)
00699     {
00700         return 0;
00701     }
00702 
00703     static        Int64              getOneElement (void)
00704     {
00705         return 1;
00706     }
00707 
00708     static        Int64              getMax        (void)
00709     {
00710         return std::numeric_limits<Int64>::max();
00711     }
00712 
00713     static        Int64              getMin        (void)
00714     {
00715         return std::numeric_limits<Int64>::min();
00716     }
00717 
00718 
00719     static Real32      getFraction  (Int64  val)
00720     {
00721         return (Real32(val) / Real32(getMax()));
00722     };
00723 
00724     static Int64       getPortion   (Real32 val)
00725     {
00726         return (Int64) (val * Real32(getMax()));
00727     };
00728 
00729 
00730     static Int64       getFromString(const Char8 *szString)
00731     {
00732         if(szString != NULL)
00733         {
00734 #ifndef WIN32
00735             return  Int64(strtoll(szString, NULL, 0));
00736 #else
00737             return _atoi64(szString);
00738 #endif
00739         }
00740         else
00741         {
00742             return getZeroElement();
00743         }
00744     }
00745 
00746     static std::string putToString  (const Int64 val)
00747     {
00748         Char8 buffer[25];
00749 
00750         sprintf(buffer, "%lli", val);
00751 
00752         return std::string(buffer);
00753     }
00754 };
00755 
00759 template <>
00760 struct TypeTraits<Real16> : public TypeTraitsBase
00761 {
00762     typedef       Real16             RealReturnType;
00763 
00764 
00765     static const  bool               IsPOD       = true;
00766     static const  MathTypeProperties MathProp    = RealValue;
00767 
00768     static        Real16             getZeroElement(void)
00769     {
00770         return Real16( 0.f );
00771     }
00772 
00773     static        Real16             getOneElement (void)
00774     {
00775         return Real16( 1.f );
00776     }
00777 
00778     static        Real16             getMax        (void)
00779     {
00780         return REAL16_MAX;
00781     }
00782 
00783     static        Real16             getMin        (void)
00784     {
00785         return REAL16_MIN;
00786     }
00787 
00788 
00789     static Real16 getFraction     (Real16 rVal) { return rVal; };
00790     static Real16 getPortion      (Real16 rVal) { return rVal; };
00791 
00792 
00793     static Real16 getFromString   (const Char8 *szString)
00794     {
00795         if(szString != NULL)
00796         {
00797 #if defined(__sgi) || defined(WIN32)
00798             return Real16(Real32(atof  (szString)));
00799 #else
00800             return Real16(Real32(strtof(szString, NULL)));
00801 #endif
00802         }
00803         else
00804         {
00805             return getZeroElement();
00806         }
00807     }
00808 
00809     static std::string putToString(const Real16 val)
00810     {
00811         Char8 buffer[20];
00812 
00813         sprintf(buffer, "%e", (Real32) val);
00814 
00815         return std::string(buffer);
00816     }
00817 
00818 };
00819 
00820 
00824 template <>
00825 struct TypeTraits<Real32> : public TypeTraitsBase
00826 {
00827     typedef       Real32             RealReturnType;
00828 
00829 
00830     static const  bool               IsPOD       = true;
00831     static const  MathTypeProperties MathProp    = RealValue;
00832 
00833     static        Real32             getZeroElement(void)
00834     {
00835         return 0.f;
00836     }
00837 
00838     static        Real32             getOneElement (void)
00839     {
00840         return 1.f;
00841     }
00842 
00843     static        Real32             getMax        (void)
00844     {
00845         return FLT_MAX;
00846     }
00847 
00848     static        Real32             getMin        (void)
00849     {
00850         return FLT_MIN;
00851     }
00852 
00853 
00854     static Real32 getFraction     (Real32 rVal) { return rVal; };
00855     static Real32 getPortion      (Real32 rVal) { return rVal; };
00856 
00857 
00858     static Real32 getFromString   (const Char8 *szString)
00859     {
00860         if(szString != NULL)
00861         {
00862 #if defined(__sgi) || defined(WIN32)
00863             return Real32(atof  (szString));
00864 #else
00865             return Real32(strtof(szString, NULL));
00866 #endif
00867         }
00868         else
00869         {
00870             return getZeroElement();
00871         }
00872     }
00873 
00874     static std::string putToString(const Real32 val)
00875     {
00876         Char8 buffer[20];
00877 
00878         sprintf(buffer, "%e", val);
00879 
00880         return std::string(buffer);
00881     }
00882 
00883 };
00884 
00885 
00889 template <>
00890 struct TypeTraits<Real64> : public TypeTraitsBase
00891 {
00892     typedef       Real64             RealReturnType;
00893 
00894 
00895     static const  bool               IsPOD       = true;
00896     static const  MathTypeProperties MathProp    = RealValue;
00897 
00898     static        Real64             getZeroElement(void)
00899     {
00900         return 0.0;
00901     }
00902 
00903     static        Real64             getOneElement (void)
00904     {
00905         return 1.0;
00906     }
00907 
00908     static        Real64             getMax        (void)
00909     {
00910         return DBL_MAX;
00911     }
00912 
00913     static        Real64             getMin        (void)
00914     {
00915         return DBL_MIN;
00916     }
00917 
00918 
00919     static Real64 getFraction     (Real64 rVal) { return rVal; };
00920     static Real64 getPortion      (Real64 rVal) { return rVal; };
00921 
00922 
00923     static Real64 getFromString   (const Char8 *szString)
00924     {
00925         if(szString != NULL)
00926         {
00927             return Real64(strtod(szString, NULL));
00928         }
00929         else
00930         {
00931             return getZeroElement();
00932         }
00933     }
00934 
00935     static std::string putToString(const Real64 val)
00936     {
00937         Char8 buffer[25];
00938 
00939         sprintf(buffer, "%e", val);
00940 
00941         return std::string(buffer);
00942     }
00943 };
00944 
00945 
00949 template <>
00950 struct TypeTraits<Real128> : public TypeTraitsBase
00951 {
00952     typedef       Real128             RealReturnType;
00953 
00954 
00955     static const  bool               IsPOD       = true;
00956     static const  MathTypeProperties MathProp    = RealValue;
00957 
00958     static        Real128             getZeroElement(void)
00959     {
00960         return 0.0;
00961     }
00962 
00963     static        Real128             getOneElement (void)
00964     {
00965         return 1.0;
00966     }
00967 
00968     static        Real128             getMax        (void)
00969     {
00970         return DBL_MAX;
00971     }
00972 
00973     static        Real128             getMin        (void)
00974     {
00975         return DBL_MIN;
00976     }
00977 
00978 
00979     static Real128 getFraction     (Real128 rVal) { return rVal; };
00980     static Real128 getPortion      (Real128 rVal) { return rVal; };
00981 
00982 
00983     static Real128 getFromString   (const Char8 *szString)
00984     {
00985         if(szString != NULL)
00986         {
00987 #if defined(WIN32)
00988             return Real128(strtod(szString, NULL));
00989 #else
00990             return Real128(strtold(szString, NULL));
00991 #endif
00992         }
00993         else
00994         {
00995             return getZeroElement();
00996         }
00997     }
00998 
00999     static std::string putToString(const Real128 val)
01000     {
01001         Char8 buffer[25];
01002 
01003         sprintf(buffer, "%Le", val);
01004 
01005         return std::string(buffer);
01006     }
01007 };
01008 
01009 
01010 #ifdef OSG_GLENUM_NEQ_UINT32
01011 
01015 template <>
01016 struct TypeTraits<GLenum> : public TypeTraitsBase
01017 {
01018     typedef       Real32                RealReturnType;
01019 
01020 
01021     static const  bool               IsPOD       = true;
01022     static const  MathTypeProperties MathProp    = IntValue;
01023 
01024     static const  UInt32             BitsSet     = 0xFFFFFFFF;
01025     static const  UInt32             BitsClear   = 0x00000000;
01026 
01027 
01028     static        GLenum             getZeroElement(void)
01029     {
01030         return 0;
01031     }
01032 
01033     static        GLenum             getOneElement (void)
01034     {
01035         return 1;
01036     }
01037 
01038     static        GLenum             getMax        (void) 
01039     { 
01040         return 0xFFFFFFFF;
01041     }
01042 
01043     static        GLenum             getMin        (void)
01044     {
01045         return 0x00000000;
01046     }
01047 
01048 
01049     static GLenum      getFromString(const Char8 *szString)
01050     {
01051         if(szString != NULL)
01052         {
01053             return GLenum(strtoul(szString, NULL, 0));
01054         }
01055         else
01056         {
01057             return getZeroElement();
01058         }
01059     }
01060 
01061     static std::string putToString  (const GLenum val)
01062     {
01063         Char8 buffer[15];
01064 
01065         sprintf(buffer, "%u", val);
01066 
01067         return std::string(buffer);
01068     }
01069 };
01070 
01071 #endif
01072 
01073 OSG_END_NAMESPACE
01074 
01075 #ifndef OSG_DISABLE_DEPRECATED
01076 #define TypeConstants TypeTraits
01077 #define getAllSet()   BitsSet
01078 #endif
01079 
01080 #define OSGBASETYPETRAITS_HEADER_CVSID "@(#)$Id: $"
01081 
01082 #endif /* _OSGBASETYPETRAITS_H_ */

Generated on Thu Aug 25 04:01:11 2005 for OpenSG by  doxygen 1.4.3