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:
15 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • 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.