Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 10, 2008, 3:35:50 PM (16 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.h

    r1574 r1586  
    3838#define _OutputHandler_H__
    3939
    40 #include "CorePrereqs.h"
     40#include "UtilPrereqs.h"
    4141
    4242#include <iostream>
     
    4949{
    5050    //! The OutputHandler acts like std::cout, but redirects output to the console AND the logfile.
    51     class _CoreExport OutputHandler
     51    class _UtilExport OutputHandler
    5252    {
    5353        public:
    5454            enum OutputDevice
    5555            {
    56                 LD_All,
    57                 LD_Console,
    58                 LD_Logfile,
    59                 LD_Shell
     56                LD_All = 0,
     57                LD_Console = 1,
     58                LD_Logfile = 2,
     59                LD_Shell = 3
    6060            };
    6161
     
    8686                { return this->logfile_; }
    8787
     88            /** @brief Returns a pointer to the OutputBuffer. @return The OutputBuffer */
     89            inline OutputBuffer* getOutputBuffer()
     90                { return this->outputBuffer_; }
     91
    8892            /** @brief Sets the level of the incoming output. @param level The level of the incoming output @return The OutputHandler itself */
    8993            inline OutputHandler& setOutputLevel(int level)
     
    9498                { return this->outputLevel_; }
    9599
    96             static int getSoftDebugLevel(OutputHandler::OutputDevice device);
    97 
    98             OutputBuffer& getShellOutputBuffer();
     100            static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
     101            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
     102
     103            void setOutputBuffer(OutputBuffer& buffer);
    99104
    100105            template <class T>
     
    136141            OutputHandler(const OutputHandler& oh);  // don't copy
    137142            virtual ~OutputHandler();
    138             std::ofstream logfile_;     //!< The logfile where the output is logged
    139             std::string logfilename_;   //!< The name of the logfile
    140             int outputLevel_;           //!< The level of the incoming output
     143
     144            std::ofstream logfile_;              //!< The logfile where the output is logged
     145            std::string logfilename_;            //!< The name of the logfile
     146            OutputBuffer fallbackBuffer_;        //!< The OutputBuffer that gets used if there is no other OutputBuffer
     147            OutputBuffer* outputBuffer_;         //!< The OutputBuffer to put output in (usually used by the Shell)
     148            int outputLevel_;                    //!< The level of the incoming output
     149            int softDebugLevel_[4];              //!< The soft debug level for each OutputDevice - the configurable maximal output level
    141150    };
    142151
     
    159168
    160169        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
    161             OutputHandler::getOutStream().getShellOutputBuffer() << output;
     170            (*this->outputBuffer_) << output;
    162171
    163172        return *this;
     
    183192
    184193        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= out.getOutputLevel())
    185             OutputHandler::getOutStream().getShellOutputBuffer() << output;
     194            (*out.getOutputBuffer()) << output;
    186195
    187196        return out;
    188197    }
    189 
    190198}
    191199
Note: See TracChangeset for help on using the changeset viewer.