OSGFixed.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *                 Copyright (C) 2006 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 _OSGFIXED_H_
00040 #define _OSGFIXED_H_
00041 
00042 #ifndef _OSGBASETYPES_H_
00043 #error  Include OSGBaseTypes.h instead of OSGFixed.h
00044 #endif
00045 
00046 class OSG_BASE_DLLMAPPING Fixed32
00047 {
00048   public:
00049 
00050     //-------------
00051     // Constructors
00052     //-------------
00053 
00054     Fixed32(void);
00055     Fixed32(const Real32 source);
00056     Fixed32(const UInt32 source);
00057     Fixed32(const Fixed32 &source);
00058 
00059     ~Fixed32(void);
00060 
00061     //------------
00062     // Unary minus
00063     //------------
00064 
00065     Fixed32 operator - () const;
00066 
00067     void setFixedValue(Int32 src);
00068 
00069     //-----------
00070     // Assignment
00071     //-----------
00072 
00073     Fixed32 &operator = (const Fixed32 rhs);
00074 
00075     Fixed32 &operator +=(const Fixed32 rhs);
00076     Fixed32 &operator -=(const Fixed32  rhs);
00077     Fixed32 &operator *=(const Fixed32 rhs);
00078     Fixed32 &operator /=(const Fixed32 rhs);
00079 
00080     Fixed32  operator + (const Fixed32 rhs) const;
00081     Fixed32  operator - (const Fixed32 rhs) const;
00082     Fixed32  operator * (const Fixed32 rhs) const;
00083     Fixed32  operator / (const Fixed32 rhs) const;
00084 
00085     bool operator ==(const Fixed32 rhs) const;
00086     bool operator !=(const Fixed32 rhs) const;
00087     bool operator < (const Fixed32 rhs) const;
00088     bool operator > (const Fixed32 rhs) const;
00089     bool operator <=(const Fixed32 rhs) const;
00090     bool operator >=(const Fixed32 rhs) const;
00091 
00092 //    operator Real32 () const;
00093 
00094     Int32 getValue(void      ) const;
00095     void  setValue(Int32 iVal);
00096 
00097     static Fixed32 abs(Fixed32 rhs);
00098     static Fixed32 sqrt(Fixed32 rhs);
00099 
00100     static Fixed32 sin(Fixed32 rhs);
00101     static Fixed32 cos(Fixed32 rhs);
00102     static Fixed32 tan(Fixed32 rhs);
00103 
00104   protected:
00105 
00106     static Real32 toFloat(Fixed32 rhs);
00107 
00108     Fixed32(const Int32 source);
00109 
00110   private:
00111 
00112     Int32 _value;
00113 };
00114 
00115 Fixed32 operator -(const Real32 lhs, const Fixed32 rhs);
00116 Fixed32 operator /(const Real32 lhs, const Fixed32 rhs);
00117 Fixed32 operator *(const Real32 lhs, const Fixed32 rhs);
00118 
00119 std::ostream &operator << (std::ostream &os, const Fixed32 fVal);
00120 
00121 #include "OSGFixed.inl"
00122 
00123 #endif /* _OSGFIXED_H_ */