OSGBaseTypes.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-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 _OSGBASETYPES_H_
00040 #define _OSGBASETYPES_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include "OSGConfig.h"
00046 #include "OSGBaseDef.h"
00047 #include "OSGReal16.h"
00048
00049 #include <vector>
00050 #include <boost/mpl/if.hpp>
00051
00052 #if defined(OSG_SGI_TYPES) || defined (OSG_LINUX_TYPES) || \
00053     defined(OSG_SUNOS_TYPES)
00054 #include <sys/types.h>
00055 #endif
00056 
00057 #include <cstdlib>
00058
00059 #include <utility>
00060
00061 #include <cfloat>
00062 #include <string>
00063 #include <cstdio>
00064 #include <cmath>
00065
00066 #if defined(OSG_LINUX_TYPES)
00067 #    include <inttypes.h>
00068 #endif
00069 
00070 OSG_BEGIN_NAMESPACE
00071
00072 #if defined(OSG_SGI_TYPES)
00073 
00078 typedef char           TChar;
00079
00084 typedef char           Char8;
00085
00090 typedef unsigned char UChar8;
00091
00096 typedef signed char   SChar8;
00097
00102 typedef int8_t    Int8;
00103
00108 typedef uint8_t   UInt8;
00109
00114 typedef int16_t   Int16;
00115
00120 typedef uint16_t  UInt16;
00121
00126 typedef int32_t   Int32;
00127
00132 typedef uint32_t  UInt32;
00133
00138 typedef int64_t   Int64;
00139
00144 typedef uint64_t  UInt64;
00145
00150 typedef float     Real32;
00151
00156 typedef double    Real64;
00157
00162 typedef long double Real128;
00163
00164 #elif defined(OSG_LINUX_TYPES)
00165 
00170 typedef char           TChar;
00171
00176 typedef char           Char8;
00177
00182 typedef unsigned char UChar8;
00183
00188 typedef signed char   SChar8;
00189
00194 typedef int8_t     Int8;
00195
00200 typedef uint8_t   UInt8;
00201
00206 typedef int16_t    Int16;
00207
00212 typedef uint16_t  UInt16;
00213
00218 typedef int32_t    Int32;
00219
00224 typedef uint32_t  UInt32;
00225
00230 typedef int64_t    Int64;
00231
00236 typedef uint64_t  UInt64;
00237
00242 typedef float      Real32;
00243
00248 typedef double     Real64;
00249
00254 typedef long double Real128;
00255
00256 #elif defined(OSG_HPUX_TYPES)
00257 
00262 typedef char           TChar;
00263
00268 typedef char           Char8;
00269
00274 typedef unsigned char UChar8;
00275
00280 typedef signed char   SChar8;
00281
00286 typedef int8_t     Int8;
00287
00292 typedef uint8_t   UInt8;
00293
00298 typedef int16_t    Int16;
00299
00304 typedef uint16_t  UInt16;
00305
00310 typedef int32_t    Int32;
00311
00316 typedef uint32_t  UInt32;
00317
00322 typedef int64_t    Int64;
00323
00328 typedef uint64_t  UInt64;
00329
00334 typedef float      Real32;
00335
00340 typedef double     Real64;
00341
00346 typedef long double Real128;
00347
00348 #elif defined(OSG_WIN_TYPES)
00349 
00350
00355 typedef TCHAR          TChar;
00356
00361 typedef CHAR           Char8;
00362
00367 typedef UCHAR         UChar8;
00368
00373 typedef signed char   SChar8;
00374
00379 typedef signed char   Int8;
00380
00385 typedef UCHAR   UInt8;
00386
00391 typedef SHORT   Int16;
00392
00397 typedef USHORT  UInt16;
00398
00403 typedef INT32   Int32;
00404
00409 typedef UINT32  UInt32;
00410
00415 typedef INT64   Int64;
00416
00421 typedef UINT64  UInt64;
00422
00427 typedef DWORD   DWord;
00428
00433 typedef HANDLE  Handle;
00434
00439 typedef float     Real32;
00440
00445 typedef double    Real64;
00446
00451 typedef long double Real128;
00452
00453 #elif defined(OSG_SUN_TYPES)
00454 
00459 typedef char           TChar;
00460
00465 typedef char           Char8;
00466
00471 typedef unsigned char UChar8;
00472
00477 typedef signed char   SChar8;
00478
00483 typedef int8_t     Int8;
00484
00489 typedef uint8_t   UInt8;
00490
00495 typedef int16_t    Int16;
00496
00501 typedef uint16_t  UInt16;
00502
00507 typedef int32_t    Int32;
00508
00513 typedef uint32_t  UInt32;
00514
00519 typedef long long    Int64;
00520
00525 typedef unsigned long long  UInt64;
00526
00531 typedef float      Real32;
00532
00537 typedef double     Real64;
00538
00543 typedef long double Real128;
00544
00545 #else
00546 #error "Could not define base types, check your system/compiler combination"
00547 #endif
00548 
00553 typedef UInt64 BitVector;
00554
00555 #ifndef OSG_WIN_TYPES
00556 typedef Int32 RefCountStore;
00557 #else
00558 typedef long RefCountStore;
00559 #endif
00560 
00565 typedef size_t SizeT;
00566
00572 typedef UInt8 *MemoryHandle;
00573
00574 #include "OSGFixed.h"
00575
00576 #ifdef OSG_FLOAT_PROFILE
00577 
00582 typedef Real32  Real;
00583 #else
00584 
00589 typedef Fixed32 Real;
00590 #endif
00591 
00592 #if defined(OSG_EMBEDDED) && !defined(__linux)
00593 typedef std::wstring   tstring;
00594 #define OSGT(TEXT) L##TEXT
00595 #else
00596 typedef std::string    tstring;
00597 #define OSGT(TEXT) TEXT
00598 #endif
00599 
00600
00604 const Real32 Eps = 1E-6f;
00605
00609 const Real32 Pi  = 3.141592653589793f;
00610
00614 const Real32 TwoPi  = 2.f * Pi;
00615
00619 const Real64 PiHalf  = 1.570796326794896619231322;
00620
00624 const Real32 Sqrt2  = 1.41421356237309504f;
00625
00629 const Real32 Inf = 1E30f;
00630
00634 const Real32 NegInf = - 1E30f;
00635
00636 #ifdef WIN32
00637 
00641 static const Char8 *PluginExt     = ".dll";
00642
00646 static const Char8 *PluginPattern = "*.dll";
00647
00651 static const Char8  DirSep    = '\\';
00652
00653 #ifndef PRIx64
00654 #define PRIx64 "llx"
00655 #endif
00656 
00657 #elif defined(__APPLE__)
00658 
00662 const Char8 PluginExt[]     = ".dylib";
00663
00667 const Char8 PluginPattern[] = "*.dylib";
00668
00672 const Char8  DirSep    = '/';
00673
00674 #else
00675 
00676 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00677 #if defined(__GNUC__)
00678 #define OSG_UNUSED_ATTRIB __attribute__((__unused__))
00679 #else
00680 #define OSG_UNUSED_ATTRIB
00681 #endif
00682 #endif
00683 
00686 static const Char8 *PluginExt OSG_UNUSED_ATTRIB = ".so";
00687
00690 static const Char8 *PluginPattern OSG_UNUSED_ATTRIB = "*.so";
00691
00695 static const Char8  DirSep OSG_UNUSED_ATTRIB = '/';
00696
00697 #undef OSG_UNUSED_ATTRIB
00698 #endif
00699 
00700 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00701 
00702 namespace PointerSize
00703 {
00704     struct UnknowSize {};
00705
00706     typedef boost::mpl::if_<boost::mpl::bool_<(sizeof(void *) == 4)>,
00707                             UInt32,
00708                             UnknowSize>::type UITmp1;
00709
00710     typedef boost::mpl::if_<boost::mpl::bool_<(sizeof(void *) == 4)>,
00711                             Int32,
00712                             UnknowSize>::type ITmp1;
00713
00714     typedef boost::mpl::if_<boost::mpl::bool_<(sizeof(void *) == 8)>,
00715                             UInt64,
00716                             UITmp1  >::type UIPtrSize;
00717
00718     typedef boost::mpl::if_<boost::mpl::bool_<(sizeof(void *) == 8)>,
00719                             Int64,
00720                             ITmp1  >::type IPtrSize;
00721 }
00722
00723 #endif
00724 
00728 typedef PointerSize::UIPtrSize UIntPointer;
00729 typedef PointerSize::IPtrSize  IntPointer;
00730
00731 #ifndef PRISize
00732 # ifdef WIN32
00733 #  define PRISize "Id"
00734 #  define PRIUSize "Iu"
00735 # else
00736 #  define PRISize "zd"
00737 #  define PRIUSize "zu"
00738 # endif
00739 #endif
00740 
00745 enum MathTypeProperties
00746 {
00747     RealValue,
00748     IntValue,
00749     BoolValue
00750 };
00751
00755 typedef const BitVector ConstFieldMaskArg;
00756
00764 struct FieldFlags
00765 {
00766     BitVector _bSyncFlags;
00767     BitVector _bThreadLocalFlags;
00768     BitVector _bClusterLocalFlags;
00769     BitVector _bNamespaceMask;
00770
00771     FieldFlags(void);
00772     FieldFlags(const FieldFlags &source);
00773     ~FieldFlags(void);
00774 };
00775
00776
00780 typedef std::vector<IntPointer> AspectOffsetStore;
00781
00782 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00783 
00784 namespace RenderPropBitVectorSize
00785 {
00786     struct UnknowSize {};
00787
00788     typedef boost::mpl::if_<boost::mpl::bool_< (RenderPropertyBits <= 64 &&
00789                                                 RenderPropertyBits >  32   )>,
00790                             UInt64,
00791                             UnknowSize>::type Tmp1;
00792
00793     typedef boost::mpl::if_<boost::mpl::bool_< (RenderPropertyBits <= 32) >,
00794                             UInt32,
00795                             Tmp1  >::type BitVectorSize;
00796 }
00797
00798 #endif
00799 
00803 typedef RenderPropBitVectorSize::BitVectorSize RenderPropBitVector;
00804
00805 OSG_END_NAMESPACE
00806
00807 #include "OSGBaseTypeTraits.h"
00808 #include "OSGBaseTypes.inl"
00809
00810 #endif /* OSGBASETYPES_H */