Changeset 11054 for code/branches/cpp11_v3/src/libraries/util
- Timestamp:
- Jan 10, 2016, 1:54:11 PM (10 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 deleted
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/src/libraries/util/CMakeLists.txt
r10624 r11054 26 26 CRC32.cc 27 27 ExprParser.cc 28 SharedPtr.cc29 28 Sleep.cc 30 29 SmallObjectAllocator.cc -
code/branches/cpp11_v3/src/libraries/util/Clipboard.cc
r8858 r11054 93 93 { 94 94 HANDLE hData = GetClipboardData(CF_TEXT); 95 if (hData == NULL)95 if (hData == nullptr) 96 96 return ""; 97 97 std::string output(static_cast<char*>(GlobalLock(hData))); -
code/branches/cpp11_v3/src/libraries/util/Clock.h
r7401 r11054 102 102 103 103 private: 104 /// Undefined 105 Clock(const Clock& instance); 104 // non-copyable: 105 Clock(const Clock&) = delete; 106 Clock& operator=(const Clock&) = delete; 106 107 107 108 Ogre::Timer* timer_; ///< Ogre timer object -
code/branches/cpp11_v3/src/libraries/util/DestructionHelper.h
r8423 r11054 36 36 /** Deletes an object and resets the pointer 37 37 @param object 38 Pointer to an object. Handing over NULLis safe.38 Pointer to an object. Handing over nullptr is safe. 39 39 */ 40 40 template <class T> … … 42 42 { 43 43 delete *object; 44 *object = NULL;44 *object = nullptr; 45 45 } 46 46 … … 87 87 88 88 private: 89 DestructionHelper(const DestructionHelper&); //!< Don't use (undefined) 89 // non-copyable: 90 DestructionHelper(const DestructionHelper&) = delete; 91 DestructionHelper& operator=(const DestructionHelper&) = delete; 90 92 91 93 T* object_; -
code/branches/cpp11_v3/src/libraries/util/DisplayStringConversions.h
r6417 r11054 51 51 { 52 52 Ogre::UTFString::code_point cp; 53 for ( unsigned int i = 0; i < input.size(); ++i)53 for (const char& character : input) 54 54 { 55 cp = input[i];55 cp = character; 56 56 cp &= 0xFF; 57 57 output->append(1, cp); -
code/branches/cpp11_v3/src/libraries/util/ExprParser.cc
r8351 r11054 391 391 } 392 392 393 char*ExprParser::parse_word(char* str)393 void ExprParser::parse_word(char* str) 394 394 { 395 395 char* word = str; … … 402 402 { 403 403 this->failed_ = true; 404 return '\0';404 return; 405 405 } 406 406 }; 407 407 *word = '\0'; 408 return str;409 408 } 410 409 -
code/branches/cpp11_v3/src/libraries/util/ExprParser.h
r8858 r11054 139 139 float parse_expr_7(); 140 140 float parse_expr_8(); 141 char*parse_word(char* str);141 void parse_word(char* str); 142 142 binary_operator parse_binary_operator(); 143 143 unary_operator parse_unary_operator(); -
code/branches/cpp11_v3/src/libraries/util/ImplicitConversion.h
r8267 r11054 68 68 { 69 69 private: 70 ImplicitConversion(); ImplicitConversion(const ImplicitConversion&); ~ImplicitConversion(); 70 // static class, no instances allowed: 71 ImplicitConversion() = delete; 72 ImplicitConversion(const ImplicitConversion&) = delete; 73 ImplicitConversion& operator=(const ImplicitConversion&) = delete; 74 ~ImplicitConversion() = delete; 75 71 76 // Gets chosen only if there is an implicit conversion from FromType to ToType. 72 77 static char test(ToType); -
code/branches/cpp11_v3/src/libraries/util/Math.cc
r11052 r11054 371 371 } 372 372 373 374 namespace detail 375 { 376 std::mt19937 rngen; 377 } 378 373 379 /** 374 380 @brief Returns a unique number. This function will never return the same value twice. -
code/branches/cpp11_v3/src/libraries/util/Math.h
r11052 r11054 46 46 #include <cmath> 47 47 #include <cstdlib> 48 #include <random> 48 49 49 50 #include <OgreMath.h> … … 73 74 namespace math 74 75 { 75 const float twoPi = 6.283185482025146484375f; ///< PI * 276 const float pi = 3.1415927410125732421875f; ///< PI77 const float pi_2 = 1.57079637050628662109375f; ///< PI / 278 const float pi_4 = 0.785398185253143310546875f; ///< PI / 479 const float e = 2.718281269073486328125f; ///< e80 const float sqrt2 = 1.41421353816986083984375f; ///< sqrt(2)81 const float sqrt2_2 = 0.707106769084930419921875f; ///< sqrt(2) / 276 constexpr float twoPi = 6.283185482025146484375f; ///< PI * 2 77 constexpr float pi = 3.1415927410125732421875f; ///< PI 78 constexpr float pi_2 = 1.57079637050628662109375f; ///< PI / 2 79 constexpr float pi_4 = 0.785398185253143310546875f; ///< PI / 4 80 constexpr float e = 2.718281269073486328125f; ///< e 81 constexpr float sqrt2 = 1.41421353816986083984375f; ///< sqrt(2) 82 constexpr float sqrt2_2 = 0.707106769084930419921875f; ///< sqrt(2) / 2 82 83 } 83 84 … … 104 105 */ 105 106 template <typename T> 106 inline T sgn(T x)107 constexpr inline T sgn(T x) 107 108 { 108 109 return (x >= 0) ? (T)1 : (T)-1; … … 116 117 */ 117 118 template <typename T> 118 inline T clamp(T x, T min, T max) 119 { 120 if (x < min) 121 return min; 122 123 if (x > max) 124 return max; 125 126 return x; 119 constexpr inline T clamp(T x, T min, T max) 120 { 121 return x < min ? min : (x > max ? max : x); 127 122 } 128 123 … … 131 126 */ 132 127 template <typename T> 133 inline T square(T x)128 constexpr inline T square(T x) 134 129 { 135 130 return x*x; … … 140 135 */ 141 136 template <typename T> 142 inline T cube(T x)137 constexpr inline T cube(T x) 143 138 { 144 139 return x*x*x; … … 186 181 inline T zeroise() 187 182 { 188 // Default, raise a compiler error without including large boost header cascade. 189 T temp(); 190 *********temp; // If you reach this code, you abused zeroise()! 191 return temp; 183 // If you reach this code, you abused zeroise()! 184 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 192 185 } 193 186 … … 206 199 template <> inline long double zeroise<long double>() { return 0; } 207 200 template <> inline bool zeroise<bool>() { return 0; } 208 template <> inline void* zeroise<void*>() { return 0; }201 template <> inline void* zeroise<void*>() { return nullptr; } 209 202 template <> inline std::string zeroise<std::string>() { return std::string(); } 210 203 template <> inline orxonox::Radian zeroise<orxonox::Radian>() { return orxonox::Radian(0.0f); } … … 258 251 } 259 252 253 namespace detail 254 { 255 /** 256 Random number generator used for the functions below. Marked extern to only have one global instance. 257 */ 258 _UtilExport extern std::mt19937 rngen; 259 } 260 261 /** 262 @brief Seeds the random number generator used for the functions below. 263 */ 264 inline void rndseed(unsigned int seed) 265 { 266 detail::rngen.seed(seed); 267 } 268 269 /** 270 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 271 @param min The minimum 272 @param max The maximum 273 */ 274 inline float rnd(float min, float max) 275 { 276 std::uniform_real_distribution<float> dist(min, max); 277 return dist(detail::rngen); 278 } 279 260 280 /** 261 281 @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>. … … 263 283 inline float rnd() 264 284 { 265 return r and() / (RAND_MAX + 1.0f);285 return rnd(0, 1); 266 286 } 267 287 … … 272 292 inline float rnd(float max) 273 293 { 274 return rnd() * max; 275 } 276 277 /** 278 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 279 @param min The minimum 280 @param max The maximum 281 */ 282 inline float rnd(float min, float max) 283 { 284 return rnd(max - min) + min; 294 return rnd(0, max); 285 295 } 286 296 … … 290 300 inline float rndsgn() 291 301 { 292 return static_cast<float>((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0 302 std::uniform_int_distribution<> dist; 303 return static_cast<float>((dist(detail::rngen) & 0x2) - 1); // dist(...) & 0x2 is either 2 or 0 293 304 } 294 305 -
code/branches/cpp11_v3/src/libraries/util/MultiType.h
r10197 r11054 175 175 public: 176 176 inline MT_ValueBase(void* data, Type::Enum type) : type_(type), bLastConversionSuccessful(true), data_(data) {} 177 inline virtual~MT_ValueBase() {}177 virtual inline ~MT_ValueBase() {} 178 178 179 179 virtual MT_ValueBase* clone() const = 0; … … 266 266 267 267 /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. 268 inline MultiType() : value_( 0) { }268 inline MultiType() : value_(nullptr) { } 269 269 /// Constructor: Assigns the given value and sets the type. 270 270 template <typename V> 271 inline MultiType(const V& value) : value_( 0) { this->set(value); }271 inline MultiType(const V& value) : value_(nullptr) { this->set(value); } 272 272 /// Copyconstructor: Assigns value and type of the other MultiType. 273 inline MultiType(const MultiType& other) : value_( 0) { this->set(other); }273 inline MultiType(const MultiType& other) : value_(nullptr) { this->set(other); } 274 274 275 275 /// Destructor: Deletes the MT_Value. … … 325 325 if (this->value_) 326 326 delete this->value_; 327 this->value_ = (other.value_) ? other.value_->clone() : 0;327 this->value_ = (other.value_) ? other.value_->clone() : nullptr; 328 328 } 329 329 … … 332 332 333 333 /// Resets value and type. Type will be void afterwards and null() returns true. 334 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }334 inline void reset() { if (this->value_) delete this->value_; this->value_ = nullptr; } 335 335 /// Resets the value and changes the internal type to T. 336 336 template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } … … 428 428 } 429 429 /// Creates a new value container (works only with specialized types). 430 template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; } 430 template <typename T> inline void createNewValueContainer(const T& value) 431 { 432 // If you reach this code, you used MultiType with an unsupported type T 433 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 434 } 431 435 432 436 MT_ValueBase* value_; //!< A pointer to the value container … … 486 490 template <> inline long double MultiType::get() const { return (this->value_ ? this->value_->get<long double>() : 0); } 487 491 template <> inline bool MultiType::get() const { return (this->value_ ? this->value_->get<bool>() : 0); } 488 template <> inline void* MultiType::get() const { return (this->value_ ? this->value_->get<void*>() : 0); }492 template <> inline void* MultiType::get() const { return (this->value_ ? this->value_->get<void*>() : nullptr); } 489 493 template <> inline std::string MultiType::get() const { return (this->value_ ? this->value_->get<std::string>() : NilValue<std::string>()); } 490 494 template <> inline orxonox::Vector2 MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Vector2>() : NilValue<orxonox::Vector2>()); } -
code/branches/cpp11_v3/src/libraries/util/MultiTypeValue.h
r9550 r11054 58 58 59 59 /// Creates a copy of itself. 60 inline MT_ValueBase* clone() const{ return new MT_Value<T>(this->value_, this->type_); }60 virtual inline MT_ValueBase* clone() const override { return new MT_Value<T>(this->value_, this->type_); } 61 61 62 62 /// Resets the current value to the default. 63 inline void reset(){ this->value_ = zeroise<T>(); bLastConversionSuccessful = true; }64 65 inline bool getValue(char* value) const{ return convertValue<T, char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.66 inline bool getValue(unsigned char* value) const{ return convertValue<T, unsigned char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.67 inline bool getValue(short* value) const{ return convertValue<T, short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.68 inline bool getValue(unsigned short* value) const{ return convertValue<T, unsigned short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.69 inline bool getValue(int* value) const{ return convertValue<T, int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.70 inline bool getValue(unsigned int* value) const{ return convertValue<T, unsigned int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.71 inline bool getValue(long* value) const{ return convertValue<T, long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.72 inline bool getValue(unsigned long* value) const{ return convertValue<T, unsigned long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.73 inline bool getValue(long long* value) const{ return convertValue<T, long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.74 inline bool getValue(unsigned long long* value) const{ return convertValue<T, unsigned long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.75 inline bool getValue(float* value) const{ return convertValue<T, float >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.76 inline bool getValue(double* value) const{ return convertValue<T, double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.77 inline bool getValue(long double* value) const{ return convertValue<T, long double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.78 inline bool getValue(bool* value) const{ return convertValue<T, bool >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.79 inline bool getValue(void** value) const { return convertValue<T, void* >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.80 inline bool getValue(std::string* value) const{ return convertValue<T, std::string >(value, value_, NilValue<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.81 inline bool getValue(orxonox::Vector2* value) const{ return convertValue<T, orxonox::Vector2 >(value, value_, NilValue<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.82 inline bool getValue(orxonox::Vector3* value) const{ return convertValue<T, orxonox::Vector3 >(value, value_, NilValue<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.83 inline bool getValue(orxonox::Vector4* value) const{ return convertValue<T, orxonox::Vector4 >(value, value_, NilValue<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.84 inline bool getValue(orxonox::ColourValue* value) const{ return convertValue<T, orxonox::ColourValue>(value, value_, NilValue<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.85 inline bool getValue(orxonox::Quaternion* value) const{ return convertValue<T, orxonox::Quaternion >(value, value_, NilValue<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.86 inline bool getValue(orxonox::Radian* value) const{ return convertValue<T, orxonox::Radian >(value, value_, NilValue<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.87 inline bool getValue(orxonox::Degree* value) const{ return convertValue<T, orxonox::Degree >(value, value_, NilValue<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.63 virtual inline void reset() override { this->value_ = zeroise<T>(); bLastConversionSuccessful = true; } 64 65 virtual inline bool getValue(char* value) const override { return convertValue<T, char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 66 virtual inline bool getValue(unsigned char* value) const override { return convertValue<T, unsigned char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 67 virtual inline bool getValue(short* value) const override { return convertValue<T, short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 68 virtual inline bool getValue(unsigned short* value) const override { return convertValue<T, unsigned short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 69 virtual inline bool getValue(int* value) const override { return convertValue<T, int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 70 virtual inline bool getValue(unsigned int* value) const override { return convertValue<T, unsigned int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 71 virtual inline bool getValue(long* value) const override { return convertValue<T, long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 72 virtual inline bool getValue(unsigned long* value) const override { return convertValue<T, unsigned long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 73 virtual inline bool getValue(long long* value) const override { return convertValue<T, long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 74 virtual inline bool getValue(unsigned long long* value) const override { return convertValue<T, unsigned long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 75 virtual inline bool getValue(float* value) const override { return convertValue<T, float >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 76 virtual inline bool getValue(double* value) const override { return convertValue<T, double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 77 virtual inline bool getValue(long double* value) const override { return convertValue<T, long double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 78 virtual inline bool getValue(bool* value) const override { return convertValue<T, bool >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 79 virtual inline bool getValue(void** value) const override { return convertValue<T, void* >(value, value_, nullptr); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 80 virtual inline bool getValue(std::string* value) const override { return convertValue<T, std::string >(value, value_, NilValue<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 81 virtual inline bool getValue(orxonox::Vector2* value) const override { return convertValue<T, orxonox::Vector2 >(value, value_, NilValue<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 82 virtual inline bool getValue(orxonox::Vector3* value) const override { return convertValue<T, orxonox::Vector3 >(value, value_, NilValue<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 83 virtual inline bool getValue(orxonox::Vector4* value) const override { return convertValue<T, orxonox::Vector4 >(value, value_, NilValue<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 84 virtual inline bool getValue(orxonox::ColourValue* value) const override { return convertValue<T, orxonox::ColourValue>(value, value_, NilValue<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 85 virtual inline bool getValue(orxonox::Quaternion* value) const override { return convertValue<T, orxonox::Quaternion >(value, value_, NilValue<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 86 virtual inline bool getValue(orxonox::Radian* value) const override { return convertValue<T, orxonox::Radian >(value, value_, NilValue<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 87 virtual inline bool getValue(orxonox::Degree* value) const override { return convertValue<T, orxonox::Degree >(value, value_, NilValue<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 88 88 89 89 /** … … 91 91 @param other The other MultiType 92 92 */ 93 inline bool setValue(const MultiType& other)93 virtual inline bool setValue(const MultiType& other) override 94 94 { 95 95 if (other.value_) … … 104 104 } 105 105 106 inline bool setValue(const char& value){ return (bLastConversionSuccessful = convertValue<char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.107 inline bool setValue(const unsigned char& value){ return (bLastConversionSuccessful = convertValue<unsigned char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.108 inline bool setValue(const short& value){ return (bLastConversionSuccessful = convertValue<short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.109 inline bool setValue(const unsigned short& value){ return (bLastConversionSuccessful = convertValue<unsigned short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.110 inline bool setValue(const int& value){ return (bLastConversionSuccessful = convertValue<int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.111 inline bool setValue(const unsigned int& value){ return (bLastConversionSuccessful = convertValue<unsigned int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.112 inline bool setValue(const long& value){ return (bLastConversionSuccessful = convertValue<long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.113 inline bool setValue(const unsigned long& value){ return (bLastConversionSuccessful = convertValue<unsigned long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.114 inline bool setValue(const long long& value){ return (bLastConversionSuccessful = convertValue<long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.115 inline bool setValue(const unsigned long long& value){ return (bLastConversionSuccessful = convertValue<unsigned long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.116 inline bool setValue(const float& value){ return (bLastConversionSuccessful = convertValue<float , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.117 inline bool setValue(const double& value){ return (bLastConversionSuccessful = convertValue<double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.118 inline bool setValue(const long double& value){ return (bLastConversionSuccessful = convertValue<long double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.119 inline bool setValue(const bool& value){ return (bLastConversionSuccessful = convertValue<bool , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.120 inline bool setValue( void* const& value){ return (bLastConversionSuccessful = convertValue<void* , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.121 inline bool setValue(const std::string& value){ return (bLastConversionSuccessful = convertValue<std::string , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.122 inline bool setValue(const orxonox::Vector2& value){ return (bLastConversionSuccessful = convertValue<orxonox::Vector2 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.123 inline bool setValue(const orxonox::Vector3& value){ return (bLastConversionSuccessful = convertValue<orxonox::Vector3 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.124 inline bool setValue(const orxonox::Vector4& value){ return (bLastConversionSuccessful = convertValue<orxonox::Vector4 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.125 inline bool setValue(const orxonox::ColourValue& value){ return (bLastConversionSuccessful = convertValue<orxonox::ColourValue, T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.126 inline bool setValue(const orxonox::Quaternion& value){ return (bLastConversionSuccessful = convertValue<orxonox::Quaternion , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.127 inline bool setValue(const orxonox::Radian& value){ return (bLastConversionSuccessful = convertValue<orxonox::Radian , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.128 inline bool setValue(const orxonox::Degree& value){ return (bLastConversionSuccessful = convertValue<orxonox::Degree , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.106 virtual inline bool setValue(const char& value) override { return (bLastConversionSuccessful = convertValue<char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 107 virtual inline bool setValue(const unsigned char& value) override { return (bLastConversionSuccessful = convertValue<unsigned char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 108 virtual inline bool setValue(const short& value) override { return (bLastConversionSuccessful = convertValue<short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 109 virtual inline bool setValue(const unsigned short& value) override { return (bLastConversionSuccessful = convertValue<unsigned short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 110 virtual inline bool setValue(const int& value) override { return (bLastConversionSuccessful = convertValue<int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 111 virtual inline bool setValue(const unsigned int& value) override { return (bLastConversionSuccessful = convertValue<unsigned int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 112 virtual inline bool setValue(const long& value) override { return (bLastConversionSuccessful = convertValue<long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 113 virtual inline bool setValue(const unsigned long& value) override { return (bLastConversionSuccessful = convertValue<unsigned long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 114 virtual inline bool setValue(const long long& value) override { return (bLastConversionSuccessful = convertValue<long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 115 virtual inline bool setValue(const unsigned long long& value) override { return (bLastConversionSuccessful = convertValue<unsigned long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 116 virtual inline bool setValue(const float& value) override { return (bLastConversionSuccessful = convertValue<float , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 117 virtual inline bool setValue(const double& value) override { return (bLastConversionSuccessful = convertValue<double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 118 virtual inline bool setValue(const long double& value) override { return (bLastConversionSuccessful = convertValue<long double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 119 virtual inline bool setValue(const bool& value) override { return (bLastConversionSuccessful = convertValue<bool , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 120 virtual inline bool setValue( void* const& value) override { return (bLastConversionSuccessful = convertValue<void* , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 121 virtual inline bool setValue(const std::string& value) override { return (bLastConversionSuccessful = convertValue<std::string , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 122 virtual inline bool setValue(const orxonox::Vector2& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Vector2 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 123 virtual inline bool setValue(const orxonox::Vector3& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Vector3 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 124 virtual inline bool setValue(const orxonox::Vector4& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Vector4 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 125 virtual inline bool setValue(const orxonox::ColourValue& value) override { return (bLastConversionSuccessful = convertValue<orxonox::ColourValue, T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 126 virtual inline bool setValue(const orxonox::Quaternion& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Quaternion , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 127 virtual inline bool setValue(const orxonox::Radian& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Radian , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 128 virtual inline bool setValue(const orxonox::Degree& value) override { return (bLastConversionSuccessful = convertValue<orxonox::Degree , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T. 129 129 130 130 /// Puts the current value on the stream 131 inline void toString(std::ostream& outstream) const{ outstream << this->value_; }131 virtual inline void toString(std::ostream& outstream) const override { outstream << this->value_; } 132 132 133 133 /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data 134 inline void importData( uint8_t*& mem ){ loadAndIncrease( /*(const T&)*/this->value_, mem ); }134 virtual inline void importData( uint8_t*& mem ) override { loadAndIncrease( /*(const T&)*/this->value_, mem ); } 135 135 /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data 136 inline void exportData( uint8_t*& mem ) const{ saveAndIncrease( /*(const T&)*/this->value_, mem ); }136 virtual inline void exportData( uint8_t*& mem ) const override { saveAndIncrease( /*(const T&)*/this->value_, mem ); } 137 137 /// returns the size of the data that would be saved by exportData 138 inline uint8_t getSize() const{ return returnSize( this->value_ ); }138 virtual inline uint8_t getSize() const override { return returnSize( this->value_ ); } 139 139 140 140 T value_; ///< The stored value -
code/branches/cpp11_v3/src/libraries/util/Serialise.h
r8706 r11054 672 672 { 673 673 uint32_t tempsize = sizeof(uint32_t); // for the number of entries 674 for( typename std::set<T>::iterator it=((std::set<T>*)(&variable))->begin(); it!=((std::set<T>*)(&variable))->end(); ++it)675 tempsize += returnSize( *it );674 for(const T& element : *((std::set<T>*)(&variable))) 675 tempsize += returnSize( element ); 676 676 return tempsize; 677 677 } … … 679 679 template <class T> inline void saveAndIncrease( const std::set<T>& variable, uint8_t*& mem ) 680 680 { 681 typename std::set<T>::const_iterator it = variable.begin();682 681 saveAndIncrease( (uint32_t)variable.size(), mem ); 683 for( ; it!=variable.end(); ++it)684 saveAndIncrease( *it, mem );682 for( const T& elem : variable ) 683 saveAndIncrease( elem, mem ); 685 684 } 686 685 -
code/branches/cpp11_v3/src/libraries/util/SignalHandler.cc
r9682 r11054 44 44 namespace orxonox 45 45 { 46 SignalHandler* SignalHandler::singletonPtr_s = NULL;46 SignalHandler* SignalHandler::singletonPtr_s = nullptr; 47 47 } 48 48 … … 81 81 void SignalHandler::dontCatch() 82 82 { 83 for ( SignalRecList::iterator it = sigRecList.begin(); it != sigRecList.end(); it++)84 { 85 signal( it->signal, it->handler );83 for (const SignalRec& sigRec : sigRecList) 84 { 85 signal( sigRec.signal, sigRec.handler ); 86 86 } 87 87 … … 127 127 } 128 128 // if the signalhandler has already been destroyed then don't do anything 129 if( SignalHandler::singletonPtr_s == 0)129 if( SignalHandler::singletonPtr_s == nullptr ) 130 130 { 131 131 orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl; … … 133 133 } 134 134 135 for ( SignalCallbackList::iterator it = SignalHandler::getInstance().callbackList.begin(); it != SignalHandler::getInstance().callbackList.end(); it++)136 { 137 (*( it->cb))( it->someData );135 for (const SignalCallbackRec& callback : SignalHandler::getInstance().callbackList) 136 { 137 (*(callback.cb))( callback.someData ); 138 138 } 139 139 … … 175 175 dup2( gdbErr[1], STDERR_FILENO ); 176 176 177 execlp( "sh", "sh", "-c", "gdb", static_cast<void*>( NULL));177 execlp( "sh", "sh", "-c", "gdb", static_cast<void*>(nullptr)); 178 178 } 179 179 … … 186 186 perror("pipe failed!\n"); 187 187 kill( gdbPid, SIGTERM ); 188 waitpid( gdbPid, NULL, 0 );188 waitpid( gdbPid, nullptr, 0 ); 189 189 exit(EXIT_FAILURE); 190 190 } … … 196 196 perror("fork failed!\n"); 197 197 kill( gdbPid, SIGTERM ); 198 waitpid( gdbPid, NULL, 0 );198 waitpid( gdbPid, nullptr, 0 ); 199 199 exit(EXIT_FAILURE); 200 200 } … … 297 297 298 298 299 waitpid( sigPid, NULL, 0 );300 waitpid( gdbPid, NULL, 0 );299 waitpid( sigPid, nullptr, 0 ); 300 waitpid( gdbPid, nullptr, 0 ); 301 301 302 302 int wsRemoved = 0; … … 312 312 bt.erase(0, 1); 313 313 314 time_t now = time( NULL);314 time_t now = time(nullptr); 315 315 316 316 std::string timeString = … … 388 388 SignalHandler::SignalHandler() 389 389 { 390 this->prevExceptionFilter_ = NULL;390 this->prevExceptionFilter_ = nullptr; 391 391 } 392 392 … … 394 394 SignalHandler::~SignalHandler() 395 395 { 396 if (this->prevExceptionFilter_ != NULL)396 if (this->prevExceptionFilter_ != nullptr) 397 397 { 398 398 // Remove the unhandled exception filter function 399 399 SetUnhandledExceptionFilter(this->prevExceptionFilter_); 400 this->prevExceptionFilter_ = NULL;400 this->prevExceptionFilter_ = nullptr; 401 401 } 402 402 } … … 408 408 409 409 // don't register twice 410 assert(this->prevExceptionFilter_ == NULL);411 412 if (this->prevExceptionFilter_ == NULL)410 assert(this->prevExceptionFilter_ == nullptr); 411 412 if (this->prevExceptionFilter_ == nullptr) 413 413 { 414 414 // Install the unhandled exception filter function … … 430 430 431 431 // if the signalhandler has already been destroyed then don't do anything 432 if (SignalHandler::singletonPtr_s == 0)432 if (SignalHandler::singletonPtr_s == nullptr) 433 433 { 434 434 orxout(user_error) << "Caught an unhandled exception" << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl; … … 441 441 std::ofstream crashlog(SignalHandler::getInstance().filename_.c_str()); 442 442 443 time_t now = time( NULL);443 time_t now = time(nullptr); 444 444 445 445 crashlog << "=======================================================" << endl; … … 480 480 } 481 481 482 /// Returns the stack trace for either the current function, or, if @a pExceptionInfo is not NULL, for the given exception context.482 /// Returns the stack trace for either the current function, or, if @a pExceptionInfo is not nullptr, for the given exception context. 483 483 /* static */ std::string SignalHandler::getStackTrace(PEXCEPTION_POINTERS pExceptionInfo) 484 484 { … … 625 625 #ifdef ORXONOX_COMPILER_GCC 626 626 int status; 627 char* demangled = __cxxabiv1::__cxa_demangle(symbol->Name, NULL, NULL, &status);627 char* demangled = __cxxabiv1::__cxa_demangle(symbol->Name, nullptr, nullptr, &status); 628 628 if (demangled) 629 629 { … … 684 684 HMODULE hModule; 685 685 686 std::string output = (GetModuleFileName( NULL, szModule, MAX_PATH) ? SignalHandler::getModuleName(szModule) : "Application");686 std::string output = (GetModuleFileName(nullptr, szModule, MAX_PATH) ? SignalHandler::getModuleName(szModule) : "Application"); 687 687 output += " caused "; 688 688 -
code/branches/cpp11_v3/src/libraries/util/SignalHandler.h
r9550 r11054 113 113 void doCatch(const std::string& appName, const std::string& filename); 114 114 115 static std::string getStackTrace(PEXCEPTION_POINTERS pExceptionInfo = NULL);115 static std::string getStackTrace(PEXCEPTION_POINTERS pExceptionInfo = nullptr); 116 116 static std::string getExceptionType(PEXCEPTION_POINTERS pExceptionInfo); 117 117 -
code/branches/cpp11_v3/src/libraries/util/Singleton.h
r10624 r11054 66 66 And don't forget to initialize the static singleton pointer in the source (*.cc) %file: 67 67 @code 68 TestSingleton* TestSingleton::singletonPtr_s = NULL;68 TestSingleton* TestSingleton::singletonPtr_s = nullptr; 69 69 @endcode 70 70 … … 118 118 static T& getInstance() 119 119 { 120 OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());120 OrxVerify(T::singletonPtr_s != nullptr, "T=" << typeid(T).name()); 121 121 return *T::singletonPtr_s; 122 122 } … … 125 125 static bool exists() 126 126 { 127 return (T::singletonPtr_s != NULL);127 return (T::singletonPtr_s != nullptr); 128 128 } 129 129 … … 132 132 Singleton() 133 133 { 134 OrxVerify(T::singletonPtr_s == NULL, "T=" << typeid(T).name());134 OrxVerify(T::singletonPtr_s == nullptr, "T=" << typeid(T).name()); 135 135 T::singletonPtr_s = static_cast<T*>(this); 136 136 } … … 139 139 virtual ~Singleton() 140 140 { 141 OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());142 T::singletonPtr_s = NULL;141 OrxVerify(T::singletonPtr_s != nullptr, "T=" << typeid(T).name()); 142 T::singletonPtr_s = nullptr; 143 143 } 144 144 145 145 private: 146 Singleton(const Singleton& rhs); //!< Don't use (undefined) 146 // non-copyable: 147 Singleton(const Singleton&) = delete; 148 Singleton& operator=(const Singleton&) = delete; 147 149 }; 148 150 } -
code/branches/cpp11_v3/src/libraries/util/SmallObjectAllocator.cc
r7401 r11054 45 45 this->chunkSize_ = std::max(objectSize, sizeof(Chunk)); // the chunk's size will be the maximum of the object's size and the size of a Chunk object itself 46 46 this->numChunksPerBlock_ = numObjects; 47 this->first_ = 0;47 this->first_ = nullptr; 48 48 } 49 49 … … 53 53 SmallObjectAllocator::~SmallObjectAllocator() 54 54 { 55 for ( std::vector<char*>::iterator it = this->blocks_.begin(); it != this->blocks_.end(); ++it)56 delete[] *it;55 for (char* block : this->blocks_) 56 delete[] block; 57 57 } 58 58 … … 97 97 setNext(block + i * this->chunkSize_, block + (i + 1) * this->chunkSize_); 98 98 99 // the next_ pointer of the last chunk must point to NULL100 setNext(block + (this->numChunksPerBlock_ - 1) * this->chunkSize_, 0);99 // the next_ pointer of the last chunk must point to nullptr 100 setNext(block + (this->numChunksPerBlock_ - 1) * this->chunkSize_, nullptr); 101 101 102 102 // The second chunk in the block is assigned to the first_ pointer -
code/branches/cpp11_v3/src/libraries/util/SmallObjectAllocator.h
r7401 r11054 77 77 #include "UtilPrereqs.h" 78 78 #include <vector> 79 #include <cstdio> 79 80 80 81 namespace orxonox -
code/branches/cpp11_v3/src/libraries/util/StringUtils.cc
r9550 r11054 36 36 #include <cctype> 37 37 #include <ctime> 38 #include <boost/scoped_array.hpp>39 38 #include "Convert.h" 40 39 #include "Math.h" … … 263 262 std::string output(str.size() * 2, ' '); 264 263 size_t i = 0; 265 for ( size_t pos = 0; pos < str.size(); ++pos)266 { 267 switch ( str[pos])264 for (const char& character : str) 265 { 266 switch (character) 268 267 { 269 268 case '\\': output[i] = '\\'; output[i + 1] = '\\'; break; … … 277 276 case '"': output[i] = '\\'; output[i + 1] = '"'; break; 278 277 case '\0': output[i] = '\\'; output[i + 1] = '0'; break; 279 default : output[i] = str[pos]; ++i; continue;278 default : output[i] = character; ++i; continue; 280 279 } 281 280 i += 2; … … 337 336 void lowercase(std::string* str) 338 337 { 339 for ( size_t i = 0; i < str->size(); ++i)340 { 341 (*str)[i] = static_cast<char>(tolower((*str)[i]));338 for (char& character : *str) 339 { 340 character = static_cast<char>(tolower(character)); 342 341 } 343 342 } … … 354 353 void uppercase(std::string* str) 355 354 { 356 for ( size_t i = 0; i < str->size(); ++i)357 { 358 (*str)[i] = static_cast<char>(toupper((*str)[i]));355 for (char& character : *str) 356 { 357 character = static_cast<char>(toupper(character)); 359 358 } 360 359 } … … 461 460 { 462 461 size_t j = 0; 463 for ( size_t i = 0; i < str.size(); ++i)464 { 465 if ( str[i]== target)462 for (char& character : str) 463 { 464 if (character == target) 466 465 { 467 str[i]= replacement;466 character = replacement; 468 467 ++j; 469 468 } … … 482 481 size_t cols = str1.size() + 1; 483 482 size_t rows = str2.size() + 1; 484 boost::scoped_array<int> matrix(new int[rows * cols]);483 const std::unique_ptr<int[]> matrix(new int[rows * cols]); 485 484 486 485 for (size_t r = 0; r < rows; ++r) -
code/branches/cpp11_v3/src/libraries/util/SubString.cc
r9550 r11054 112 112 for (size_t i = 0; i < argc; ++i) 113 113 { 114 this->tokens_. push_back(std::string(argv[i]));114 this->tokens_.emplace_back(argv[i]); 115 115 this->bTokenInSafemode_.push_back(false); 116 116 } -
code/branches/cpp11_v3/src/libraries/util/UtilPrereqs.h
r10624 r11054 80 80 class OutputStream; 81 81 class ScopeListener; 82 template <class T>83 class SharedPtr;84 82 class SignalHandler; 85 83 template <class T> -
code/branches/cpp11_v3/src/libraries/util/output/BaseWriter.cc
r8858 r11054 47 47 this->configurableMaxLevel_ = level::none; 48 48 this->configurableAdditionalContextsMaxLevel_ = level::verbose; 49 this->configurableAdditionalContexts_. push_back("example");49 this->configurableAdditionalContexts_.emplace_back("example"); 50 50 51 51 this->changedConfigurableLevel(); … … 116 116 117 117 // iterate over all strings in the config-vector 118 for ( size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i)118 for (const std::string& full_name : this->configurableAdditionalContexts_) 119 119 { 120 const std::string& full_name = this->configurableAdditionalContexts_[i];121 122 120 // split the name into main-name and sub-name (if given; otherwise sub-name remains empty). both names are separated by :: 123 121 std::string name = full_name; -
code/branches/cpp11_v3/src/libraries/util/output/BaseWriter.h
r8858 r11054 103 103 104 104 protected: 105 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) ;105 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) override; 106 106 107 107 private: -
code/branches/cpp11_v3/src/libraries/util/output/ConsoleWriter.h
r9550 r11054 53 53 public: 54 54 ConsoleWriter(std::ostream& outputStream); 55 ConsoleWriter(const ConsoleWriter&);56 55 virtual ~ConsoleWriter(); 57 56 … … 63 62 64 63 protected: 65 virtual void printLine(const std::string& line, OutputLevel level) ;64 virtual void printLine(const std::string& line, OutputLevel level) override; 66 65 67 66 private: 67 // non-copyable: 68 ConsoleWriter(const ConsoleWriter&) = delete; 69 ConsoleWriter& operator=(const ConsoleWriter&) = delete; 70 68 71 std::ostream& outputStream_; ///< The ostream to which the console writer writes its output 69 72 bool bEnabled_; ///< If false, the instance will not write output to the console. -
code/branches/cpp11_v3/src/libraries/util/output/LogWriter.cc
r9550 r11054 35 35 36 36 #include <ctime> 37 #include <chrono> 37 38 #include <cstdlib> 38 39 … … 43 44 namespace orxonox 44 45 { 45 static const int MAX_ARCHIVED_FILES = 9;46 static constexpr int MAX_ARCHIVED_FILES = 9; 46 47 47 48 /** … … 180 181 return; 181 182 183 // get the milliseconds 184 std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); 185 std::chrono::system_clock::duration timeSinceEpoch = now.time_since_epoch(); 186 std::chrono::milliseconds millisSinceEpoch = std::chrono::duration_cast<std::chrono::milliseconds>(timeSinceEpoch); 187 unsigned int millis = (millisSinceEpoch.count() % 1000); 188 182 189 // get the current time 183 time_t rawtime; 184 struct tm* timeinfo; 185 time(&rawtime); 186 timeinfo = localtime(&rawtime); 190 time_t rawtime = std::chrono::system_clock::to_time_t(now); 191 struct tm* timeinfo = localtime(&rawtime); 192 193 // format time: hh:mm:ss:xxx 194 char buffer[13]; 195 snprintf(buffer, sizeof(buffer), "%.2i:%.2i:%.2i:%.3i", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, millis); 187 196 188 197 // print timestamp and output line to the log file 189 this->file_ << (timeinfo->tm_hour < 10 ? "0" : "") << timeinfo->tm_hour << ':' << 190 (timeinfo->tm_min < 10 ? "0" : "") << timeinfo->tm_min << ':' << 191 (timeinfo->tm_sec < 10 ? "0" : "") << timeinfo->tm_sec << ' ' << line << std::endl; 198 this->file_ << buffer << ' ' << line << std::endl; 192 199 } 193 200 } -
code/branches/cpp11_v3/src/libraries/util/output/LogWriter.h
r9550 r11054 57 57 public: 58 58 LogWriter(); 59 LogWriter(const LogWriter&);60 59 virtual ~LogWriter(); 61 60 … … 70 69 71 70 protected: 72 virtual void printLine(const std::string& line, OutputLevel level) ;71 virtual void printLine(const std::string& line, OutputLevel level) override; 73 72 74 73 private: 74 // non-copyable: 75 LogWriter(const LogWriter&) = delete; 76 LogWriter& operator=(const LogWriter&) = delete; 77 75 78 void openFile(); 76 79 void closeFile(); -
code/branches/cpp11_v3/src/libraries/util/output/MemoryWriter.cc
r9550 r11054 57 57 void MemoryWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) 58 58 { 59 this->messages_. push_back(Message(level, context, lines));59 this->messages_.emplace_back(level, context, lines); 60 60 } 61 61 … … 65 65 void MemoryWriter::resendOutput(OutputListener* listener) const 66 66 { 67 for ( size_t i = 0; i < this->messages_.size(); ++i)67 for (const Message& message : this->messages_) 68 68 { 69 const Message& message = this->messages_[i];70 69 listener->unfilteredOutput(message.level, *message.context, message.lines); 71 70 } -
code/branches/cpp11_v3/src/libraries/util/output/MemoryWriter.h
r9550 r11054 68 68 public: 69 69 MemoryWriter(); 70 MemoryWriter(const MemoryWriter&);71 70 virtual ~MemoryWriter(); 72 71 … … 75 74 76 75 protected: 77 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) ;76 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) override; 78 77 79 78 private: 79 // non-copyable: 80 MemoryWriter(const MemoryWriter&) = delete; 81 MemoryWriter& operator=(const MemoryWriter&) = delete; 82 80 83 std::vector<Message> messages_; ///< Stores all output messages from the creation of this instance until disable() is called. 81 84 }; -
code/branches/cpp11_v3/src/libraries/util/output/OutputDefinitions.h
r10624 r11054 132 132 namespace context 133 133 { 134 static const OutputContextMask all = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1135 static const OutputContextMask none = 0x0000000000000000ull; ///< Context mask, all bits set to 0134 static constexpr OutputContextMask all = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1 135 static constexpr OutputContextMask none = 0x0000000000000000ull; ///< Context mask, all bits set to 0 136 136 137 static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts137 static constexpr OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts 138 138 139 139 namespace -
code/branches/cpp11_v3/src/libraries/util/output/OutputListener.cc
r9550 r11054 111 111 this->levelMask_ = mask; 112 112 113 for ( size_t i = 0; i < this->listeners_.size(); ++i)114 this->listeners_[i]->updatedLevelMask(this);113 for (AdditionalContextListener* listener : this->listeners_) 114 listener->updatedLevelMask(this); 115 115 } 116 116 … … 142 142 this->additionalContextsLevelMask_ = mask; 143 143 144 for ( size_t i = 0; i < this->listeners_.size(); ++i)145 this->listeners_[i]->updatedAdditionalContextsLevelMask(this);144 for (AdditionalContextListener* listener : this->listeners_) 145 listener->updatedAdditionalContextsLevelMask(this); 146 146 } 147 147 … … 153 153 this->additionalContextsMask_ = mask; 154 154 155 for ( size_t i = 0; i < this->listeners_.size(); ++i)156 this->listeners_[i]->updatedAdditionalContextsMask(this);155 for (AdditionalContextListener* listener : this->listeners_) 156 listener->updatedAdditionalContextsMask(this); 157 157 } 158 158 -
code/branches/cpp11_v3/src/libraries/util/output/OutputManager.cc
r9550 r11054 41 41 #include "util/Output.h" 42 42 #include "util/StringUtils.h" 43 #include "util/SharedPtr.h"44 43 45 44 namespace orxonox … … 57 56 58 57 this->isInitialized_ = false; 59 this->memoryWriterInstance_ = 0;60 this->consoleWriterInstance_ = 0;61 this->logWriterInstance_ = 0;58 this->memoryWriterInstance_ = nullptr; 59 this->consoleWriterInstance_ = nullptr; 60 this->logWriterInstance_ = nullptr; 62 61 63 62 // register 'undefined' context in order to give it always the first context-ID … … 81 80 } 82 81 83 /*static*/ SharedPtr<OutputManager>& OutputManager::Testing::getInstancePointer()84 { 85 static SharedPtr<OutputManager> instance(new OutputManager());82 /*static*/ std::shared_ptr<OutputManager>& OutputManager::Testing::getInstancePointer() 83 { 84 static std::shared_ptr<OutputManager> instance(new OutputManager()); 86 85 return instance; 87 86 } … … 132 131 vectorize(message, '\n', &lines); 133 132 134 for ( size_t i = 0; i < this->listeners_.size(); ++i)135 this->listeners_[i]->unfilteredOutput(level, context, lines);133 for (OutputListener* listener : this->listeners_) 134 listener->unfilteredOutput(level, context, lines); 136 135 } 137 136 … … 179 178 { 180 179 int mask = 0; 181 for ( size_t i = 0; i < this->listeners_.size(); ++i)182 mask |= this->listeners_[i]->getLevelMask();180 for (OutputListener* listener : this->listeners_) 181 mask |= listener->getLevelMask(); 183 182 this->combinedLevelMask_ = static_cast<OutputLevel>(mask); 184 183 } … … 190 189 { 191 190 int mask = 0; 192 for ( size_t i = 0; i < this->listeners_.size(); ++i)193 mask |= this->listeners_[i]->getAdditionalContextsLevelMask();191 for (OutputListener* listener : this->listeners_) 192 mask |= listener->getAdditionalContextsLevelMask(); 194 193 this->combinedAdditionalContextsLevelMask_ = static_cast<OutputLevel>(mask); 195 194 } … … 201 200 { 202 201 this->combinedAdditionalContextsMask_ = 0; 203 for ( size_t i = 0; i < this->listeners_.size(); ++i)204 this->combinedAdditionalContextsMask_ |= this->listeners_[i]->getAdditionalContextsMask();202 for (OutputListener* listener : this->listeners_) 203 this->combinedAdditionalContextsMask_ |= listener->getAdditionalContextsMask(); 205 204 } 206 205 -
code/branches/cpp11_v3/src/libraries/util/output/OutputManager.h
r9550 r11054 41 41 #include <vector> 42 42 #include <map> 43 #include <memory> 43 44 44 45 #include "OutputDefinitions.h" … … 66 67 public: 67 68 OutputManager(); 68 OutputManager(const OutputManager&);69 69 virtual ~OutputManager(); 70 70 … … 81 81 virtual void unregisterListener(OutputListener* listener); 82 82 83 virtual void updatedLevelMask(const OutputListener* listener) 83 virtual void updatedLevelMask(const OutputListener* listener) override 84 84 { this->updateCombinedLevelMask(); } 85 virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) 85 virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) override 86 86 { this->updateCombinedAdditionalContextsLevelMask(); } 87 virtual void updatedAdditionalContextsMask(const OutputListener* listener) 87 virtual void updatedAdditionalContextsMask(const OutputListener* listener) override 88 88 { this->updateCombinedAdditionalContextsMask(); } 89 89 … … 114 114 115 115 private: 116 // non-copyable: 117 OutputManager(const OutputManager&) = delete; 118 OutputManager& operator=(const OutputManager&) = delete; 119 116 120 void updateMasks(); 117 121 void updateCombinedLevelMask(); … … 137 141 struct _UtilExport Testing 138 142 { 139 static SharedPtr<OutputManager>& getInstancePointer();143 static std::shared_ptr<OutputManager>& getInstancePointer(); 140 144 }; 141 145 }; -
code/branches/cpp11_v3/src/libraries/util/output/OutputStream.cc
r8858 r11054 41 41 @brief Default constructor, initializes level and context with default values. 42 42 */ 43 OutputStream::OutputStream() 43 OutputStream::OutputStream() : OutputStream(level::debug_output, context::undefined()) 44 44 { 45 this->setOutputAttributes(level::debug_output, context::undefined());46 45 } 47 46 -
code/branches/cpp11_v3/src/libraries/util/output/SubcontextOutputListener.cc
r8858 r11054 79 79 80 80 // compose the mask of subcontexts and build the set of sub-context-IDs 81 for ( std::set<const OutputContextContainer*>::const_iterator it = subcontexts.begin(); it != subcontexts.end(); ++it)81 for (const OutputContextContainer* subcontext : subcontexts) 82 82 { 83 this->subcontextsCheckMask_ |= (*it)->mask;84 this->subcontexts_.insert( (*it)->sub_id);83 this->subcontextsCheckMask_ |= subcontext->mask; 84 this->subcontexts_.insert(subcontext->sub_id); 85 85 } 86 86 -
code/branches/cpp11_v3/src/libraries/util/output/SubcontextOutputListener.h
r9550 r11054 73 73 virtual ~SubcontextOutputListener(); 74 74 75 virtual void setAdditionalContextsMask(OutputContextMask mask) ;75 virtual void setAdditionalContextsMask(OutputContextMask mask) override; 76 76 void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts); 77 77 78 virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const ;78 virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const override; 79 79 80 80 inline const std::set<OutputContextSubID>& getSubcontexts() const
Note: See TracChangeset
for help on using the changeset viewer.