Changeset 792 for code/branches/core/src/util
- Timestamp:
- Feb 9, 2008, 7:32:06 PM (17 years ago)
- Location:
- code/branches/core/src/util
- Files:
-
- 11 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/util/CMakeLists.txt
r790 r792 5 5 SET (UTIL_SRC_FILES 6 6 ${TINYXML_SRC_FILES} 7 Math.cc 8 String.cc 7 9 substring.cc 10 MultiTypePrimitive.cc 11 MultiTypeString.cc 12 MultiTypeMath.cc 8 13 ) 9 14 10 IF(WIN32) 11 ADD_LIBRARY( util ${UTIL_SRC_FILES} ) 12 ELSE(WIN32) 13 ADD_LIBRARY( util SHARED ${UTIL_SRC_FILES} ) 14 ENDIF(WIN32) 15 ADD_LIBRARY( util SHARED ${UTIL_SRC_FILES} ) 15 16 SET_TARGET_PROPERTIES( util PROPERTIES LINK_FLAGS "--no-undefined" ) 16 17 17 18 18 IF(TESTING_ENABLED) 19 19 ADD_SUBDIRECTORY(testing) 20 20 ENDIF(TESTING_ENABLED) 21 22 TARGET_LINK_LIBRARIES( util 23 ${OGRE_LIBRARIES} 24 ) -
code/branches/core/src/util/Convert.h
r790 r792 36 36 #include <sstream> 37 37 38 #include "UtilPrereqs.h" 38 39 39 40 // DEFAULT CLASS 40 41 template <typename FromType, typename ToType> 41 class Converter42 class _UtilExport Converter 42 43 { 43 44 public: … … 50 51 // PARTIAL SPECIALIZATION TO CONVERT TO STRINGS 51 52 template<typename FromType> 52 class Converter<FromType, std::string>53 class _UtilExport Converter<FromType, std::string> 53 54 { 54 55 public: … … 68 69 // PARTIAL SPECIALIZATION TO CONVERT FROM STRING 69 70 template<typename ToType> 70 class Converter<std::string, ToType>71 class _UtilExport Converter<std::string, ToType> 71 72 { 72 73 public: … … 83 84 // FUNCTION SO WE DO NOT HAVE TO TELL THE COMPILER ABOUT THE TYPE 84 85 template<typename FromType, typename ToType> 85 static bool ConvertValue(ToType* output, const FromType& input)86 static _UtilExport bool ConvertValue(ToType* output, const FromType& input) 86 87 { 87 88 Converter<FromType, ToType> converter; … … 91 92 // THE SAME, BUT WITH DEFAULT VALUE 92 93 template<typename FromType, typename ToType> 93 static bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback)94 static _UtilExport bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback) 94 95 { 95 96 Converter<FromType, ToType> converter; -
code/branches/core/src/util/Math.h
r790 r792 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * Fabian 'x3n' Landau 23 * Co-authors: 24 * ... 25 * 26 */ 27 28 #ifndef _Math_H__ 29 #define _Math_H__ 30 31 #include <ostream> 32 33 #include "UtilPrereqs.h" 34 1 35 #include <OgreMath.h> 2 36 #include <OgreVector2.h> … … 18 52 typedef Ogre::ColourValue ColourValue; 19 53 } 54 55 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian); 56 _UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian); 57 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree); 58 _UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree); 59 60 template <typename T> 61 inline _UtilExport T sgn(T x) 62 { 63 return (x >= 0) ? 1 : -1; 64 } 65 66 template <typename T> 67 inline _UtilExport T min(T a, T b) 68 { 69 return (a <= b) ? a : b; 70 } 71 72 template <typename T> 73 inline _UtilExport T max(T a, T b) 74 { 75 return (a >= b) ? a : b; 76 } 77 78 template <typename T> 79 inline _UtilExport T clamp(T x, T min, T max) 80 { 81 if (x < min) 82 return min; 83 84 if (x > max) 85 return max; 86 87 return x; 88 } 89 90 template <typename T> 91 inline _UtilExport T square(T x) 92 { 93 return x*x; 94 } 95 96 template <typename T> 97 inline _UtilExport T cube(T x) 98 { 99 return x*x*x; 100 } 101 102 template <typename T> 103 inline _UtilExport int floor(T x) 104 { 105 return (int)(x); 106 } 107 108 template <typename T> 109 inline _UtilExport int ceil(T x) 110 { 111 int temp = floor(x); 112 return (temp != x) ? (temp + 1) : temp; 113 } 114 115 template <typename T> 116 inline _UtilExport int round(T x) 117 { 118 return (int)(x + 0.5); 119 } 120 121 template <typename T> 122 _UtilExport T interpolate(float time, const T& start, const T& end) 123 { 124 return time * (end - start) + start; 125 } 126 127 template <typename T> 128 _UtilExport T interpolateSmooth(float time, const T& start, const T& end) 129 { 130 return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start; 131 } 132 133 inline _UtilExport float rnd() 134 { 135 return ((float)rand() / RAND_MAX); 136 } 137 138 inline _UtilExport float rnd(float max) 139 { 140 return rnd() * max; 141 } 142 143 inline _UtilExport float rnd(float min, float max) 144 { 145 return rnd(max - min) + min; 146 } 147 148 #endif /* _Math_H__ */ -
code/branches/core/src/util/String2Number.h
r790 r792 7 7 8 8 #include "core/Debug.h" 9 #include "UtilPrereqs.h" 9 10 10 11 /** … … 23 24 24 25 template <class T> 25 class String2Number26 class _UtilExport String2Number 26 27 { 27 28 private: -
code/branches/core/src/util/substring.h
r790 r792 59 59 #include <string> 60 60 61 #include "UtilPrereqs.h" 61 62 62 63 //! A class that can load one string and split it in multipe ones … … 65 66 * It can be used, to Split strings append them and join them again. 66 67 */ 67 class SubString68 class _UtilExport SubString 68 69 { 69 70 public:
Note: See TracChangeset
for help on using the changeset viewer.