Changeset 2662 for code/trunk/src/util
- Timestamp:
- Feb 14, 2009, 10:17:35 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 15 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/util
- Property svn:mergeinfo changed
/code/branches/network/src/util (added) merged: 2356 /code/branches/network64/src/util (added) merged: 2245 /code/branches/objecthierarchy2/src/util (added) merged: 2257,2259,2343-2345,2361 /code/branches/overlay/src/util (added) merged: 2180 /code/branches/physics/src/util (added) merged: 2192,2298,2305,2424 /code/branches/physics_merge/src/util (added) merged: 2442 /code/branches/pickups2/src/util (added) merged: 2136 /code/branches/presentation/src/util (added) merged: 2371,2420,2459,2485,2492-2493,2500,2535,2541-2542,2560
- Property svn:mergeinfo changed
-
code/trunk/src/util/Convert.h
r2171 r2662 460 460 else 461 461 *output = "false"; 462 return false;462 return true; 463 463 } 464 464 }; -
code/trunk/src/util/Exception.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/core/Exception.cc reverse-merged: 1638,1664 /code/branches/network/src/util/Exception.cc (added) merged: 2356 /code/branches/physics/src/util/Exception.cc (added) merged: 2192 /code/branches/physics_merge/src/util/Exception.cc (added) merged: 2442 /code/branches/pickups2/src/util/Exception.cc (added) merged: 2136 /code/branches/presentation/src/util/Exception.cc (added) merged: 2371,2420,2459,2485,2492-2493,2500
- Property svn:mergeinfo changed
-
code/trunk/src/util/Exception.h
- Property svn:mergeinfo changed
/code/branches/gui/src/core/Exception.h reverse-merged: 1638,1642,1645,1652,1660,1663-1664,1670,1704 /code/branches/network/src/util/Exception.h (added) merged: 2356 /code/branches/objecthierarchy2/src/util/Exception.h (added) merged: 2257,2259 /code/branches/physics/src/util/Exception.h (added) merged: 2192,2298,2305 /code/branches/physics_merge/src/util/Exception.h (added) merged: 2442 /code/branches/pickups2/src/util/Exception.h (added) merged: 2136 /code/branches/presentation/src/util/Exception.h (added) merged: 2371,2420,2459,2485,2492-2493,2500
r2261 r2662 82 82 const char* filename, const char* functionName) \ 83 83 : Exception(description, lineNumber, filename, functionName) \ 84 { \ 85 /* Let the catcher decide whether to display the message below level 4 \ 86 Note: Don't place this code in Exception c'tor because getTypeName() \ 87 is still pure virtual at that time. */ \ 88 COUT(4) << this->getFullDescription() << std::endl; \ 89 } \ 84 { } \ 90 85 \ 91 86 ExceptionName##Exception(const std::string& description) \ 92 87 : Exception(description) \ 93 { COUT(4) << this->getFullDescription() << std::endl; }\88 { } \ 94 89 \ 95 90 ~ExceptionName##Exception() throw() { } \ … … 103 98 CREATE_ORXONOX_EXCEPTION(FileNotFound); 104 99 CREATE_ORXONOX_EXCEPTION(Argument); 100 CREATE_ORXONOX_EXCEPTION(PhysicsViolation); 101 CREATE_ORXONOX_EXCEPTION(ParseError); 105 102 CREATE_ORXONOX_EXCEPTION(PluginsNotFound); 106 103 CREATE_ORXONOX_EXCEPTION(InitialisationFailed); … … 111 108 } 112 109 113 #define ThrowException(Type, Description) \ 114 throw Type##Exception(Description, __LINE__, __FILE__, __FUNCTIONNAME__) 110 /** 111 @brief 112 Helper function that creates an exception, displays the message, but doesn't throw it. 113 */ 114 template <class T> 115 inline const T& InternalHandleException(const T& exception) 116 { 117 // let the catcher decide whether to display the message below level 4 118 COUT(4) << exception.getFullDescription() << std::endl; 119 return exception; 120 } 121 122 #define ThrowException(type, description) \ 123 throw InternalHandleException(type##Exception(description, __LINE__, __FILE__, __FUNCTIONNAME__)) 115 124 116 125 // define an assert macro that can display a message - Property svn:mergeinfo changed
-
code/trunk/src/util/Integers.h
r1755 r2662 49 49 typedef unsigned __int32 uint32_t; 50 50 typedef unsigned __int64 uint64_t; 51 #el if ORXONOX_COMPILER == ORXONOX_COMPILER_GCC52 # include "inttypes.h"51 #else 52 # include <inttypes.h> 53 53 #endif 54 54 -
code/trunk/src/util/Math.h
r2171 r2662 63 63 namespace orxonox 64 64 { 65 typedef Ogre::Radian Radian; 66 typedef Ogre::Degree Degree; 67 typedef Ogre::Vector2 Vector2; 68 typedef Ogre::Vector3 Vector3; 69 typedef Ogre::Vector4 Vector4; 70 typedef Ogre::Matrix3 Matrix3; 71 typedef Ogre::Matrix4 Matrix4; 72 typedef Ogre::Quaternion Quaternion; 73 typedef Ogre::ColourValue ColourValue; 65 using Ogre::Radian; 66 using Ogre::Degree; 67 using Ogre::Vector2; 68 using Ogre::Vector3; 69 using Ogre::Vector4; 70 using Ogre::Matrix3; 71 using Ogre::Matrix4; 72 using Ogre::Quaternion; 73 using Ogre::ColourValue; 74 75 // Also define our own transform space enum 76 namespace TransformSpace 77 { 78 /** 79 @brief 80 Enumeration denoting the spaces which a transform can be relative to. 81 */ 82 enum Enum 83 { 84 //! Transform is relative to the local space 85 Local, 86 //! Transform is relative to the space of the parent node 87 Parent, 88 //! Transform is relative to world space 89 World 90 }; 91 } 74 92 75 93 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian); … … 174 192 inline T zeroise() 175 193 { 176 BOOST_STATIC_ASSERT(sizeof(T) == 0); 177 return T(); 194 // Default, raise a compiler error without including large boost header cascade. 195 T temp(); 196 *********temp; // If you reach this code, you abused zeroise()! 197 return temp; 178 198 } 179 199 -
code/trunk/src/util/MultiType.cc
r2171 r2662 45 45 switch (type) 46 46 { 47 case MT_null: 48 this->reset(); return true; 47 49 case MT_char: 48 50 return this->convert<char>(); break; -
code/trunk/src/util/MultiType.h
r2171 r2662 305 305 306 306 /** @brief Current content gets deleted. New type is MT_null */ 307 inline void reset() { if (this->value_) this->value_->reset(); } 308 309 template <typename T> inline void setType() { this->assignValue(T()); } /** @brief Resets the value and changes the internal type to T. */ 310 inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ 311 inline void setType(MT_Type type) { this->reset(); this->convert(type); this->reset(); } /** @brief Resets the value and changes the internal type to the given type. */ 307 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; } 308 /** @brief Current content gets overridden with default zero value */ 309 inline void resetValue() { if (this->value_) this->value_->reset(); } 310 311 template <typename T> inline void setType() { this->assignValue(T()); } /** @brief Resets the value and changes the internal type to T. */ 312 inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ 313 inline void setType(MT_Type type) { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */ 312 314 313 315 /** @brief Returns the current type. */ -
code/trunk/src/util/OutputHandler.cc
r2171 r2662 100 100 @param buffer The OutputBuffer 101 101 */ 102 void OutputHandler::setOutputBuffer(OutputBuffer& buffer) 103 { 104 buffer.getStream() >> this->outputBuffer_->getStream().rdbuf(); 105 this->outputBuffer_ = &buffer; 102 void OutputHandler::setOutputBuffer(OutputBuffer* buffer) 103 { 104 if (buffer == NULL) 105 this->outputBuffer_ = &this->fallbackBuffer_; 106 else 107 { 108 buffer->getStream() >> this->outputBuffer_->getStream().rdbuf(); 109 this->outputBuffer_ = buffer; 110 } 106 111 } 107 112 -
code/trunk/src/util/OutputHandler.h
r2171 r2662 101 101 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 102 102 103 void setOutputBuffer(OutputBuffer &buffer);103 void setOutputBuffer(OutputBuffer* buffer); 104 104 105 105 template <class T> -
code/trunk/src/util/SignalHandler.cc
- Property svn:mergeinfo changed
/code/branches/core3/src/orxonox/SignalHandler.cc reverse-merged: 1607,1678 /code/branches/network/src/util/SignalHandler.cc (added) merged: 2356 /code/branches/objecthierarchy2/src/util/SignalHandler.cc (added) merged: 2344-2345 /code/branches/physics_merge/src/util/SignalHandler.cc (added) merged: 2442 /code/branches/presentation/src/util/SignalHandler.cc (added) merged: 2371,2420,2459,2485,2492-2493,2500 /code/trunk/src/util/SignalHandler.cc (added) merged: 2-2085
r2261 r2662 35 35 #include "Debug.h" 36 36 37 #include <cassert>38 37 #include <iostream> 39 38 #include <cstdlib> … … 42 41 namespace orxonox 43 42 { 44 SignalHandler * SignalHandler::singletonRef= NULL;43 SignalHandler* SignalHandler::singletonRef_s = NULL; 45 44 } 46 45 … … 55 54 { 56 55 bool SignalHandler::bXAutoKeyRepeatOn_ = false; 57 58 SignalHandler::SignalHandler()59 {60 }61 56 62 57 /** … … 133 128 void SignalHandler::sigHandler( int sig ) 134 129 { 135 for ( SignalCallbackList::iterator it = SignalHandler::getInstance() ->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++ )130 for ( SignalCallbackList::iterator it = SignalHandler::getInstance().callbackList.begin(); it != SignalHandler::getInstance().callbackList.end(); it++ ) 136 131 { 137 132 (*(it->cb))( it->someData ); … … 184 179 if ( sigPid == 0 ) 185 180 { 186 getInstance() ->dontCatch();181 getInstance().dontCatch(); 187 182 // wait for message from parent when it has attached gdb 188 183 int someData; … … 237 232 238 233 char cmd[256]; 239 snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance() ->appName.c_str(), sigPid );234 snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance().appName.c_str(), sigPid ); 240 235 write( gdbIn[1], cmd, strlen(cmd) ); 241 236 … … 331 326 bt.insert(0, timeString); 332 327 333 FILE * f = fopen( getInstance() ->filename.c_str(), "a" );328 FILE * f = fopen( getInstance().filename.c_str(), "a" ); 334 329 335 330 if ( !f ) 336 331 { 337 perror( ( std::string( "could not append to " ) + getInstance() ->filename ).c_str() );332 perror( ( std::string( "could not append to " ) + getInstance().filename ).c_str() ); 338 333 exit(EXIT_FAILURE); 339 334 } … … 341 336 if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() ) 342 337 { 343 COUT(0) << "could not write " << bt.length() << " byte to " << getInstance() ->filename << std::endl;338 COUT(0) << "could not write " << bt.length() << " byte to " << getInstance().filename << std::endl; 344 339 exit(EXIT_FAILURE); 345 340 } - Property svn:mergeinfo changed
-
code/trunk/src/util/SignalHandler.h
- Property svn:mergeinfo changed
/code/branches/core3/src/orxonox/SignalHandler.h reverse-merged: 1607 /code/branches/network/src/util/SignalHandler.h (added) merged: 2356 /code/branches/objecthierarchy2/src/util/SignalHandler.h (added) merged: 2344 /code/branches/physics_merge/src/util/SignalHandler.h (added) merged: 2442 /code/branches/presentation/src/util/SignalHandler.h (added) merged: 2371,2420,2459,2485,2492-2493,2500 /code/trunk/src/util/SignalHandler.h (added) merged: 2-2085
r2261 r2662 37 37 #include "UtilPrereqs.h" 38 38 39 #include <cassert> 39 40 #include <list> 40 41 #include <string> … … 68 69 class SignalHandler 69 70 { 70 private:71 SignalHandler();72 71 public: 73 inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; } 74 ~SignalHandler(){ SignalHandler::singletonRef = NULL; } 72 SignalHandler() { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; } 73 ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = NULL; } 74 inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; } 75 75 76 76 void registerCallback( SignalCallback cb, void * someData ); … … 87 87 SignalCallbackList callbackList; 88 88 89 static SignalHandler * singletonRef;89 static SignalHandler* singletonRef_s; 90 90 91 91 std::string appName; … … 104 104 { 105 105 public: 106 inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }; 107 void doCatch( const std::string & appName, const std::string & filename ) {}; 108 void dontCatch() {}; 109 void registerCallback( SignalCallback cb, void * someData ) {}; 106 SignalHandler() { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; } 107 ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = 0; } 108 inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; } 109 void doCatch( const std::string & appName, const std::string & filename ) {} 110 void dontCatch() {} 111 void registerCallback( SignalCallback cb, void * someData ) {} 110 112 111 113 private: 112 static SignalHandler * singletonRef;114 static SignalHandler* singletonRef_s; 113 115 }; 114 116 } - Property svn:mergeinfo changed
-
code/trunk/src/util/String.cc
r2171 r2662 84 84 { 85 85 size_t pos1 = 0; 86 int pos2 = str.size() - 1;86 int pos2 = (int)(str.size() - 1); 87 87 for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++); 88 88 for (; pos2 > 0 && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--); -
code/trunk/src/util/mbool.h
r2171 r2662 36 36 struct _UtilExport mbool 37 37 { 38 // friend Synchronisable::registerVariable<>() 38 39 public: 39 40 inline mbool(bool value = false) … … 67 68 inline bool operator!() const 68 69 { return (!this->value_.bool_); } 70 71 inline unsigned char& getMemory(){ return value_.memory_; } 69 72 70 73 private:
Note: See TracChangeset
for help on using the changeset viewer.