Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 10, 2016, 1:54:11 PM (10 years ago)
Author:
landauf
Message:

merged branch cpp11_v2 into cpp11_v3

Location:
code/branches/cpp11_v3
Files:
2 deleted
36 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/libraries/util/CMakeLists.txt

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

    r8858 r11054  
    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/branches/cpp11_v3/src/libraries/util/Clock.h

    r7401 r11054  
    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/branches/cpp11_v3/src/libraries/util/DestructionHelper.h

    r8423 r11054  
    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/branches/cpp11_v3/src/libraries/util/DisplayStringConversions.h

    r6417 r11054  
    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/branches/cpp11_v3/src/libraries/util/ExprParser.cc

    r8351 r11054  
    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/branches/cpp11_v3/src/libraries/util/ExprParser.h

    r8858 r11054  
    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/branches/cpp11_v3/src/libraries/util/ImplicitConversion.h

    r8267 r11054  
    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/branches/cpp11_v3/src/libraries/util/Math.cc

    r11052 r11054  
    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/branches/cpp11_v3/src/libraries/util/Math.h

    r11052 r11054  
    4646#include <cmath>
    4747#include <cstdlib>
     48#include <random>
    4849
    4950#include <OgreMath.h>
     
    7374    namespace math
    7475    {
    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
     76        constexpr float twoPi   = 6.283185482025146484375f;     ///< PI * 2
     77        constexpr float pi      = 3.1415927410125732421875f;    ///< PI
     78        constexpr float pi_2    = 1.57079637050628662109375f;   ///< PI / 2
     79        constexpr float pi_4    = 0.785398185253143310546875f;  ///< PI / 4
     80        constexpr float e       = 2.718281269073486328125f;     ///< e
     81        constexpr float sqrt2   = 1.41421353816986083984375f;   ///< sqrt(2)
     82        constexpr float sqrt2_2 = 0.707106769084930419921875f;  ///< sqrt(2) / 2
    8283    }
    8384
     
    104105    */
    105106    template <typename T>
    106     inline T sgn(T x)
     107    constexpr inline T sgn(T x)
    107108    {
    108109        return (x >= 0) ? (T)1 : (T)-1;
     
    116117    */
    117118    template <typename T>
    118     inline T clamp(T x, T min, T max)
    119     {
    120         if (x < min)
    121             return min;
    122 
    123         if (x > max)
    124             return max;
    125 
    126         return x;
     119    constexpr inline T clamp(T x, T min, T max)
     120    {
     121        return x < min ? min : (x > max ? max : x);
    127122    }
    128123
     
    131126    */
    132127    template <typename T>
    133     inline T square(T x)
     128    constexpr inline T square(T x)
    134129    {
    135130        return x*x;
     
    140135    */
    141136    template <typename T>
    142     inline T cube(T x)
     137    constexpr inline T cube(T x)
    143138    {
    144139        return x*x*x;
     
    186181    inline T zeroise()
    187182    {
    188         // Default, raise a compiler error without including large boost header cascade.
    189         T temp();
    190         *********temp; // If you reach this code, you abused zeroise()!
    191         return temp;
     183        // If you reach this code, you abused zeroise()!
     184        static_assert(sizeof(T) != sizeof(T), "No template specialization available for T");
    192185    }
    193186
     
    206199    template <> inline long double          zeroise<long double>()          { return 0; }
    207200    template <> inline bool                 zeroise<bool>()                 { return 0; }
    208     template <> inline void*                zeroise<void*>()                { return 0; }
     201    template <> inline void*                zeroise<void*>()                { return nullptr; }
    209202    template <> inline std::string          zeroise<std::string>()          { return std::string(); }
    210203    template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
     
    258251    }
    259252
     253    namespace detail
     254    {
     255        /**
     256        Random number generator used for the functions below. Marked extern to only have one global instance.
     257        */
     258        _UtilExport extern std::mt19937 rngen;
     259    }
     260
     261    /**
     262    @brief Seeds the random number generator used for the functions below.
     263    */
     264    inline void rndseed(unsigned int seed)
     265    {
     266        detail::rngen.seed(seed);
     267    }
     268
     269    /**
     270    @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>.
     271    @param min The minimum
     272    @param max The maximum
     273    */
     274    inline float rnd(float min, float max)
     275    {
     276        std::uniform_real_distribution<float> dist(min, max);
     277        return dist(detail::rngen);
     278    }
     279
    260280    /**
    261281        @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>.
     
    263283    inline float rnd()
    264284    {
    265         return rand() / (RAND_MAX + 1.0f);
     285        return rnd(0, 1);
    266286    }
    267287
     
    272292    inline float rnd(float max)
    273293    {
    274         return rnd() * max;
    275     }
    276 
    277     /**
    278         @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>.
    279         @param min The minimum
    280         @param max The maximum
    281     */
    282     inline float rnd(float min, float max)
    283     {
    284         return rnd(max - min) + min;
     294        return rnd(0, max);
    285295    }
    286296
     
    290300    inline float rndsgn()
    291301    {
    292         return static_cast<float>((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0
     302        std::uniform_int_distribution<> dist;
     303        return static_cast<float>((dist(detail::rngen) & 0x2) - 1); // dist(...) & 0x2 is either 2 or 0
    293304    }
    294305
  • code/branches/cpp11_v3/src/libraries/util/MultiType.h

    r10197 r11054  
    175175        public:
    176176            inline MT_ValueBase(void* data, Type::Enum type) : type_(type), bLastConversionSuccessful(true), data_(data) {}
    177             inline virtual ~MT_ValueBase() {}
     177            virtual inline ~MT_ValueBase() {}
    178178
    179179            virtual MT_ValueBase* clone() const = 0;
     
    266266
    267267            /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
    268             inline MultiType()                       : value_(0) { }
     268            inline MultiType()                       : value_(nullptr) { }
    269269            /// Constructor: Assigns the given value and sets the type.
    270270            template <typename V>
    271             inline MultiType(const V& value)         : value_(0) { this->set(value); }
     271            inline MultiType(const V& value)         : value_(nullptr) { this->set(value); }
    272272            /// Copyconstructor: Assigns value and type of the other MultiType.
    273             inline MultiType(const MultiType& other) : value_(0) { this->set(other); }
     273            inline MultiType(const MultiType& other) : value_(nullptr) { this->set(other); }
    274274
    275275            /// Destructor: Deletes the MT_Value.
     
    325325                if (this->value_)
    326326                    delete this->value_;
    327                 this->value_ = (other.value_) ? other.value_->clone() : 0;
     327                this->value_ = (other.value_) ? other.value_->clone() : nullptr;
    328328            }
    329329
     
    332332
    333333            /// Resets value and type. Type will be void afterwards and null() returns true.
    334             inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
     334            inline void reset() { if (this->value_) delete this->value_; this->value_ = nullptr; }
    335335            /// Resets the value and changes the internal type to T.
    336336            template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     
    428428            }
    429429            /// Creates a new value container (works only with specialized types).
    430             template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
     430            template <typename T> inline void createNewValueContainer(const T& value)
     431            {
     432                // If you reach this code, you used MultiType with an unsupported type T
     433                static_assert(sizeof(T) != sizeof(T), "No template specialization available for T");
     434            }
    431435
    432436            MT_ValueBase* value_; //!< A pointer to the value container
     
    486490    template <> inline long double          MultiType::get() const { return (this->value_ ? this->value_->get<long double>()          : 0); }
    487491    template <> inline bool                 MultiType::get() const { return (this->value_ ? this->value_->get<bool>()                 : 0); }
    488     template <> inline void*                MultiType::get() const { return (this->value_ ? this->value_->get<void*>()                : 0); }
     492    template <> inline void*                MultiType::get() const { return (this->value_ ? this->value_->get<void*>()                : nullptr); }
    489493    template <> inline std::string          MultiType::get() const { return (this->value_ ? this->value_->get<std::string>()          : NilValue<std::string>()); }
    490494    template <> inline orxonox::Vector2     MultiType::get() const { return (this->value_ ? this->value_->get<orxonox::Vector2>()     : NilValue<orxonox::Vector2>()); }
  • code/branches/cpp11_v3/src/libraries/util/MultiTypeValue.h

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/Serialise.h

    r8706 r11054  
    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/branches/cpp11_v3/src/libraries/util/SignalHandler.cc

    r9682 r11054  
    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/branches/cpp11_v3/src/libraries/util/SignalHandler.h

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/Singleton.h

    r10624 r11054  
    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/branches/cpp11_v3/src/libraries/util/SmallObjectAllocator.cc

    r7401 r11054  
    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/branches/cpp11_v3/src/libraries/util/SmallObjectAllocator.h

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

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/SubString.cc

    r9550 r11054  
    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        }
  • code/branches/cpp11_v3/src/libraries/util/UtilPrereqs.h

    r10624 r11054  
    8080    class OutputStream;
    8181    class ScopeListener;
    82     template <class T>
    83     class SharedPtr;
    8482    class SignalHandler;
    8583    template <class T>
  • code/branches/cpp11_v3/src/libraries/util/output/BaseWriter.cc

    r8858 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/BaseWriter.h

    r8858 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/ConsoleWriter.h

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/LogWriter.cc

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/LogWriter.h

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/MemoryWriter.cc

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/MemoryWriter.h

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/OutputDefinitions.h

    r10624 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/OutputListener.cc

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/OutputManager.cc

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/OutputManager.h

    r9550 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/OutputStream.cc

    r8858 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/SubcontextOutputListener.cc

    r8858 r11054  
    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/branches/cpp11_v3/src/libraries/util/output/SubcontextOutputListener.h

    r9550 r11054  
    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.