Changeset 7367
- Timestamp:
- Sep 6, 2010, 3:51:29 PM (14 years ago)
- Location:
- code/branches/doc/src/libraries/util
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/util/Clock.cc
r7331 r7367 45 45 } 46 46 47 /**48 @remarks49 Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned50 long, which will eventually overflow. But if you use the subtraction of51 the current time minus the last time the timer gave us and sum these up to52 a 64 bit integer, we get the desired result. <br>53 Also mind that we don't have to store the last timer's time as unsigned long54 as well because (unsigned long)tickTime_ will do exactly that.55 */56 47 void Clock::capture() 57 48 { -
code/branches/doc/src/libraries/util/Clock.h
r7331 r7367 41 41 via Clock& references (for instance for the game tick). <br> 42 42 Precision: <br> 43 @par Precision 43 44 The maximum precision is given by the Ogre::Timer and that is somewhere 44 45 in the microsecond range for both Windows and UNIX. 45 @ remarks46 @par Remarks for Usage on Windows 46 47 For proper functionality this class MUST be used in the same thread! <br> 47 Further 48 caveat on Windows because it will only capture the time on the same49 C PU core. Confining the main thread to one process could speed up the game.50 See command line argument 'limitToCPU'.48 Furthermore it might be possible that the Ogre::Timer has a performance 49 caveat because it will only capture the time on the same CPU core. 50 Confining the main thread to one process could speed up the game. 51 See \ref cmdargspage "Ccommandline Argument" 'limitToCPU' (only on Windows) 51 52 */ 52 53 class _UtilExport Clock 53 54 { 54 55 public: 55 // !Starts the time at 056 /// Starts the time at 0 56 57 Clock(); 57 58 ~Clock(); 58 59 59 //! Internally captures the time and stays at that particular time 60 /** Internally captures the time and stays at that particular time 61 @remarks 62 Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned 63 long, which will eventually overflow. But if you use the subtraction of 64 the current time minus the last time the timer gave us and sum these up to 65 a 64 bit integer, we get the desired result. <br> 66 Also mind that we don't have to store the last timer's time as unsigned long 67 as well because (unsigned long)tickTime_ will do exactly that. 68 */ 60 69 void capture(); 61 70 62 // !Returns the last captured absolute time in microseconds71 /// Returns the last captured absolute time in microseconds 63 72 unsigned long long getMicroseconds() const 64 73 { return tickTime_; } 65 // !Returns the last captured absolute time in milliseconds74 /// Returns the last captured absolute time in milliseconds 66 75 unsigned long long getMilliseconds() const 67 76 { return tickTime_ / 1000; } 68 // !Returns the last captured absolute time in seconds77 /// Returns the last captured absolute time in seconds 69 78 unsigned long getSeconds() const 70 79 { return static_cast<long> (tickTime_ / 1000000); } 71 // !Returns the last captured absolute time in seconds as float80 /// Returns the last captured absolute time in seconds as float 72 81 float getSecondsPrecise() const 73 82 { return static_cast<float>(tickTime_ / 1000000.0f); } 74 83 75 // !Returns the timespan in seconds between the last two calls to capture()84 /// Returns the timespan in seconds between the last two calls to capture() 76 85 float getDeltaTime() const 77 86 { return tickDtFloat_; } 78 // !Returns the timespan in microseconds between the last two calls to capture()87 /// Returns the timespan in microseconds between the last two calls to capture() 79 88 long getDeltaTimeMicroseconds() const 80 89 { return tickDt_; } … … 88 97 89 98 private: 90 // !Undefined99 /// Undefined 91 100 Clock(const Clock& instance); 92 101 93 Ogre::Timer* timer_; // !< Ogre timer object94 unsigned long long tickTime_; // !< Currently captured time95 long tickDt_; // !< Delta time in microseconds (cache value)96 float tickDtFloat_; // !< Delta time in seconds (cache value)102 Ogre::Timer* timer_; ///< Ogre timer object 103 unsigned long long tickTime_; ///< Currently captured time 104 long tickDt_; ///< Delta time in microseconds (cache value) 105 float tickDtFloat_; ///< Delta time in seconds (cache value) 97 106 }; 98 107 } -
code/branches/doc/src/libraries/util/Exception.cc
r7174 r7367 53 53 { } 54 54 55 /**56 @remarks57 The composed full description gets stored to fullDescription_. But for compliance58 with std::exception, this method has to be const. Hence fullDescription_ is declared59 as mutable.60 */61 55 const std::string& Exception::getFullDescription() const 62 56 { … … 89 83 } 90 84 91 //! Returns the error description92 85 const char* Exception::what() const throw() 93 86 { -
code/branches/doc/src/libraries/util/Exception.h
r7297 r7367 31 31 @brief 32 32 Declaration of facilities to handle exceptions. 33 @details 34 Any exception thrown should inherit from orxonox::Exception. There is a macro 35 \ref CREATE_ORXONOX_EXCEPTION to create a new exception (you can find a list of 36 available exceptions in the docs of this file). <br> 37 Throwing exception is also very simple: 38 @code 39 ThrowException(General, "Something went wrong"); 40 @endcode 41 (\c General is a type of exception, see docs of this file) <br> 42 The exception will automatically contain information about file, line number 43 and function name it occurred in. <br><br> 44 There is also some magic you can do for numbers, etc.: 45 @code 46 ThrowException(General, "Error code: " << myInt << ". more info..."); 47 @endcode 48 It works with an std::ostringstream, so you can feed it all sorts of values. 33 49 */ 34 50 … … 45 61 namespace orxonox 46 62 { 47 /** 48 @brief 49 Base class for all exceptions (derived from std::exception). 63 /** Base class for all exceptions (derived from std::exception). 50 64 @details 51 65 This class provides support for information about the file, the line 52 and the function the error occured. 66 and the function the error occurred. 67 @see Exception.h 53 68 */ 54 69 class _UtilExport Exception : public std::exception … … 74 89 //! Needed for compatibility with std::exception 75 90 virtual ~Exception() throw() { } 91 //! Returns the error description 76 92 const char* what() const throw(); 77 93 78 //! Returns a full description with type, line, file and function 94 /** Returns a full description with type, line, file and function 95 @remarks 96 The composed full description gets stored to fullDescription_. But for compliance 97 with std::exception, this method has to be const. Hence fullDescription_ is declared 98 as mutable. 99 */ 79 100 virtual const std::string& getFullDescription() const; 80 101 //! Returns the string name of the exception type … … 107 128 }; 108 129 109 //! Creates a new type of exception that inherits from tracker::Exception130 //! Creates a new type of exception that inherits from orxonox::Exception 110 131 #define CREATE_ORXONOX_EXCEPTION(ExceptionName) \ 111 132 class ExceptionName##Exception : public Exception \ … … 129 150 // Creates all possible exception types. 130 151 // If you want to add a new type, simply copy and adjust a new line here. 131 #ifndef DOXYGEN_SHOULD_SKIP_THIS132 152 CREATE_ORXONOX_EXCEPTION(General); 133 153 CREATE_ORXONOX_EXCEPTION(FileNotFound); … … 142 162 CREATE_ORXONOX_EXCEPTION(NoGraphics); 143 163 CREATE_ORXONOX_EXCEPTION(AbortLoading); 144 #endif145 164 146 /** 147 @brief 148 Helper function that forwards an exception and displays the message. 165 /** Helper function that forwards an exception and displays the message. 149 166 @details 150 167 This is necessary because only when using 'throw' the objects storage is managed. … … 158 175 } 159 176 160 /** 161 @brief 162 Throws an exception and logs a message beforehand. 177 /** Throws an exception and logs a message beforehand. 163 178 @param type 164 179 Type of the exception as literal (General, Initialisation, etc.) 165 180 @param description 166 181 Exception description as string 182 @see Exception.h 167 183 */ 168 184 #define ThrowException(type, description) \ -
code/branches/doc/src/libraries/util/ExprParser.h
r6417 r7367 28 28 29 29 /** 30 31 30 @file 31 @brief Declaration of FloatParser 32 32 */ 33 33 … … 42 42 namespace orxonox 43 43 { 44 /** Parser for expressions like \c "3 * cos(5 + 4) / a" where \a a is a predeclared 45 variable. 46 @par Usage 47 Using it is rather simple: 48 @code 49 std::string str("3 + 4"); 50 ExprParser expr; 51 expr.parse(str); 52 if (expr.getSuccess()) 53 { 54 if (!expr.getRemains().empty()) 55 { 56 COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl; 57 } 58 double result = expr.getResult(); 59 } 60 else 61 COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl; 62 @endcode 63 getRemains() returns the expression after what could be parsed. For instance 64 \c "2*3 text" will return \c "text" as remains. 65 @details 66 The implementation of this class is really old and sort of a trial for 67 a first C++ class by Reto. That explains why it looks more like C than 68 C++... Also some of the variable names are in German. <br> 69 Explaining how it works exactly is probably not possible anymore, but it 70 is based on recursively parsing the expression character by character. 71 That much I can remember. 72 @par Functions, operators and variables supported 73 - Variables: 74 - e 75 - pi 76 - Functions: 77 - sin, asin, sinh, asinh 78 - cos, acos, cosh, acosh 79 - tan, atan, tanh, atanh 80 - int, floor, ceil, abs, sign 81 - pow, sqrt, exp, ln, log 82 - mod, div 83 - min, max 84 - radians, degrees 85 - Operators: 86 - +, -, ! (unary) 87 - +, -, *, /, %, ^, |, &, !, <, >, !=, <=, >=, = 88 @note 89 Operators may not be very consistent with C++ rules, but using the class 90 for plus and minus should be perfectly ok. 91 */ 44 92 class _UtilExport ExprParser 45 93 { -
code/branches/doc/src/libraries/util/MathConvert.h
r6417 r7367 28 28 29 29 /** 30 31 32 Math conversion functions. Definitions are in Math.cc30 @file 31 @brief 32 Conversion functions for Math types like Ogre::Vector3 (definitions are in Math.cc) 33 33 */ 34 34 … … 46 46 //////////////////// 47 47 48 // Vector2 to std::string48 /// Ogre::Vector2 to std::string conversion 49 49 template <> 50 50 struct ConverterExplicit<orxonox::Vector2, std::string> … … 62 62 }; 63 63 64 // Vector3 to std::string64 /// Ogre::Vector3 to std::string conversion 65 65 template <> 66 66 struct ConverterExplicit<orxonox::Vector3, std::string> … … 78 78 }; 79 79 80 // Vector4 to std::string80 /// Ogre::Vector4 to std::string conversion 81 81 template <> 82 82 struct ConverterExplicit<orxonox::Vector4, std::string> … … 94 94 }; 95 95 96 // Quaternion to std::string96 /// Ogre::Quaternion to std::string conversion 97 97 template <> 98 98 struct ConverterExplicit<orxonox::Quaternion, std::string> … … 110 110 }; 111 111 112 // ColourValue to std::string112 /// Ogre::ColourValue to std::string conversion 113 113 template <> 114 114 struct ConverterExplicit<orxonox::ColourValue, std::string> … … 131 131 //////////////////// 132 132 133 // std::string to Vector2133 /// std::string to Ogre::Vector2 conversion 134 134 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector2> 135 135 { static bool convert(orxonox::Vector2* output, const std::string& input); }; 136 // std::string to Vector3136 /// std::string to Ogre::Vector3 conversion 137 137 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector3> 138 138 { static bool convert(orxonox::Vector3* output, const std::string& input); }; 139 // std::string to Vector4139 /// std::string to Ogre::Vector4 conversion 140 140 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector4> 141 141 { static bool convert(orxonox::Vector4* output, const std::string& input); }; 142 // std::string to Quaternion142 /// std::string to Ogre::Quaternion conversion 143 143 template <> struct _UtilExport ConverterFallback<std::string, orxonox::Quaternion> 144 144 { static bool convert(orxonox::Quaternion* output, const std::string& input); }; 145 // std::string to ColourValue145 /// std::string to Ogre::ColourValue conversion 146 146 template <> struct _UtilExport ConverterFallback<std::string, orxonox::ColourValue> 147 147 { static bool convert(orxonox::ColourValue* output, const std::string& input); }; … … 152 152 /////////////////////////////// 153 153 154 // From Radian154 /// Delegates conversions from Radian to conversions from float 155 155 template <class ToType> 156 156 struct ConverterFallback<orxonox::Radian, ToType> … … 162 162 }; 163 163 164 // From Degree164 /// Delegates conversions from Degree to conversions from float 165 165 template <class ToType> 166 166 struct ConverterFallback<orxonox::Degree, ToType> … … 172 172 }; 173 173 174 // To Radian174 /// Delegates conversions to Radian to conversions to float 175 175 template <class FromType> 176 176 struct ConverterFallback<FromType, orxonox::Radian> … … 189 189 }; 190 190 191 // To Degree191 /// Delegates conversions to Degree to conversions to float 192 192 template <class FromType> 193 193 struct ConverterFallback<FromType, orxonox::Degree> -
code/branches/doc/src/libraries/util/OrxAssert.h
r6105 r7367 41 41 #include "OutputHandler.h" 42 42 43 // define an assert macro that can display a message44 43 #ifndef NDEBUG 44 /** Run time assertion like assert(), but with an embedded message. 45 @details 46 The message will be printed as error with COUT(1). <br> 47 You can use the same magic here as you can with \ref ThrowException 48 @code 49 OrxAssert(condition, "Text: " << number << " more text"); 50 @endcode 51 */ 45 52 #define OrxAssert(Assertion, ErrorMessage) \ 46 53 Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream(1) << ErrorMessage << std::endl); \ -
code/branches/doc/src/libraries/util/OrxEnum.h
r5738 r7367 27 27 */ 28 28 29 /**30 @file31 @brief32 Declaration of the OrxEnum class.33 */34 35 29 #ifndef _OrxEnum_H__ 36 30 #define _OrxEnum_H__ … … 40 34 namespace orxonox 41 35 { 36 /** Lightweight enumeration class that can be extended at run time. 37 @details 38 The class accepts type int and also defines operator int(). Therefore 39 int and OrxEnum can be used interchangeably so you can extend the content 40 of the enumeration at run time by adding ints. 41 @par Declaring an OrxEnum 42 Write a struct that inherits OrxEnum and use some macros: 43 @code 44 struct MyEnum : OrxEnum<MyEnum> 45 { 46 OrxEnumConstructors(MyEnum); 47 48 static const int Value1 = -1; 49 static const int Value2 = 0; 50 static const int Value3 = Value2 + 10; 51 }; 52 @endcode 53 */ 42 54 template <class T> 43 55 struct OrxEnum … … 45 57 public: 46 58 OrxEnum() { } 47 OrxEnum(int type) 59 OrxEnum(int type) { type_ = type; } 48 60 OrxEnum(const T& instance) { type_ = instance.type_; } 49 61 50 operator int() 62 operator int() { return type_; } 51 63 T& operator =(int type) { type_ = type; return *this; } 52 64 bool operator <(const T& right) const { return (type_ < right.type_); } … … 59 71 } 60 72 73 /// See orxonox::OrxEnum for more info 61 74 #define OrxEnumConstructors(enumName) \ 62 75 enumName() { } \ -
code/branches/doc/src/libraries/util/TriBool.h
r6746 r7367 35 35 namespace orxonox 36 36 { 37 /** Sort of a boolean value that also has state \c Dontcare 38 @remarks 39 Even though \c False has the value 0, both \c True and \c Dontcare have 40 a value other than 0. Keep that in mind when using TriBools in if statements. 41 */ 37 42 namespace TriBool 38 43 {
Note: See TracChangeset
for help on using the changeset viewer.