Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8794


Ignore:
Timestamp:
Jul 28, 2011, 10:35:41 PM (13 years ago)
Author:
landauf
Message:

added BaseWriter, a common base class of ConsoleWriter, LogWriter, and also the Shell in future

Location:
code/branches/output/src/libraries/util
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/util/CMakeLists.txt

    r8787 r8794  
    4242  output/OutputManager.cc
    4343  output/OutputListener.cc
     44  output/BaseWriter.cc
    4445  output/ConsoleWriter.cc
    4546  output/LogWriter.cc
  • code/branches/output/src/libraries/util/output/ConsoleWriter.cc

    r8789 r8794  
    5151    }
    5252
    53     void ConsoleWriter::output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines)
     53    void ConsoleWriter::printLine(const std::string& line)
    5454    {
    55         const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
    56         std::string blanks(prefix.length(), ' ');
    57 
    58         for (size_t i = 0; i < lines.size(); ++i)
    59             std::cout << (i == 0 ? prefix : blanks) << lines[i] << std::endl;
     55        std::cout << line << std::endl;
    6056    }
    6157
  • code/branches/output/src/libraries/util/output/ConsoleWriter.h

    r8787 r8794  
    3131
    3232#include "util/UtilPrereqs.h"
    33 #include "OutputListener.h"
     33#include "BaseWriter.h"
    3434
    3535namespace orxonox
    3636{
    37     class _UtilExport ConsoleWriter : public OutputListener
     37    class _UtilExport ConsoleWriter : public BaseWriter
    3838    {
    3939        public:
     
    4444
    4545        protected:
    46             virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines);
     46            virtual void printLine(const std::string& line);
    4747
    4848        private:
    4949            ConsoleWriter();
    5050            ConsoleWriter(const ConsoleWriter&);
    51             ~ConsoleWriter();
     51            virtual ~ConsoleWriter();
    5252
    5353            bool bEnabled_;
  • code/branches/output/src/libraries/util/output/LogWriter.cc

    r8787 r8794  
    6464    }
    6565
    66     void LogWriter::output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines)
    67     {
    68         if (!this->file_.is_open())
    69             return;
    70 
    71         const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
    72         std::string blanks(prefix.length(), ' ');
    73 
    74         for (size_t i = 0; i < lines.size(); ++i)
    75             this->printLine((i == 0 ? prefix : blanks) + lines[i]);
    76     }
    77 
    7866    void LogWriter::openFile()
    7967    {
     
    114102    void LogWriter::printLine(const std::string& line)
    115103    {
     104        if (!this->file_.is_open())
     105            return;
     106
    116107        // Get current time
    117108        time_t rawtime;
  • code/branches/output/src/libraries/util/output/LogWriter.h

    r8787 r8794  
    3434#include <fstream>
    3535
    36 #include "OutputListener.h"
     36#include "BaseWriter.h"
    3737
    3838namespace orxonox
    3939{
    40     class _UtilExport LogWriter : public OutputListener
     40    class _UtilExport LogWriter : public BaseWriter
    4141    {
    4242        public:
     
    4646
    4747        protected:
    48             virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines);
     48            virtual void printLine(const std::string& line);
    4949
    5050        private:
    5151            LogWriter();
    5252            LogWriter(const LogWriter&);
    53             ~LogWriter();
     53            virtual ~LogWriter();
    5454
    5555            void openFile();
    5656            void closeFile();
    57 
    58             void printLine(const std::string& line);
    5957
    6058            std::string filename_;
  • code/branches/output/src/libraries/util/output/MemoryWriter.h

    r8787 r8794  
    5959            MemoryWriter();
    6060            MemoryWriter(const MemoryWriter&);
    61             ~MemoryWriter();
     61            virtual ~MemoryWriter();
    6262
    6363            std::vector<Message> messages_;
  • code/branches/output/src/libraries/util/output/OutputListener.h

    r8787 r8794  
    4242        public:
    4343            OutputListener();
    44             ~OutputListener();
     44            virtual ~OutputListener();
    4545
    4646            void setLevelMax(OutputLevel max);
Note: See TracChangeset for help on using the changeset viewer.