Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 10, 2008, 3:35:50 PM (17 years ago)
Author:
landauf
Message:

moved Debug.h, OutputHandler and OutputBuffer to util, to make COUT(x) available everywhere

File:
1 moved

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/util/OutputHandler.cc

    r1574 r1586  
    3333
    3434#include "OutputHandler.h"
    35 #include "Core.h"
    36 #include "ConsoleCommand.h"
    37 #include "Shell.h"
    3835
    3936namespace orxonox
    4037{
    41     SetConsoleCommandShortcutGeneric(log,     createConsoleCommand(createFunctor(&OutputHandler::log),     "log"    ));
    42     SetConsoleCommandShortcutGeneric(error,   createConsoleCommand(createFunctor(&OutputHandler::error),   "error"  ));
    43     SetConsoleCommandShortcutGeneric(warning, createConsoleCommand(createFunctor(&OutputHandler::warning), "warning"));
    44     SetConsoleCommandShortcutGeneric(info,    createConsoleCommand(createFunctor(&OutputHandler::info),    "info"   ));
    45     SetConsoleCommandShortcutGeneric(debug,   createConsoleCommand(createFunctor(&OutputHandler::debug),   "debug"  ));
    46 
    4738    /**
    4839        @brief Constructor: Opens the logfile and writes the first line.
     
    5142    OutputHandler::OutputHandler(const std::string& logfilename)
    5243    {
     44        this->outputBuffer_ = &this->fallbackBuffer_;
     45        this->softDebugLevel_[0] = this->softDebugLevel_[1] = this->softDebugLevel_[2] = this->softDebugLevel_[3] = 2;
    5346        this->logfilename_ = logfilename;
    5447        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
     
    7770
    7871    /**
     72        @brief Sets the soft debug level for a given output device.
     73        @param device The output device
     74        @param level The debug level
     75    */
     76    void OutputHandler::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
     77    {
     78        OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device] = level;
     79    }
     80
     81    /**
    7982        @brief Returns the soft debug level for a given output device.
    8083        @param device The output device
     
    8386    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
    8487    {
    85         return Core::getSoftDebugLevel(device);
     88        return OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device];
    8689    }
    8790
    8891    /**
    89         @brief Returns the Shell's OutputBuffer. This is mere placed here to avoid
    90                recompiling the entire project when Shell.h changes.
    91         @return The OutputBuffer of the Shell
     92        @brief Sets the OutputBuffer, representing the third output stream.
     93        @param buffer The OutputBuffer
    9294    */
    93     OutputBuffer& OutputHandler::getShellOutputBuffer()
     95    void OutputHandler::setOutputBuffer(OutputBuffer& buffer)
    9496    {
    95         return Shell::getInstance().getOutputBuffer();
     97        buffer.getStream() >> this->outputBuffer_->getStream().rdbuf();
     98        this->outputBuffer_ = &buffer;
    9699    }
    97100
     
    113116
    114117        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
    115             Shell::getInstance().getOutputBuffer() << sb;
     118            (*this->outputBuffer_) << sb;
    116119
    117120        return *this;
     
    135138
    136139        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
    137             Shell::getInstance().getOutputBuffer() << manipulator;
     140            (*this->outputBuffer_) << manipulator;
    138141
    139142        return *this;
     
    157160
    158161        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
    159             Shell::getInstance().getOutputBuffer() << manipulator;
     162            (*this->outputBuffer_) << manipulator;
    160163
    161164        return *this;
     
    179182
    180183        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
    181             Shell::getInstance().getOutputBuffer() << manipulator;
     184            (*this->outputBuffer_) << manipulator;
    182185
    183186        return *this;
Note: See TracChangeset for help on using the changeset viewer.