Changeset 11071 for code/trunk/src/libraries/util
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/util/CMakeLists.txt
r10624 r11071 26 26 CRC32.cc 27 27 ExprParser.cc 28 SharedPtr.cc29 28 Sleep.cc 30 29 SmallObjectAllocator.cc -
code/trunk/src/libraries/util/Clipboard.cc
r8858 r11071 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/trunk/src/libraries/util/Clock.h
r7401 r11071 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/trunk/src/libraries/util/DestructionHelper.h
r8423 r11071 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/trunk/src/libraries/util/DisplayStringConversions.h
r6417 r11071 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/trunk/src/libraries/util/ExprParser.cc
r8351 r11071 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/trunk/src/libraries/util/ExprParser.h
r8858 r11071 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/trunk/src/libraries/util/ImplicitConversion.h
r8267 r11071 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/trunk/src/libraries/util/Math.cc
r11052 r11071 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/trunk/src/libraries/util/Math.h
r11052 r11071 46 46 #include <cmath> 47 47 #include <cstdlib> 48 #include <random> 49 #include <type_traits> 48 50 49 51 #include <OgreMath.h> … … 73 75 namespace math 74 76 { 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) / 277 constexpr float twoPi = 6.283185482025146484375f; ///< PI * 2 78 constexpr float pi = 3.1415927410125732421875f; ///< PI 79 constexpr float pi_2 = 1.57079637050628662109375f; ///< PI / 2 80 constexpr float pi_4 = 0.785398185253143310546875f; ///< PI / 4 81 constexpr float e = 2.718281269073486328125f; ///< e 82 constexpr float sqrt2 = 1.41421353816986083984375f; ///< sqrt(2) 83 constexpr float sqrt2_2 = 0.707106769084930419921875f; ///< sqrt(2) / 2 82 84 } 83 85 … … 104 106 */ 105 107 template <typename T> 106 inline T sgn(T x)108 constexpr inline T sgn(T x) 107 109 { 108 110 return (x >= 0) ? (T)1 : (T)-1; … … 116 118 */ 117 119 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; 120 constexpr inline T clamp(T x, T min, T max) 121 { 122 return x < min ? min : (x > max ? max : x); 127 123 } 128 124 … … 131 127 */ 132 128 template <typename T> 133 inline T square(T x)129 constexpr inline T square(T x) 134 130 { 135 131 return x*x; … … 140 136 */ 141 137 template <typename T> 142 inline T cube(T x)138 constexpr inline T cube(T x) 143 139 { 144 140 return x*x*x; … … 183 179 @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>. 184 180 */ 185 template <typename T> 186 inline T zeroise() 187 { 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; 181 template <typename T> /* for normal classes */ typename std::enable_if<!std::is_enum<T>::value, T>::type 182 inline /*T*/ zeroise() 183 { 184 // If you reach this code, you abused zeroise()! 185 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 186 } 187 /// Implementation for enum classes: uses the underlying type to create a zero value. 188 template <typename T> /* for enum classes */ typename std::enable_if<std::is_enum<T>::value, T>::type 189 inline /*T*/ zeroise() 190 { 191 return static_cast<T>(zeroise<typename std::underlying_type<T>::type>()); 192 192 } 193 193 … … 206 206 template <> inline long double zeroise<long double>() { return 0; } 207 207 template <> inline bool zeroise<bool>() { return 0; } 208 template <> inline void* zeroise<void*>() { return 0; }208 template <> inline void* zeroise<void*>() { return nullptr; } 209 209 template <> inline std::string zeroise<std::string>() { return std::string(); } 210 210 template <> inline orxonox::Radian zeroise<orxonox::Radian>() { return orxonox::Radian(0.0f); } … … 258 258 } 259 259 260 namespace detail 261 { 262 /** 263 Random number generator used for the functions below. Marked extern to only have one global instance. 264 */ 265 _UtilExport extern std::mt19937 rngen; 266 } 267 268 /** 269 @brief Seeds the random number generator used for the functions below. 270 */ 271 inline void rndseed(unsigned int seed) 272 { 273 detail::rngen.seed(seed); 274 } 275 276 /** 277 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 278 @param min The minimum 279 @param max The maximum 280 */ 281 inline float rnd(float min, float max) 282 { 283 std::uniform_real_distribution<float> dist(min, max); 284 return dist(detail::rngen); 285 } 286 260 287 /** 261 288 @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>. … … 263 290 inline float rnd() 264 291 { 265 return r and() / (RAND_MAX + 1.0f);292 return rnd(0, 1); 266 293 } 267 294 … … 272 299 inline float rnd(float max) 273 300 { 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; 301 return rnd(0, max); 285 302 } 286 303 … … 290 307 inline float rndsgn() 291 308 { 292 return static_cast<float>((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0 309 std::uniform_int_distribution<> dist; 310 return static_cast<float>((dist(detail::rngen) & 0x2) - 1); // dist(...) & 0x2 is either 2 or 0 293 311 } 294 312 -
code/trunk/src/libraries/util/MultiType.cc
r9550 r11071 43 43 @param type The type 44 44 */ 45 bool MultiType::convert(Type ::Enumtype)45 bool MultiType::convert(Type type) 46 46 { 47 47 switch (type) … … 106 106 std::string MultiType::getTypename() const 107 107 { 108 Type ::Enumtype = (this->value_) ? this->value_->type_ : Type::Null;108 Type type = (this->value_) ? this->value_->type_ : Type::Null; 109 109 110 110 switch (type) -
code/trunk/src/libraries/util/MultiType.h
r10197 r11071 132 132 template <typename T> friend class MT_Value; 133 133 134 struct Type 134 /** 135 @brief Enum of all possible types of a MultiType. 136 */ 137 enum class Type : uint8_t 135 138 { 136 /** 137 @brief Enum of all possible types of a MultiType. 138 */ 139 enum Enum 140 { 141 Null, 142 Char, 143 UnsignedChar, 144 Short, 145 UnsignedShort, 146 Int, 147 UnsignedInt, 148 Long, 149 UnsignedLong, 150 LongLong, 151 UnsignedLongLong, 152 Float, 153 Double, 154 LongDouble, 155 Bool, 156 VoidPointer, 157 String, 158 Vector2, 159 Vector3, 160 Vector4, 161 ColourValue, 162 Quaternion, 163 Radian, 164 Degree 165 }; 139 Null, 140 Char, 141 UnsignedChar, 142 Short, 143 UnsignedShort, 144 Int, 145 UnsignedInt, 146 Long, 147 UnsignedLong, 148 LongLong, 149 UnsignedLongLong, 150 Float, 151 Double, 152 LongDouble, 153 Bool, 154 VoidPointer, 155 String, 156 Vector2, 157 Vector3, 158 Vector4, 159 ColourValue, 160 Quaternion, 161 Radian, 162 Degree 166 163 }; 167 164 … … 174 171 { 175 172 public: 176 inline MT_ValueBase(void* data, Type ::Enumtype) : type_(type), bLastConversionSuccessful(true), data_(data) {}177 inline virtual~MT_ValueBase() {}173 inline MT_ValueBase(void* data, Type type) : type_(type), bLastConversionSuccessful(true), data_(data) {} 174 virtual inline ~MT_ValueBase() {} 178 175 179 176 virtual MT_ValueBase* clone() const = 0; … … 182 179 183 180 /// Returns the type of the current value. 184 inline const Type::Enum& getType() const { return this->type_; } 185 /// Returns true if the type of the stored value is T. 186 template <typename T> inline bool isType() const { return false; } 181 inline const Type& getType() const { return this->type_; } 182 183 /// Returns true if the type of the stored value is T. Note: the actual implementations for all supported types are defined outside of the class. 184 template <typename T> /* for normal classes */ typename std::enable_if<!std::is_enum<T>::value, bool>::type 185 inline /*bool*/ isType() const 186 { 187 // If you reach this code, you used MultiType with an unsupported type T 188 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 189 return false; 190 } 191 /// Implementation for enum classes: Returns true if the type of the stored value is the underlying type of T. 192 template <typename T> /* for enum classes */ typename std::enable_if<std::is_enum<T>::value, bool>::type 193 inline /*bool*/ isType() const 194 { 195 return this->isType<typename std::underlying_type<T>::type>(); 196 } 187 197 188 198 /// Checks whether the value is a default one. … … 215 225 virtual bool setValue(const MultiType& other) = 0; 216 226 227 template <typename T> /* for normal classes */ typename std::enable_if<!std::is_enum<T>::value, bool>::type 228 inline /*bool*/ setValue(const T& value) 229 { 230 // If you reach this code, you used MultiType with an unsupported type T 231 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 232 return false; 233 } 234 template <typename T> /* for enum classes */ typename std::enable_if<std::is_enum<T>::value, bool>::type 235 inline /*bool*/ setValue(const T& value) 236 { 237 typedef typename std::underlying_type<T>::type UnderlyingType; 238 return this->setValue(reinterpret_cast<const UnderlyingType&>(value)); 239 } 240 217 241 virtual bool getValue(char* value) const = 0; 218 242 virtual bool getValue(unsigned char* value) const = 0; … … 239 263 virtual bool getValue(orxonox::Degree* value) const = 0; 240 264 265 template <typename T> /* for normal classes */ typename std::enable_if<!std::is_enum<T>::value, bool>::type 266 inline /*bool*/ getValue(T* value) const 267 { 268 // If you reach this code, you used MultiType with an unsupported type T 269 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 270 return false; 271 } 272 template <typename T> /* for enum classes */ typename std::enable_if<std::is_enum<T>::value, bool>::type 273 inline /*bool*/ getValue(T* value) const 274 { 275 typedef typename std::underlying_type<T>::type UnderlyingType; 276 return this->getValue(reinterpret_cast<UnderlyingType*>(value)); 277 } 278 241 279 template <typename T> T get() const 242 280 { … … 257 295 virtual uint8_t getSize() const = 0; 258 296 259 Type ::Enum type_;///< The type of the current value297 Type type_; ///< The type of the current value 260 298 bool bLastConversionSuccessful; ///< True if the last conversion was successful 261 299 void* data_; ///< For direct access to the value if the type is known … … 266 304 267 305 /// 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) { }306 inline MultiType() : value_(nullptr) { } 269 307 /// Constructor: Assigns the given value and sets the type. 270 308 template <typename V> 271 inline MultiType(const V& value) : value_( 0) { this->set(value); }309 inline MultiType(const V& value) : value_(nullptr) { this->set(value); } 272 310 /// Copyconstructor: Assigns value and type of the other MultiType. 273 inline MultiType(const MultiType& other) : value_( 0) { this->set(other); }311 inline MultiType(const MultiType& other) : value_(nullptr) { this->set(other); } 274 312 275 313 /// Destructor: Deletes the MT_Value. … … 325 363 if (this->value_) 326 364 delete this->value_; 327 this->value_ = (other.value_) ? other.value_->clone() : 0;365 this->value_ = (other.value_) ? other.value_->clone() : nullptr; 328 366 } 329 367 … … 332 370 333 371 /// 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; }372 inline void reset() { if (this->value_) delete this->value_; this->value_ = nullptr; } 335 373 /// Resets the value and changes the internal type to T. 336 374 template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } … … 354 392 template <typename T> inline bool getValue(T* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } 355 393 356 /// Returns the current value, converted to the requested type. This base implementation works only for pointers. All other supported types are 357 /// implemented in specialized functions at the bottom of this file. 358 template <typename T> inline T get() const { return static_cast<T>(this->get<void*>()); } 394 /// Returns the current value, converted to the requested type. 395 template <typename T> /* for normal types */ typename std::enable_if<!std::is_pointer<T>::value, T>::type 396 inline /*T*/ get() const { return (this->value_ ? this->value_->get<T>() : NilValue<T>()); } 397 /// Returns the current value, converted to a pointer of the requested type. 398 template <typename T> /* for pointers */ typename std::enable_if<std::is_pointer<T>::value, T>::type 399 inline /*T*/ get() const { return this->value_ ? static_cast<T>(this->value_->get<void*>()) : nullptr; } 359 400 360 401 … … 365 406 inline void exportData(uint8_t*& mem) const 366 407 { 367 assert(sizeof(Type ::Enum) <= 8);368 *static_cast<uint8_t*>(mem) = this->getType();408 assert(sizeof(Type) <= 8); 409 *static_cast<uint8_t*>(mem) = static_cast<uint8_t>(this->getType()); 369 410 mem += sizeof(uint8_t); 370 411 this->value_->exportData(mem); … … 373 414 inline void importData(uint8_t*& mem) 374 415 { 375 assert(sizeof(Type ::Enum) <= 8);376 this->setType(static_cast<Type ::Enum>(*static_cast<uint8_t*>(mem)));416 assert(sizeof(Type) <= 8); 417 this->setType(static_cast<Type>(*static_cast<uint8_t*>(mem))); 377 418 mem += sizeof(uint8_t); 378 419 this->value_->importData(mem); … … 414 455 415 456 /// Resets the value and changes the internal type to the given type. 416 inline void setType(Type ::Enumtype) { this->reset(); this->convert(type); this->resetValue(); }457 inline void setType(Type type) { this->reset(); this->convert(type); this->resetValue(); } 417 458 /// Returns the current type. 418 inline Type ::EnumgetType() const { return (this->value_) ? this->value_->type_ : Type::Null; }459 inline Type getType() const { return (this->value_) ? this->value_->type_ : Type::Null; } 419 460 /// Converts the current value to the given type. 420 bool convert(Type ::Enumtype);461 bool convert(Type type); 421 462 422 463 /// Changes the value container. … … 428 469 } 429 470 /// 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; } 471 template <typename T> /* for normal classes */ typename std::enable_if<!std::is_enum<T>::value>::type 472 inline /*void*/ createNewValueContainer(const T& value) 473 { 474 // If you reach this code, you used MultiType with an unsupported type T 475 static_assert(sizeof(T) != sizeof(T), "No template specialization available for T"); 476 } 477 /// Creates a new value container (implementation for enum classes that must be cast to the underlying type). 478 template <typename T> /* for enum classes */ typename std::enable_if<std::is_enum<T>::value>::type 479 inline /*void*/ createNewValueContainer(const T& value) 480 { 481 typedef typename std::underlying_type<T>::type UnderlyingType; 482 this->createNewValueContainer<UnderlyingType>(reinterpret_cast<const UnderlyingType&>(value)); 483 } 431 484 432 485 MT_ValueBase* value_; //!< A pointer to the value container … … 471 524 template <> inline bool MultiType::isType<void>() const { return this->null(); } 472 525 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } 473 474 template <> inline char MultiType::get() const { return (this->value_ ? this->value_->get<char>() : 0); }475 template <> inline unsigned char MultiType::get() const { return (this->value_ ? this->value_->get<unsigned char>() : 0); }476 template <> inline short MultiType::get() const { return (this->value_ ? this->value_->get<short>() : 0); }477 template <> inline unsigned short MultiType::get() const { return (this->value_ ? this->value_->get<unsigned short>() : 0); }478 template <> inline int MultiType::get() const { return (this->value_ ? this->value_->get<int>() : 0); }479 template <> inline unsigned int MultiType::get() const { return (this->value_ ? this->value_->get<unsigned int>() : 0); }480 template <> inline long MultiType::get() const { return (this->value_ ? this->value_->get<long>() : 0); }481 template <> inline unsigned long MultiType::get() const { return (this->value_ ? this->value_->get<unsigned long>() : 0); }482 template <> inline long long MultiType::get() const { return (this->value_ ? this->value_->get<long long>() : 0); }483 template <> inline unsigned long long MultiType::get() const { return (this->value_ ? this->value_->get<unsigned long long>() : 0); }484 template <> inline float MultiType::get() const { return (this->value_ ? this->value_->get<float>() : 0); }485 template <> inline double MultiType::get() const { return (this->value_ ? this->value_->get<double>() : 0); }486 template <> inline long double MultiType::get() const { return (this->value_ ? this->value_->get<long double>() : 0); }487 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); }489 template <> inline std::string MultiType::get() const { return (this->value_ ? this->value_->get<std::string>() : NilValue<std::string>()); }490 template <> inline orxonox::Vector2 MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Vector2>() : NilValue<orxonox::Vector2>()); }491 template <> inline orxonox::Vector3 MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Vector3>() : NilValue<orxonox::Vector3>()); }492 template <> inline orxonox::Vector4 MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Vector4>() : NilValue<orxonox::Vector4>()); }493 template <> inline orxonox::ColourValue MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::ColourValue>() : NilValue<orxonox::ColourValue>()); }494 template <> inline orxonox::Quaternion MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Quaternion>() : NilValue<orxonox::Quaternion>()); }495 template <> inline orxonox::Radian MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Radian>() : NilValue<orxonox::Radian>()); }496 template <> inline orxonox::Degree MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Degree>() : NilValue<orxonox::Degree>()); }497 526 498 527 template <> _UtilExport void MultiType::createNewValueContainer(const char& value); -
code/trunk/src/libraries/util/MultiTypeValue.h
r9550 r11071 55 55 public: 56 56 /// Constructor: Assigns the value and the type identifier. 57 MT_Value(const T& value, MultiType::Type ::Enumtype) : MT_ValueBase(&this->value_, type), value_(value) {}57 MT_Value(const T& value, MultiType::Type type) : MT_ValueBase(&this->value_, type), value_(value) {} 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/trunk/src/libraries/util/Serialise.h
r8706 r11071 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/trunk/src/libraries/util/SignalHandler.cc
r9682 r11071 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/trunk/src/libraries/util/SignalHandler.h
r9550 r11071 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/trunk/src/libraries/util/Singleton.h
r10624 r11071 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/trunk/src/libraries/util/SmallObjectAllocator.cc
r7401 r11071 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/trunk/src/libraries/util/SmallObjectAllocator.h
r7401 r11071 77 77 #include "UtilPrereqs.h" 78 78 #include <vector> 79 #include <cstdio> 79 80 80 81 namespace orxonox -
code/trunk/src/libraries/util/StringUtils.cc
r9550 r11071 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/trunk/src/libraries/util/SubString.cc
r9550 r11071 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 } … … 265 265 bool inSafemode = false; 266 266 267 if(start_state != S L_NORMAL && tokens.size() > 0)267 if(start_state != SPLIT_LINE_STATE::NORMAL && tokens.size() > 0) 268 268 { 269 269 token = tokens[tokens.size()-1]; 270 270 tokens.pop_back(); 271 271 } 272 if(start_state != S L_NORMAL && bTokenInSafemode.size() > 0)272 if(start_state != SPLIT_LINE_STATE::NORMAL && bTokenInSafemode.size() > 0) 273 273 { 274 274 inSafemode = bTokenInSafemode[bTokenInSafemode.size()-1]; … … 280 280 switch(state) 281 281 { 282 case S L_NORMAL:282 case SPLIT_LINE_STATE::NORMAL: 283 283 if(line[i] == escapeChar) 284 284 { 285 state = S L_ESCAPE;285 state = SPLIT_LINE_STATE::ESCAPE; 286 286 if (!bRemoveEscapeChar) 287 287 token += line[i]; … … 290 290 else if(line[i] == safemodeChar) 291 291 { 292 state = S L_SAFEMODE;292 state = SPLIT_LINE_STATE::SAFEMODE; 293 293 inSafemode = true; 294 294 if (!bRemoveSafemodeChar) … … 298 298 else if(line[i] == openparenthesisChar) 299 299 { 300 state = S L_PARENTHESES;300 state = SPLIT_LINE_STATE::PARENTHESES; 301 301 inSafemode = true; 302 302 if (!bRemoveParenthesisChars) … … 318 318 } 319 319 token += line[i]; // EAT 320 state = S L_COMMENT;320 state = SPLIT_LINE_STATE::COMMENT; 321 321 } 322 322 else if(delimiters.find(line[i]) != std::string::npos) … … 334 334 inSafemode = false; 335 335 } 336 state = S L_NORMAL;336 state = SPLIT_LINE_STATE::NORMAL; 337 337 } 338 338 else … … 353 353 } 354 354 break; 355 case S L_ESCAPE:355 case SPLIT_LINE_STATE::ESCAPE: 356 356 if (!bRemoveSafemodeChar) 357 357 token += line[i]; … … 368 368 else token += line[i]; // EAT 369 369 } 370 state = S L_NORMAL;371 break; 372 case S L_SAFEMODE:370 state = SPLIT_LINE_STATE::NORMAL; 371 break; 372 case SPLIT_LINE_STATE::SAFEMODE: 373 373 if(line[i] == safemodeChar) 374 374 { 375 state = S L_NORMAL;375 state = SPLIT_LINE_STATE::NORMAL; 376 376 if (!bRemoveSafemodeChar) 377 377 token += line[i]; … … 379 379 else if(line[i] == escapeChar) 380 380 { 381 state = S L_SAFEESCAPE;381 state = SPLIT_LINE_STATE::SAFEESCAPE; 382 382 } 383 383 else … … 387 387 break; 388 388 389 case S L_SAFEESCAPE:389 case SPLIT_LINE_STATE::SAFEESCAPE: 390 390 if(line[i] == 'n') token += '\n'; 391 391 else if(line[i] == 't') token += '\t'; … … 397 397 else if(line[i] == '?') token += '\?'; 398 398 else token += line[i]; // EAT 399 state = S L_SAFEMODE;400 break; 401 402 case S L_PARENTHESES:399 state = SPLIT_LINE_STATE::SAFEMODE; 400 break; 401 402 case SPLIT_LINE_STATE::PARENTHESES: 403 403 if(line[i] == closeparenthesisChar) 404 404 { 405 state = S L_NORMAL;405 state = SPLIT_LINE_STATE::NORMAL; 406 406 if (!bRemoveParenthesisChars) 407 407 token += line[i]; … … 409 409 else if(line[i] == escapeChar) 410 410 { 411 state = S L_PARENTHESESESCAPE;411 state = SPLIT_LINE_STATE::PARENTHESESESCAPE; 412 412 } 413 413 else … … 417 417 break; 418 418 419 case S L_PARENTHESESESCAPE:419 case SPLIT_LINE_STATE::PARENTHESESESCAPE: 420 420 if(line[i] == 'n') token += '\n'; 421 421 else if(line[i] == 't') token += '\t'; … … 427 427 else if(line[i] == '?') token += '\?'; 428 428 else token += line[i]; // EAT 429 state = S L_PARENTHESES;430 break; 431 432 case S L_COMMENT:429 state = SPLIT_LINE_STATE::PARENTHESES; 430 break; 431 432 case SPLIT_LINE_STATE::COMMENT: 433 433 if(line[i] == '\n') 434 434 { … … 441 441 inSafemode = false; 442 442 } 443 state = S L_NORMAL;443 state = SPLIT_LINE_STATE::NORMAL; 444 444 } 445 445 else -
code/trunk/src/libraries/util/SubString.h
r9550 r11071 102 102 { 103 103 /// An enumerator for the internal state of the parser 104 enum SPLIT_LINE_STATE104 enum class SPLIT_LINE_STATE 105 105 { 106 SL_NORMAL, //!< Normal state107 SL_ESCAPE, //!< After an escape character108 S L_SAFEMODE, //!< In safe mode (usually between quotation marks).109 S L_SAFEESCAPE, //!< In safe mode with the internal escape character, that escapes even the savemode character.110 SL_COMMENT, //!< In Comment mode.111 SL_PARENTHESES, //!< Between parentheses (usually '{' and '}')112 SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing parenthesis character.106 NORMAL, //!< Normal state 107 ESCAPE, //!< After an escape character 108 SAFEMODE, //!< In safe mode (usually between quotation marks). 109 SAFEESCAPE, //!< In safe mode with the internal escape character, that escapes even the savemode character. 110 COMMENT, //!< In Comment mode. 111 PARENTHESES, //!< Between parentheses (usually '{' and '}') 112 PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing parenthesis character. 113 113 }; 114 114 … … 204 204 bool bRemoveParenthesisChars = true, 205 205 char commentChar = '\0', 206 SPLIT_LINE_STATE start_state = S L_NORMAL);206 SPLIT_LINE_STATE start_state = SPLIT_LINE_STATE::NORMAL); 207 207 208 208 std::vector<std::string> tokens_; ///< The tokens after splitting the input line -
code/trunk/src/libraries/util/UtilPrereqs.h
r10624 r11071 37 37 38 38 #include "OrxonoxConfig.h" 39 #include <string> 39 40 40 41 //----------------------------------------------------------------------- … … 80 81 class OutputStream; 81 82 class ScopeListener; 82 template <class T>83 class SharedPtr;84 83 class SignalHandler; 85 84 template <class T> -
code/trunk/src/libraries/util/output/BaseWriter.cc
r8858 r11071 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/trunk/src/libraries/util/output/BaseWriter.h
r8858 r11071 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/trunk/src/libraries/util/output/ConsoleWriter.h
r9550 r11071 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/trunk/src/libraries/util/output/LogWriter.cc
r9550 r11071 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/trunk/src/libraries/util/output/LogWriter.h
r9550 r11071 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/trunk/src/libraries/util/output/MemoryWriter.cc
r9550 r11071 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/trunk/src/libraries/util/output/MemoryWriter.h
r9550 r11071 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/trunk/src/libraries/util/output/OutputDefinitions.h
r10624 r11071 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/trunk/src/libraries/util/output/OutputListener.cc
r9550 r11071 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/trunk/src/libraries/util/output/OutputManager.cc
r9550 r11071 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/trunk/src/libraries/util/output/OutputManager.h
r9550 r11071 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/trunk/src/libraries/util/output/OutputStream.cc
r8858 r11071 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/trunk/src/libraries/util/output/SubcontextOutputListener.cc
r8858 r11071 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/trunk/src/libraries/util/output/SubcontextOutputListener.h
r9550 r11071 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.