Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 deleted
38 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/util/CMakeLists.txt

    r10624 r11071  
    2626  CRC32.cc
    2727  ExprParser.cc
    28   SharedPtr.cc
    2928  Sleep.cc
    3029  SmallObjectAllocator.cc
  • code/trunk/src/libraries/util/Clipboard.cc

    r8858 r11071  
    9393            {
    9494                HANDLE hData = GetClipboardData(CF_TEXT);
    95                 if (hData == NULL)
     95                if (hData == nullptr)
    9696                    return "";
    9797                std::string output(static_cast<char*>(GlobalLock(hData)));
  • code/trunk/src/libraries/util/Clock.h

    r7401 r11071  
    102102
    103103    private:
    104         /// Undefined
    105         Clock(const Clock& instance);
     104        // non-copyable:
     105        Clock(const Clock&) = delete;
     106        Clock& operator=(const Clock&) = delete;
    106107
    107108        Ogre::Timer*       timer_;       ///< Ogre timer object
  • code/trunk/src/libraries/util/DestructionHelper.h

    r8423 r11071  
    3636    /** Deletes an object and resets the pointer
    3737    @param object
    38         Pointer to an object. Handing over NULL is safe.
     38        Pointer to an object. Handing over nullptr is safe.
    3939    */
    4040    template <class T>
     
    4242    {
    4343        delete *object;
    44         *object = NULL;
     44        *object = nullptr;
    4545    }
    4646
     
    8787
    8888    private:
    89         DestructionHelper(const DestructionHelper&); //!< Don't use (undefined)
     89        // non-copyable:
     90        DestructionHelper(const DestructionHelper&) = delete;
     91        DestructionHelper& operator=(const DestructionHelper&) = delete;
    9092
    9193        T* object_;
  • code/trunk/src/libraries/util/DisplayStringConversions.h

    r6417 r11071  
    5151            {
    5252                Ogre::UTFString::code_point cp;
    53                 for (unsigned int i = 0; i < input.size(); ++i)
     53                for (const char& character : input)
    5454                {
    55                   cp = input[i];
     55                  cp = character;
    5656                  cp &= 0xFF;
    5757                  output->append(1, cp);
  • code/trunk/src/libraries/util/ExprParser.cc

    r8351 r11071  
    391391    }
    392392
    393     char* ExprParser::parse_word(char* str)
     393    void ExprParser::parse_word(char* str)
    394394    {
    395395        char* word = str;
     
    402402            {
    403403                this->failed_ = true;
    404                 return '\0';
     404                return;
    405405            }
    406406        };
    407407        *word = '\0';
    408         return str;
    409408    }
    410409
  • code/trunk/src/libraries/util/ExprParser.h

    r8858 r11071  
    139139        float parse_expr_7();
    140140        float parse_expr_8();
    141         char* parse_word(char* str);
     141        void parse_word(char* str);
    142142        binary_operator parse_binary_operator();
    143143        unary_operator parse_unary_operator();
  • code/trunk/src/libraries/util/ImplicitConversion.h

    r8267 r11071  
    6868    {
    6969    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
    7176        // Gets chosen only if there is an implicit conversion from FromType to ToType.
    7277        static char test(ToType);
  • code/trunk/src/libraries/util/Math.cc

    r11052 r11071  
    371371    }
    372372
     373
     374    namespace detail
     375    {
     376        std::mt19937 rngen;
     377    }
     378
    373379    /**
    374380        @brief Returns a unique number. This function will never return the same value twice.
  • code/trunk/src/libraries/util/Math.h

    r11052 r11071  
    4646#include <cmath>
    4747#include <cstdlib>
     48#include <random>
     49#include <type_traits>
    4850
    4951#include <OgreMath.h>
     
    7375    namespace math
    7476    {
    75         const float twoPi   = 6.283185482025146484375f;     ///< PI * 2
    76         const float pi      = 3.1415927410125732421875f;    ///< PI
    77         const float pi_2    = 1.57079637050628662109375f;   ///< PI / 2
    78         const float pi_4    = 0.785398185253143310546875f;  ///< PI / 4
    79         const float e       = 2.718281269073486328125f;     ///< e
    80         const float sqrt2   = 1.41421353816986083984375f;   ///< sqrt(2)
    81         const float sqrt2_2 = 0.707106769084930419921875f;  ///< sqrt(2) / 2
     77        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
    8284    }
    8385
     
    104106    */
    105107    template <typename T>
    106     inline T sgn(T x)
     108    constexpr inline T sgn(T x)
    107109    {
    108110        return (x >= 0) ? (T)1 : (T)-1;
     
    116118    */
    117119    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);
    127123    }
    128124
     
    131127    */
    132128    template <typename T>
    133     inline T square(T x)
     129    constexpr inline T square(T x)
    134130    {
    135131        return x*x;
     
    140136    */
    141137    template <typename T>
    142     inline T cube(T x)
     138    constexpr inline T cube(T x)
    143139    {
    144140        return x*x*x;
     
    183179        @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>.
    184180    */
    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>());
    192192    }
    193193
     
    206206    template <> inline long double          zeroise<long double>()          { return 0; }
    207207    template <> inline bool                 zeroise<bool>()                 { return 0; }
    208     template <> inline void*                zeroise<void*>()                { return 0; }
     208    template <> inline void*                zeroise<void*>()                { return nullptr; }
    209209    template <> inline std::string          zeroise<std::string>()          { return std::string(); }
    210210    template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
     
    258258    }
    259259
     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
    260287    /**
    261288        @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>.
     
    263290    inline float rnd()
    264291    {
    265         return rand() / (RAND_MAX + 1.0f);
     292        return rnd(0, 1);
    266293    }
    267294
     
    272299    inline float rnd(float max)
    273300    {
    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);
    285302    }
    286303
     
    290307    inline float rndsgn()
    291308    {
    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
    293311    }
    294312
  • code/trunk/src/libraries/util/MultiType.cc

    r9550 r11071  
    4343        @param type The type
    4444    */
    45     bool MultiType::convert(Type::Enum type)
     45    bool MultiType::convert(Type type)
    4646    {
    4747        switch (type)
     
    106106    std::string MultiType::getTypename() const
    107107    {
    108         Type::Enum type = (this->value_) ? this->value_->type_ : Type::Null;
     108        Type type = (this->value_) ? this->value_->type_ : Type::Null;
    109109
    110110        switch (type)
  • code/trunk/src/libraries/util/MultiType.h

    r10197 r11071  
    132132        template <typename T> friend class MT_Value;
    133133
    134         struct Type
     134        /**
     135            @brief Enum of all possible types of a MultiType.
     136        */
     137        enum class Type : uint8_t
    135138        {
    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
    166163        };
    167164
     
    174171        {
    175172        public:
    176             inline MT_ValueBase(void* data, Type::Enum type) : 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() {}
    178175
    179176            virtual MT_ValueBase* clone() const = 0;
     
    182179
    183180            /// 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            }
    187197
    188198            /// Checks whether the value is a default one.
     
    215225            virtual bool setValue(const MultiType& other)            = 0;
    216226
     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
    217241            virtual bool getValue(char*                 value) const = 0;
    218242            virtual bool getValue(unsigned char*        value) const = 0;
     
    239263            virtual bool getValue(orxonox::Degree*      value) const = 0;
    240264
     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
    241279            template <typename T> T get() const
    242280            {
     
    257295            virtual uint8_t getSize() const = 0;
    258296
    259             Type::Enum type_;               ///< The type of the current value
     297            Type type_;                     ///< The type of the current value
    260298            bool bLastConversionSuccessful; ///< True if the last conversion was successful
    261299            void* data_;                    ///< For direct access to the value if the type is known
     
    266304
    267305            /// 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) { }
    269307            /// Constructor: Assigns the given value and sets the type.
    270308            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); }
    272310            /// 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); }
    274312
    275313            /// Destructor: Deletes the MT_Value.
     
    325363                if (this->value_)
    326364                    delete this->value_;
    327                 this->value_ = (other.value_) ? other.value_->clone() : 0;
     365                this->value_ = (other.value_) ? other.value_->clone() : nullptr;
    328366            }
    329367
     
    332370
    333371            /// 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; }
    335373            /// Resets the value and changes the internal type to T.
    336374            template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     
    354392            template <typename T> inline bool getValue(T* value) const { if (this->value_) { return this->value_->getValue(value); } return false; }
    355393
    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; }
    359400
    360401
     
    365406            inline void exportData(uint8_t*& mem) const
    366407            {
    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());
    369410                mem += sizeof(uint8_t);
    370411                this->value_->exportData(mem);
     
    373414            inline void importData(uint8_t*& mem)
    374415            {
    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)));
    377418                mem += sizeof(uint8_t);
    378419                this->value_->importData(mem);
     
    414455
    415456            /// Resets the value and changes the internal type to the given type.
    416             inline void setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
     457            inline void setType(Type type) { this->reset(); this->convert(type); this->resetValue(); }
    417458            /// Returns the current type.
    418             inline Type::Enum getType() const { return (this->value_) ? this->value_->type_ : Type::Null; }
     459            inline Type getType() const { return (this->value_) ? this->value_->type_ : Type::Null; }
    419460            /// Converts the current value to the given type.
    420             bool convert(Type::Enum type);
     461            bool convert(Type type);
    421462
    422463            /// Changes the value container.
     
    428469            }
    429470            /// 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            }
    431484
    432485            MT_ValueBase* value_; //!< A pointer to the value container
     
    471524    template <> inline bool MultiType::isType<void>() const { return this->null(); }
    472525    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>()); }
    497526
    498527    template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
  • code/trunk/src/libraries/util/MultiTypeValue.h

    r9550 r11071  
    5555    public:
    5656        /// Constructor: Assigns the value and the type identifier.
    57         MT_Value(const T& value, MultiType::Type::Enum type) : MT_ValueBase(&this->value_, type), value_(value) {}
     57        MT_Value(const T& value, MultiType::Type type) : MT_ValueBase(&this->value_, type), value_(value) {}
    5858
    5959        /// 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_); }
    6161
    6262        /// 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.
    8888
    8989        /**
     
    9191            @param other The other MultiType
    9292        */
    93         inline bool setValue(const MultiType& other)
     93        virtual inline bool setValue(const MultiType& other) override
    9494        {
    9595            if (other.value_)
     
    104104        }
    105105
    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.
    129129
    130130        /// 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_; }
    132132
    133133        /// 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 ); }
    135135        /// 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 ); }
    137137        /// 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_ ); }
    139139
    140140        T value_; ///< The stored value
  • code/trunk/src/libraries/util/Serialise.h

    r8706 r11071  
    672672    {
    673673        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 );
    676676        return tempsize;
    677677    }
     
    679679    template <class T> inline void saveAndIncrease(  const std::set<T>& variable, uint8_t*& mem )
    680680    {
    681         typename std::set<T>::const_iterator it = variable.begin();
    682681        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 );
    685684    }
    686685
  • code/trunk/src/libraries/util/SignalHandler.cc

    r9682 r11071  
    4444namespace orxonox
    4545{
    46     SignalHandler* SignalHandler::singletonPtr_s = NULL;
     46    SignalHandler* SignalHandler::singletonPtr_s = nullptr;
    4747}
    4848
     
    8181    void SignalHandler::dontCatch()
    8282    {
    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 );
    8686      }
    8787
     
    127127      }
    128128      // if the signalhandler has already been destroyed then don't do anything
    129       if( SignalHandler::singletonPtr_s == 0 )
     129      if( SignalHandler::singletonPtr_s == nullptr )
    130130      {
    131131        orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl;
     
    133133      }
    134134
    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 );
    138138      }
    139139
     
    175175        dup2( gdbErr[1], STDERR_FILENO );
    176176
    177         execlp( "sh", "sh", "-c", "gdb", static_cast<void*>(NULL));
     177        execlp( "sh", "sh", "-c", "gdb", static_cast<void*>(nullptr));
    178178      }
    179179
     
    186186        perror("pipe failed!\n");
    187187        kill( gdbPid, SIGTERM );
    188         waitpid( gdbPid, NULL, 0 );
     188        waitpid( gdbPid, nullptr, 0 );
    189189        exit(EXIT_FAILURE);
    190190      }
     
    196196        perror("fork failed!\n");
    197197        kill( gdbPid, SIGTERM );
    198         waitpid( gdbPid, NULL, 0 );
     198        waitpid( gdbPid, nullptr, 0 );
    199199        exit(EXIT_FAILURE);
    200200      }
     
    297297
    298298
    299       waitpid( sigPid, NULL, 0 );
    300       waitpid( gdbPid, NULL, 0 );
     299      waitpid( sigPid, nullptr, 0 );
     300      waitpid( gdbPid, nullptr, 0 );
    301301
    302302      int wsRemoved = 0;
     
    312312        bt.erase(0, 1);
    313313
    314       time_t now = time(NULL);
     314      time_t now = time(nullptr);
    315315
    316316      std::string timeString =
     
    388388    SignalHandler::SignalHandler()
    389389    {
    390         this->prevExceptionFilter_ = NULL;
     390        this->prevExceptionFilter_ = nullptr;
    391391    }
    392392
     
    394394    SignalHandler::~SignalHandler()
    395395    {
    396         if (this->prevExceptionFilter_ != NULL)
     396        if (this->prevExceptionFilter_ != nullptr)
    397397        {
    398398            // Remove the unhandled exception filter function
    399399            SetUnhandledExceptionFilter(this->prevExceptionFilter_);
    400             this->prevExceptionFilter_ = NULL;
     400            this->prevExceptionFilter_ = nullptr;
    401401        }
    402402    }
     
    408408
    409409        // 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)
    413413        {
    414414            // Install the unhandled exception filter function
     
    430430
    431431            // if the signalhandler has already been destroyed then don't do anything
    432             if (SignalHandler::singletonPtr_s == 0)
     432            if (SignalHandler::singletonPtr_s == nullptr)
    433433            {
    434434                orxout(user_error) << "Caught an unhandled exception" << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl;
     
    441441            std::ofstream crashlog(SignalHandler::getInstance().filename_.c_str());
    442442
    443             time_t now = time(NULL);
     443            time_t now = time(nullptr);
    444444
    445445            crashlog << "=======================================================" << endl;
     
    480480    }
    481481
    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.
    483483    /* static */ std::string SignalHandler::getStackTrace(PEXCEPTION_POINTERS pExceptionInfo)
    484484    {
     
    625625#ifdef ORXONOX_COMPILER_GCC
    626626                int status;
    627                 char* demangled = __cxxabiv1::__cxa_demangle(symbol->Name, NULL, NULL, &status);
     627                char* demangled = __cxxabiv1::__cxa_demangle(symbol->Name, nullptr, nullptr, &status);
    628628                if (demangled)
    629629                {
     
    684684        HMODULE hModule;
    685685
    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");
    687687        output += " caused ";
    688688
  • code/trunk/src/libraries/util/SignalHandler.h

    r9550 r11071  
    113113            void doCatch(const std::string& appName, const std::string& filename);
    114114
    115             static std::string getStackTrace(PEXCEPTION_POINTERS pExceptionInfo = NULL);
     115            static std::string getStackTrace(PEXCEPTION_POINTERS pExceptionInfo = nullptr);
    116116            static std::string getExceptionType(PEXCEPTION_POINTERS pExceptionInfo);
    117117
  • code/trunk/src/libraries/util/Singleton.h

    r10624 r11071  
    6666    And don't forget to initialize the static singleton pointer in the source (*.cc) %file:
    6767    @code
    68     TestSingleton* TestSingleton::singletonPtr_s = NULL;
     68    TestSingleton* TestSingleton::singletonPtr_s = nullptr;
    6969    @endcode
    7070
     
    118118        static T& getInstance()
    119119        {
    120             OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());
     120            OrxVerify(T::singletonPtr_s != nullptr, "T=" << typeid(T).name());
    121121            return *T::singletonPtr_s;
    122122        }
     
    125125        static bool exists()
    126126        {
    127             return (T::singletonPtr_s != NULL);
     127            return (T::singletonPtr_s != nullptr);
    128128        }
    129129
     
    132132        Singleton()
    133133        {
    134             OrxVerify(T::singletonPtr_s == NULL, "T=" << typeid(T).name());
     134            OrxVerify(T::singletonPtr_s == nullptr, "T=" << typeid(T).name());
    135135            T::singletonPtr_s = static_cast<T*>(this);
    136136        }
     
    139139        virtual ~Singleton()
    140140        {
    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;
    143143        }
    144144
    145145    private:
    146         Singleton(const Singleton& rhs); //!< Don't use (undefined)
     146        // non-copyable:
     147        Singleton(const Singleton&) = delete;
     148        Singleton& operator=(const Singleton&) = delete;
    147149    };
    148150}
  • code/trunk/src/libraries/util/SmallObjectAllocator.cc

    r7401 r11071  
    4545        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
    4646        this->numChunksPerBlock_ = numObjects;
    47         this->first_ = 0;
     47        this->first_ = nullptr;
    4848    }
    4949
     
    5353    SmallObjectAllocator::~SmallObjectAllocator()
    5454    {
    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;
    5757    }
    5858
     
    9797                setNext(block + i * this->chunkSize_, block + (i + 1) * this->chunkSize_);
    9898
    99             // the next_ pointer of the last chunk must point to NULL
    100             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);
    101101
    102102            // The second chunk in the block is assigned to the first_ pointer
  • code/trunk/src/libraries/util/SmallObjectAllocator.h

    r7401 r11071  
    7777#include "UtilPrereqs.h"
    7878#include <vector>
     79#include <cstdio>
    7980
    8081namespace orxonox
  • code/trunk/src/libraries/util/StringUtils.cc

    r9550 r11071  
    3636#include <cctype>
    3737#include <ctime>
    38 #include <boost/scoped_array.hpp>
    3938#include "Convert.h"
    4039#include "Math.h"
     
    263262        std::string output(str.size() * 2, ' ');
    264263        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)
    268267            {
    269268            case '\\': output[i] = '\\'; output[i + 1] = '\\'; break;
     
    277276            case  '"': output[i] = '\\'; output[i + 1] =  '"'; break;
    278277            case '\0': output[i] = '\\'; output[i + 1] =  '0'; break;
    279             default  : output[i] = str[pos]; ++i; continue;
     278            default  : output[i] = character; ++i; continue;
    280279            }
    281280            i += 2;
     
    337336    void lowercase(std::string* str)
    338337    {
    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));
    342341        }
    343342    }
     
    354353    void uppercase(std::string* str)
    355354    {
    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));
    359358        }
    360359    }
     
    461460    {
    462461        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)
    466465            {
    467                 str[i] = replacement;
     466                character = replacement;
    468467                ++j;
    469468            }
     
    482481        size_t cols = str1.size() + 1;
    483482        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]);
    485484
    486485        for (size_t r = 0; r < rows; ++r)
  • code/trunk/src/libraries/util/SubString.cc

    r9550 r11071  
    112112        for (size_t i = 0; i < argc; ++i)
    113113        {
    114             this->tokens_.push_back(std::string(argv[i]));
     114            this->tokens_.emplace_back(argv[i]);
    115115            this->bTokenInSafemode_.push_back(false);
    116116        }
     
    265265        bool inSafemode = false;
    266266
    267         if(start_state != SL_NORMAL && tokens.size() > 0)
     267        if(start_state != SPLIT_LINE_STATE::NORMAL && tokens.size() > 0)
    268268        {
    269269            token = tokens[tokens.size()-1];
    270270            tokens.pop_back();
    271271        }
    272         if(start_state != SL_NORMAL && bTokenInSafemode.size() > 0)
     272        if(start_state != SPLIT_LINE_STATE::NORMAL && bTokenInSafemode.size() > 0)
    273273        {
    274274            inSafemode = bTokenInSafemode[bTokenInSafemode.size()-1];
     
    280280            switch(state)
    281281            {
    282             case SL_NORMAL:
     282            case SPLIT_LINE_STATE::NORMAL:
    283283                if(line[i] == escapeChar)
    284284                {
    285                     state = SL_ESCAPE;
     285                    state = SPLIT_LINE_STATE::ESCAPE;
    286286                    if (!bRemoveEscapeChar)
    287287                        token += line[i];
     
    290290                else if(line[i] == safemodeChar)
    291291                {
    292                     state = SL_SAFEMODE;
     292                    state = SPLIT_LINE_STATE::SAFEMODE;
    293293                    inSafemode = true;
    294294                    if (!bRemoveSafemodeChar)
     
    298298                else if(line[i] == openparenthesisChar)
    299299                {
    300                     state = SL_PARENTHESES;
     300                    state = SPLIT_LINE_STATE::PARENTHESES;
    301301                    inSafemode = true;
    302302                    if (!bRemoveParenthesisChars)
     
    318318                    }
    319319                    token += line[i];       // EAT
    320                     state = SL_COMMENT;
     320                    state = SPLIT_LINE_STATE::COMMENT;
    321321                }
    322322                else if(delimiters.find(line[i]) != std::string::npos)
     
    334334                        inSafemode = false;
    335335                    }
    336                     state = SL_NORMAL;
     336                    state = SPLIT_LINE_STATE::NORMAL;
    337337                }
    338338                else
     
    353353                }
    354354                break;
    355             case SL_ESCAPE:
     355            case SPLIT_LINE_STATE::ESCAPE:
    356356                if (!bRemoveSafemodeChar)
    357357                    token += line[i];
     
    368368                    else token += line[i];  // EAT
    369369                }
    370                 state = SL_NORMAL;
    371                 break;
    372             case SL_SAFEMODE:
     370                state = SPLIT_LINE_STATE::NORMAL;
     371                break;
     372            case SPLIT_LINE_STATE::SAFEMODE:
    373373                if(line[i] == safemodeChar)
    374374                {
    375                     state = SL_NORMAL;
     375                    state = SPLIT_LINE_STATE::NORMAL;
    376376                    if (!bRemoveSafemodeChar)
    377377                        token += line[i];
     
    379379                else if(line[i] == escapeChar)
    380380                {
    381                     state = SL_SAFEESCAPE;
     381                    state = SPLIT_LINE_STATE::SAFEESCAPE;
    382382                }
    383383                else
     
    387387                break;
    388388
    389             case SL_SAFEESCAPE:
     389            case SPLIT_LINE_STATE::SAFEESCAPE:
    390390                if(line[i] == 'n') token += '\n';
    391391                else if(line[i] == 't') token += '\t';
     
    397397                else if(line[i] == '?') token += '\?';
    398398                else token += line[i];  // EAT
    399                 state = SL_SAFEMODE;
    400                 break;
    401 
    402             case SL_PARENTHESES:
     399                state = SPLIT_LINE_STATE::SAFEMODE;
     400                break;
     401
     402            case SPLIT_LINE_STATE::PARENTHESES:
    403403                if(line[i] == closeparenthesisChar)
    404404                {
    405                     state = SL_NORMAL;
     405                    state = SPLIT_LINE_STATE::NORMAL;
    406406                    if (!bRemoveParenthesisChars)
    407407                        token += line[i];
     
    409409                else if(line[i] == escapeChar)
    410410                {
    411                     state = SL_PARENTHESESESCAPE;
     411                    state = SPLIT_LINE_STATE::PARENTHESESESCAPE;
    412412                }
    413413                else
     
    417417                break;
    418418
    419             case SL_PARENTHESESESCAPE:
     419            case SPLIT_LINE_STATE::PARENTHESESESCAPE:
    420420                if(line[i] == 'n') token += '\n';
    421421                else if(line[i] == 't') token += '\t';
     
    427427                else if(line[i] == '?') token += '\?';
    428428                else token += line[i];  // EAT
    429                 state = SL_PARENTHESES;
    430                 break;
    431 
    432             case SL_COMMENT:
     429                state = SPLIT_LINE_STATE::PARENTHESES;
     430                break;
     431
     432            case SPLIT_LINE_STATE::COMMENT:
    433433                if(line[i] == '\n')
    434434                {
     
    441441                        inSafemode = false;
    442442                    }
    443                     state = SL_NORMAL;
     443                    state = SPLIT_LINE_STATE::NORMAL;
    444444                }
    445445                else
  • code/trunk/src/libraries/util/SubString.h

    r9550 r11071  
    102102    {
    103103        /// An enumerator for the internal state of the parser
    104         enum SPLIT_LINE_STATE
     104        enum class SPLIT_LINE_STATE
    105105        {
    106             SL_NORMAL,            //!< Normal state
    107             SL_ESCAPE,            //!< After an escape character
    108             SL_SAFEMODE,          //!< In safe mode (usually between quotation marks).
    109             SL_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.
    113113        };
    114114
     
    204204                                          bool bRemoveParenthesisChars = true,
    205205                                          char commentChar = '\0',
    206                                           SPLIT_LINE_STATE start_state = SL_NORMAL);
     206                                          SPLIT_LINE_STATE start_state = SPLIT_LINE_STATE::NORMAL);
    207207
    208208        std::vector<std::string>  tokens_;              ///< The tokens after splitting the input line
  • code/trunk/src/libraries/util/UtilPrereqs.h

    r10624 r11071  
    3737
    3838#include "OrxonoxConfig.h"
     39#include <string>
    3940
    4041//-----------------------------------------------------------------------
     
    8081    class OutputStream;
    8182    class ScopeListener;
    82     template <class T>
    83     class SharedPtr;
    8483    class SignalHandler;
    8584    template <class T>
  • code/trunk/src/libraries/util/output/BaseWriter.cc

    r8858 r11071  
    4747        this->configurableMaxLevel_ = level::none;
    4848        this->configurableAdditionalContextsMaxLevel_ = level::verbose;
    49         this->configurableAdditionalContexts_.push_back("example");
     49        this->configurableAdditionalContexts_.emplace_back("example");
    5050
    5151        this->changedConfigurableLevel();
     
    116116
    117117        // 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_)
    119119        {
    120             const std::string& full_name = this->configurableAdditionalContexts_[i];
    121 
    122120            // split the name into main-name and sub-name (if given; otherwise sub-name remains empty). both names are separated by ::
    123121            std::string name = full_name;
  • code/trunk/src/libraries/util/output/BaseWriter.h

    r8858 r11071  
    103103
    104104        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;
    106106
    107107        private:
  • code/trunk/src/libraries/util/output/ConsoleWriter.h

    r9550 r11071  
    5353        public:
    5454            ConsoleWriter(std::ostream& outputStream);
    55             ConsoleWriter(const ConsoleWriter&);
    5655            virtual ~ConsoleWriter();
    5756
     
    6362
    6463        protected:
    65             virtual void printLine(const std::string& line, OutputLevel level);
     64            virtual void printLine(const std::string& line, OutputLevel level) override;
    6665
    6766        private:
     67            // non-copyable:
     68            ConsoleWriter(const ConsoleWriter&) = delete;
     69            ConsoleWriter& operator=(const ConsoleWriter&) = delete;
     70
    6871            std::ostream& outputStream_; ///< The ostream to which the console writer writes its output
    6972            bool bEnabled_;              ///< If false, the instance will not write output to the console.
  • code/trunk/src/libraries/util/output/LogWriter.cc

    r9550 r11071  
    3535
    3636#include <ctime>
     37#include <chrono>
    3738#include <cstdlib>
    3839
     
    4344namespace orxonox
    4445{
    45     static const int MAX_ARCHIVED_FILES = 9;
     46    static constexpr int MAX_ARCHIVED_FILES = 9;
    4647
    4748    /**
     
    180181            return;
    181182
     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
    182189        // 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);
    187196
    188197        // 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;
    192199    }
    193200}
  • code/trunk/src/libraries/util/output/LogWriter.h

    r9550 r11071  
    5757        public:
    5858            LogWriter();
    59             LogWriter(const LogWriter&);
    6059            virtual ~LogWriter();
    6160
     
    7069
    7170        protected:
    72             virtual void printLine(const std::string& line, OutputLevel level);
     71            virtual void printLine(const std::string& line, OutputLevel level) override;
    7372
    7473        private:
     74            // non-copyable:
     75            LogWriter(const LogWriter&) = delete;
     76            LogWriter& operator=(const LogWriter&) = delete;
     77
    7578            void openFile();
    7679            void closeFile();
  • code/trunk/src/libraries/util/output/MemoryWriter.cc

    r9550 r11071  
    5757    void MemoryWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
    5858    {
    59         this->messages_.push_back(Message(level, context, lines));
     59        this->messages_.emplace_back(level, context, lines);
    6060    }
    6161
     
    6565    void MemoryWriter::resendOutput(OutputListener* listener) const
    6666    {
    67         for (size_t i = 0; i < this->messages_.size(); ++i)
     67        for (const Message& message : this->messages_)
    6868        {
    69             const Message& message = this->messages_[i];
    7069            listener->unfilteredOutput(message.level, *message.context, message.lines);
    7170        }
  • code/trunk/src/libraries/util/output/MemoryWriter.h

    r9550 r11071  
    6868        public:
    6969            MemoryWriter();
    70             MemoryWriter(const MemoryWriter&);
    7170            virtual ~MemoryWriter();
    7271
     
    7574
    7675        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;
    7877
    7978        private:
     79            // non-copyable:
     80            MemoryWriter(const MemoryWriter&) = delete;
     81            MemoryWriter& operator=(const MemoryWriter&) = delete;
     82
    8083            std::vector<Message> messages_; ///< Stores all output messages from the creation of this instance until disable() is called.
    8184    };
  • code/trunk/src/libraries/util/output/OutputDefinitions.h

    r10624 r11071  
    132132    namespace context
    133133    {
    134         static const OutputContextMask all       = 0xFFFFFFFFFFFFFFFFull; ///< Context mask, all bits set to 1
    135         static const OutputContextMask none      = 0x0000000000000000ull; ///< Context mask, all bits set to 0
     134        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
    136136
    137         static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
     137        static constexpr OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
    138138
    139139        namespace
  • code/trunk/src/libraries/util/output/OutputListener.cc

    r9550 r11071  
    111111        this->levelMask_ = mask;
    112112
    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);
    115115    }
    116116
     
    142142        this->additionalContextsLevelMask_ = mask;
    143143
    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);
    146146    }
    147147
     
    153153        this->additionalContextsMask_ = mask;
    154154
    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);
    157157    }
    158158
  • code/trunk/src/libraries/util/output/OutputManager.cc

    r9550 r11071  
    4141#include "util/Output.h"
    4242#include "util/StringUtils.h"
    43 #include "util/SharedPtr.h"
    4443
    4544namespace orxonox
     
    5756
    5857        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;
    6261
    6362        // register 'undefined' context in order to give it always the first context-ID
     
    8180    }
    8281
    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());
    8685        return instance;
    8786    }
     
    132131        vectorize(message, '\n', &lines);
    133132
    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);
    136135    }
    137136
     
    179178    {
    180179        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();
    183182        this->combinedLevelMask_ = static_cast<OutputLevel>(mask);
    184183    }
     
    190189    {
    191190        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();
    194193        this->combinedAdditionalContextsLevelMask_ = static_cast<OutputLevel>(mask);
    195194    }
     
    201200    {
    202201        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();
    205204    }
    206205
  • code/trunk/src/libraries/util/output/OutputManager.h

    r9550 r11071  
    4141#include <vector>
    4242#include <map>
     43#include <memory>
    4344
    4445#include "OutputDefinitions.h"
     
    6667        public:
    6768            OutputManager();
    68             OutputManager(const OutputManager&);
    6969            virtual ~OutputManager();
    7070
     
    8181            virtual void unregisterListener(OutputListener* listener);
    8282
    83             virtual void updatedLevelMask(const OutputListener* listener)
     83            virtual void updatedLevelMask(const OutputListener* listener) override
    8484                { this->updateCombinedLevelMask(); }
    85             virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener)
     85            virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) override
    8686                { this->updateCombinedAdditionalContextsLevelMask(); }
    87             virtual void updatedAdditionalContextsMask(const OutputListener* listener)
     87            virtual void updatedAdditionalContextsMask(const OutputListener* listener) override
    8888                { this->updateCombinedAdditionalContextsMask(); }
    8989
     
    114114
    115115        private:
     116            // non-copyable:
     117            OutputManager(const OutputManager&) = delete;
     118            OutputManager& operator=(const OutputManager&) = delete;
     119
    116120            void updateMasks();
    117121            void updateCombinedLevelMask();
     
    137141            struct _UtilExport Testing
    138142            {
    139                 static SharedPtr<OutputManager>& getInstancePointer();
     143                static std::shared_ptr<OutputManager>& getInstancePointer();
    140144            };
    141145    };
  • code/trunk/src/libraries/util/output/OutputStream.cc

    r8858 r11071  
    4141        @brief Default constructor, initializes level and context with default values.
    4242    */
    43     OutputStream::OutputStream()
     43    OutputStream::OutputStream() : OutputStream(level::debug_output, context::undefined())
    4444    {
    45         this->setOutputAttributes(level::debug_output, context::undefined());
    4645    }
    4746
  • code/trunk/src/libraries/util/output/SubcontextOutputListener.cc

    r8858 r11071  
    7979
    8080        // 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)
    8282        {
    83             this->subcontextsCheckMask_ |= (*it)->mask;
    84             this->subcontexts_.insert((*it)->sub_id);
     83            this->subcontextsCheckMask_ |= subcontext->mask;
     84            this->subcontexts_.insert(subcontext->sub_id);
    8585        }
    8686
  • code/trunk/src/libraries/util/output/SubcontextOutputListener.h

    r9550 r11071  
    7373            virtual ~SubcontextOutputListener();
    7474
    75             virtual void setAdditionalContextsMask(OutputContextMask mask);
     75            virtual void setAdditionalContextsMask(OutputContextMask mask) override;
    7676            void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts);
    7777
    78             virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
     78            virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const override;
    7979
    8080            inline const std::set<OutputContextSubID>& getSubcontexts() const
Note: See TracChangeset for help on using the changeset viewer.