Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 4, 2013, 11:23:57 PM (11 years ago)
Author:
landauf
Message:

ConsoleWriter now accepts and writes to any std::ostream, not just std::cout. Makes it easier to test.

Location:
code/branches/testing/src/libraries/util/output
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/util/output/ConsoleWriter.cc

    r9536 r9537  
    3434#include "ConsoleWriter.h"
    3535
    36 #include <iostream>
    3736
    3837#include "OutputManager.h"
     
    4847        After creation, the instance is enabled.
    4948    */
    50     ConsoleWriter::ConsoleWriter() : BaseWriter("Console")
     49    ConsoleWriter::ConsoleWriter(std::ostream& outputStream) : BaseWriter("Console"), outputStream_(outputStream)
    5150    {
    5251#ifdef ORXONOX_RELEASE
     
    7069    void ConsoleWriter::printLine(const std::string& line, OutputLevel)
    7170    {
    72         std::cout << line << std::endl;
     71        this->outputStream_ << line << std::endl;
    7372    }
    7473
  • code/branches/testing/src/libraries/util/output/ConsoleWriter.h

    r9536 r9537  
    3737
    3838#include "util/UtilPrereqs.h"
     39
     40#include <ostream>
     41
    3942#include "BaseWriter.h"
    4043
     
    5053    {
    5154        public:
    52             ConsoleWriter();
     55            ConsoleWriter(std::ostream& outputStream);
    5356            ConsoleWriter(const ConsoleWriter&);
    5457            virtual ~ConsoleWriter();
     
    5760            void disable();
    5861
     62            inline const std::ostream& getOutputStream() const
     63                { return this->outputStream_; }
     64
    5965        protected:
    6066            virtual void printLine(const std::string& line, OutputLevel level);
    6167
    6268        private:
    63             bool bEnabled_; ///< If false, the instance will not write output to the console.
     69            std::ostream& outputStream_; ///< The ostream to which the console writer writes its output
     70            bool bEnabled_;              ///< If false, the instance will not write output to the console.
    6471    };
    6572}
  • code/branches/testing/src/libraries/util/output/OutputManager.cc

    r9536 r9537  
    3333
    3434#include "OutputManager.h"
     35
     36#include <iostream>
    3537
    3638#include "MemoryWriter.h"
     
    111113    ConsoleWriter& OutputManager::getConsoleWriter()
    112114    {
    113         static ConsoleWriter instance;
     115        static ConsoleWriter instance(std::cout);
    114116        return instance;
    115117    }
Note: See TracChangeset for help on using the changeset viewer.