[Orxonox-commit 4116] r8787 - in code/branches/output/src/libraries/util: . output

landauf at orxonox.net landauf at orxonox.net
Mon Jul 25 23:53:17 CEST 2011


Author: landauf
Date: 2011-07-25 23:53:17 +0200 (Mon, 25 Jul 2011)
New Revision: 8787

Removed:
   code/branches/output/src/libraries/util/Debug.h
   code/branches/output/src/libraries/util/OutputHandler.cc
   code/branches/output/src/libraries/util/OutputHandler.h
Modified:
   code/branches/output/src/libraries/util/CMakeLists.txt
   code/branches/output/src/libraries/util/Output.h
   code/branches/output/src/libraries/util/UtilPrereqs.h
   code/branches/output/src/libraries/util/output/ConsoleWriter.cc
   code/branches/output/src/libraries/util/output/ConsoleWriter.h
   code/branches/output/src/libraries/util/output/LogWriter.cc
   code/branches/output/src/libraries/util/output/LogWriter.h
   code/branches/output/src/libraries/util/output/MemoryWriter.cc
   code/branches/output/src/libraries/util/output/MemoryWriter.h
   code/branches/output/src/libraries/util/output/OutputDefinitions.h
   code/branches/output/src/libraries/util/output/OutputListener.cc
   code/branches/output/src/libraries/util/output/OutputListener.h
   code/branches/output/src/libraries/util/output/OutputManager.cc
   code/branches/output/src/libraries/util/output/OutputManager.h
   code/branches/output/src/libraries/util/output/OutputStream.cc
   code/branches/output/src/libraries/util/output/OutputStream.h
Log:
removed Debug.h and OutputHandler. removed test namespace from new output system.
doesn't compile.

Modified: code/branches/output/src/libraries/util/CMakeLists.txt
===================================================================
--- code/branches/output/src/libraries/util/CMakeLists.txt	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/CMakeLists.txt	2011-07-25 21:53:17 UTC (rev 8787)
@@ -25,7 +25,6 @@
   Convert.cc
   CRC32.cc
   ExprParser.cc
-  OutputHandler.cc
   Scope.cc
   ScopedSingletonManager.cc
   SharedPtr.cc

Deleted: code/branches/output/src/libraries/util/Debug.h
===================================================================
--- code/branches/output/src/libraries/util/Debug.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/Debug.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -1,131 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @defgroup COUT COUT(x) output macro
-    @ingroup Util
-*/
-
-/**
- at file
- at ingroup COUT
- at brief
-    Handles different output-levels of errors, warnings, infos, and debug information.
-
-    The COUT(level) macro acts like @c std::cout, but the output is only performed if the given
-    level is <= the soft debug level.
-
-    There are two used values in this file:
-     - The hard debug level is used during compile time. It describes the highest allowed output level.
-     - The soft debug level is used during runtime and is the maximum of the three configurable
-       output-levels for console, log file, and in game shell.
-
-    The separation between the three devices is done by the OutputHandler.
-
-    @anchor COUTlevels
-    Possible levels are:
-     - 0: Very important output
-     - 1: Errors
-     - 2: Warnings
-     - 3: Information
-     - 4: Debug information
-     - 5: More debug information
-     - 6: Crazy debug information
-
-    Example:
-    @code
-    COUT(0) << "Very important output" << std::endl;
-    COUT(1) << "Error: Something went wrong!" << std::endl;
-    COUT(2) << "Warning: There might be a problem." << std::endl;
-    COUT(3) << "Info: It's Monday" << std::endl;
-    COUT(4) << "Debug: x is 1.23456" << std::endl;
-    @endcode
-*/
-
-#ifndef _Util_Debug_H__
-#define _Util_Debug_H__
-
-#include "UtilPrereqs.h"
-#include "OutputHandler.h"
-
-namespace orxonox
-{
-    // Just for convenience
-    using std::endl;
-
-    // Adjust this to discard certain output with level > hardDebugLevel at compile time already
-#ifdef ORXONOX_RELEASE
-    const int hardDebugLevel = OutputLevel::Verbose;
-#else
-    //! Maximum level for debug output that should be even processed at run time
-    const int hardDebugLevel = OutputLevel::Ultra;
-#endif
-
-    //! This function simply returns 0 and helps to suppress the "statement has no effect" compiler warning
-    inline int debugDummyFunction()
-    {
-        return 0;
-    }
-}
-
-/**
- at brief
-    Logs text output: You can use COUT(level) exactly like @c std::cout, but you have to specify an output level as argument.
- at param level
-    The level of the following output (passed with <tt><< "text"</tt>). Lower levels are more important. See @ref COUTlevels "the description above" for a list of possible output levels.
-
-    Example:
-    @code
-    COUT(3) << "Some info" << std::endl; // Output with level 3
-    @endcode
- at note
-    <tt>(a > b ? 0 : c << "text")</tt> is equivalent to <tt>(a > b ? 0 : (c << "text")</tt>
-    where <tt>(a > b ? 0 : )</tt> stands for COUT(x). This should explain how
-    this macro magic can possibly even work ;)
- at remarks
-    The <tt>? :</tt> operator requires both possible results to have the type of
-    the first. This is achieved by the int conversion operator dummy
-    in the @ref orxonox::OutputHandler.
-*/
-#define COUT(level)                                                    \
-    /*if*/ (level > orxonox::hardDebugLevel) ?                         \
-        orxonox::debugDummyFunction()                                  \
-    /*else*/ :                                                         \
-        /*if*/ (level > orxonox::OutputHandler::getSoftDebugLevel()) ? \
-            orxonox::debugDummyFunction()                              \
-        /*else*/ :                                                     \
-            orxonox::OutputHandler::getOutStream(level)
-
-/** Logs debug output: You can use DOUT exactly like @c std::cout.
-    Use this macro to produce temporary debug output that will be removed later on.
-    The console output shall have a special colour if available.
-*/
-#define DOUT orxonox::OutputHandler::getOutStream(-1) << "+++ "
-
-#endif /* _Util_Debug_H__ */

Modified: code/branches/output/src/libraries/util/Output.h
===================================================================
--- code/branches/output/src/libraries/util/Output.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/Output.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -34,8 +34,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     // Just for convenience
     using std::endl;
     using namespace level;
@@ -52,6 +50,8 @@
         return orxout(level, context());
     }
 }
-}
 
+#define COUT(level) orxonox::orxout()
+#define DOUT orxonox::orxout()
+
 #endif /* _Output_H__ */

Deleted: code/branches/output/src/libraries/util/OutputHandler.cc
===================================================================
--- code/branches/output/src/libraries/util/OutputHandler.cc	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/OutputHandler.cc	2011-07-25 21:53:17 UTC (rev 8787)
@@ -1,356 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      Reto Grieder
- *
- */
-
-/**
- at file
- at brief
-    Definition of classes related to output (logging).
-*/
-
-#include "OutputHandler.h"
-
-#include <algorithm>
-#include <ctime>
-#include <cstdlib>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-
-#include "Debug.h"
-
-namespace orxonox
-{
-    /////////////////////////
-    ///// LogFileWriter /////
-    /////////////////////////
-    /**
-    @brief
-        Writes the output to the log file.
-    @note
-        As long as the correct log path is not yet known (for pre main code), the
-        LogFileWriter will write to a temporary file in /temp (Unix) or %TEMP% (Windows).
-        As soon as you set the correct path setLogPath the content of the temporary file
-        is read and put into the new file as well.
-    */
-    class LogFileWriter : public OutputListener
-    {
-    public:
-        /**
-        @brief
-            Gets temporary log path and starts the log file
-        */
-        LogFileWriter()
-            : OutputListener("LogFile")
-        {
-            this->logFileBaseName_ = "orxonox.log";
-
-            // Get path for a temporary file
-#ifdef ORXONOX_PLATFORM_WINDOWS
-            char* pTempDir = getenv("TEMP");
-            this->logFilename_ = std::string(pTempDir) + '/' + this->logFileBaseName_;
-#else
-            this->logFilename_ = std::string("/tmp/") + this->logFileBaseName_;
-#endif
-
-            // Get current time
-            time_t rawtime;
-            struct tm* timeinfo;
-            time(&rawtime);
-            timeinfo = localtime(&rawtime);
-
-            this->openFile();
-            if (this->logFile_.is_open())
-            {
-                this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl;
-                this->logFile_.flush();
-            }
-        }
-
-        //! Closes the log file
-        ~LogFileWriter()
-        {
-            if (this->logFile_.is_open())
-            {
-                this->logFile_ << "Closed log" << std::endl;
-                this->logFile_.close();
-            }
-        }
-
-        //! Changes the log path
-        void setLogPath(const std::string& path)
-        {
-            if (this->logFile_.is_open())
-                this->logFile_.close();
-
-            // Open the new file
-            this->logFilename_ = path + this->logFileBaseName_;
-            this->openFile();
-        }
-
-        //! Erases the log file
-        void clearFile()
-        {
-            if (this->logFile_.is_open())
-            {
-                this->logFile_.close();
-                this->openFile();
-            }
-        }
-
-    private:
-        void openFile()
-        {
-            this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
-
-            if (this->logFile_.is_open())
-                this->outputStream_ = &this->logFile_;
-            else
-            {
-                COUT(2) << "Warning: Failed to open log file. File logging disabled." << std::endl;
-                this->outputStream_ = NULL;
-            }
-        }
-
-        std::ofstream logFile_;         //!< File handle for the log file
-        std::string   logFilename_;     //!< Filename of the log file
-        std::string   logFileBaseName_; //!< How the log file shall be named on the filesystem
-    };
-
-
-    /////////////////////////
-    ///// ConsoleWriter /////
-    /////////////////////////
-    /**
-    @brief
-        Writes the output to std::cout.
-    @note
-        This listener will usually be disable once an actual shell with console is instantiated.
-    */
-    class ConsoleWriter : public OutputListener
-    {
-    public:
-        //! Only assigns the output stream with std::cout
-        ConsoleWriter()
-            : OutputListener("Console")
-        {
-            this->outputStream_ = &std::cout;
-        }
-    };
-
-
-    ///////////////////////////
-    ///// MemoryLogWriter /////
-    ///////////////////////////
-    /**
-    @brief
-        OutputListener that writes all the output piece by piece to an array
-        associated with the corresponding output level.
-        Used as buffer until all output devices have been initialised.
-    @note
-        At some point, OutputHandler::disableMemoryLog() has to be called in
-        order to avoid large memory footprints of this class.
-    */
-    class MemoryLogWriter : public OutputListener
-    {
-    public:
-        friend class OutputHandler;
-
-        MemoryLogWriter()
-            : OutputListener("memoryLog")
-        {
-            this->outputStream_ = &this->buffer_;
-        }
-
-        //! Push the just written output to the internal array
-        void outputChanged(int level)
-        {
-            if (!this->buffer_.str().empty())
-            {
-                // Read ostringstream and store it
-                this->output_.push_back(std::make_pair(level, this->buffer_.str()));
-                // Clear content and flags
-                this->buffer_.str(std::string());
-            }
-            this->buffer_.clear();
-        }
-
-    private:
-        std::ostringstream          buffer_; //!< Stream object used to process the output
-        OutputHandler::OutputVector output_; //!< Vector containing ALL output
-    };
-
-
-    /////////////////////////
-    ///// OutputHandler /////
-    /////////////////////////
-    int OutputHandler::softDebugLevel_s = hardDebugLevel;
-
-    //! Creates the LogFileWriter and the MemoryLogWriter
-    OutputHandler::OutputHandler()
-        : outputLevel_(OutputLevel::Verbose)
-    {
-        // Note: These levels only concern startup before orxonox.ini is read.
-#ifdef ORXONOX_RELEASE
-        const OutputLevel::Value initialLevelConsole = OutputLevel::Error;
-#else
-        const OutputLevel::Value initialLevelConsole = OutputLevel::Info;
-#endif
-        // Use high log level because we rewrite the log file anyway with the
-        // correct level. But if Orxonox were to crash before that, we might be
-        // grateful to have a high debug level, esp. for releases.
-        const OutputLevel::Value intialLevelLogFile = OutputLevel::Debug;
-
-        this->logFile_ = new LogFileWriter();
-        // Use default level until we get the configValue from the Core
-        this->logFile_->softDebugLevel_ = intialLevelLogFile;
-        this->registerOutputListener(this->logFile_);
-
-        this->consoleWriter_ = new ConsoleWriter();
-        this->consoleWriter_->softDebugLevel_ = initialLevelConsole;
-        this->registerOutputListener(this->consoleWriter_);
-
-        this->memoryBuffer_ = new MemoryLogWriter();
-        // Write everything, e.g. use hardDebugLevel
-        this->memoryBuffer_->softDebugLevel_ = hardDebugLevel;
-        this->registerOutputListener(this->memoryBuffer_);
-    }
-
-    //! Destroys the LogFileWriter and the MemoryLogWriter
-    OutputHandler::~OutputHandler()
-    {
-        delete this->logFile_;
-        delete this->consoleWriter_;
-        delete this->memoryBuffer_; // Might already be NULL
-    }
-
-    OutputHandler& OutputHandler::getInstance()
-    {
-        static OutputHandler orxout;
-        return orxout;
-    }
-
-    void OutputHandler::registerOutputListener(OutputListener* listener)
-    {
-        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((*it)->name_ == listener->name_)
-            {
-                COUT(2) << "OutputHandler, Warning: Trying to register two listeners with the same name!" << std::endl;
-                return;
-            }
-        }
-        this->listeners_.push_back(listener);
-        this->updateGlobalDebugLevel();
-    }
-
-    void OutputHandler::unregisterOutputListener(OutputListener* listener)
-    {
-        for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((*it)->name_ == listener->name_)
-            {
-                this->listeners_.erase(it);
-                break;
-            }
-        }
-        this->updateGlobalDebugLevel();
-    }
-
-    void OutputHandler::setLogPath(const std::string& path)
-    {
-        this->logFile_->setLogPath(path);
-        this->rewriteLogFile();
-    }
-
-    void OutputHandler::rewriteLogFile()
-    {
-        logFile_->clearFile();
-
-        if (logFile_->outputStream_ == NULL)
-            return;
-
-        for (OutputVector::const_iterator it = this->getOutput().begin(); it != this->getOutput().end(); ++it)
-        {
-            if (it->first <= logFile_->softDebugLevel_)
-                (*logFile_->outputStream_) << it->second;
-        }
-        logFile_->outputStream_->flush();
-    }
-
-    void OutputHandler::disableCout()
-    {
-        this->unregisterOutputListener(this->consoleWriter_);
-    }
-
-    void OutputHandler::enableCout()
-    {
-        this->registerOutputListener(this->consoleWriter_);
-    }
-
-    void OutputHandler::disableMemoryLog()
-    {
-        this->unregisterOutputListener(this->memoryBuffer_);
-        // Only clear the buffer so we can still reference the vector
-        this->memoryBuffer_->output_.clear();
-    }
-
-    const OutputHandler::OutputVector& OutputHandler::getOutput() const
-    {
-        return this->memoryBuffer_->output_;
-    }
-
-    int OutputHandler::getSoftDebugLevel(const std::string& name) const
-    {
-        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((*it)->name_ == name)
-                return (*it)->softDebugLevel_;
-        }
-        return -1;
-    }
-
-    void OutputHandler::setSoftDebugLevel(const std::string& name, int level)
-    {
-        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((*it)->name_ == name)
-                (*it)->softDebugLevel_ = level;
-        }
-        this->updateGlobalDebugLevel();
-    }
-
-    void OutputHandler::updateGlobalDebugLevel()
-    {
-        int globalSoftDebugLevel = -1;
-        std::vector<OutputListener*>::const_iterator it = this->listeners_.begin();
-        for (; it != this->listeners_.end(); ++it)
-            globalSoftDebugLevel = std::max(globalSoftDebugLevel, (*it)->softDebugLevel_);
-
-        OutputHandler::softDebugLevel_s = globalSoftDebugLevel;
-    }
-}

Deleted: code/branches/output/src/libraries/util/OutputHandler.h
===================================================================
--- code/branches/output/src/libraries/util/OutputHandler.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/OutputHandler.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -1,285 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      Reto Grieder
- *
- */
-
-/**
- at file
- at ingroup Util Output
- at brief
-    Declaration of classes related to output (logging), most notably OutputHandler and OutputListener.
-*/
-
-#ifndef _OutputHandler_H__
-#define _OutputHandler_H__
-
-#include "UtilPrereqs.h"
-
-#include <ostream>
-#include <string>
-#include <vector>
-#include <utility>
-
-namespace orxonox
-{
-    /**
-    @brief
-        Denotes different levels of text output (log output)
-
-         - 0, None   : Very important output
-         - 1, Error  : Errors
-         - 2, Warning: Warnings
-         - 3, Info   : Information
-         - 4, Debug  : Debug information
-         - 5, Verbose: More debug information
-         - 6, Ultra  : Crazy debug information
-    */
-    namespace OutputLevel
-    {
-        enum Value
-        {
-            TDebug  = -1,
-            None    = 0,
-            Error   = 1,
-            Warning = 2,
-            Info    = 3,
-            Debug   = 4,
-            Verbose = 5,
-            Ultra   = 6,
-        };
-    }
-
-    // Forward declarations for classes in the source file
-    class LogFileWriter;
-    class ConsoleWriter;
-    class MemoryLogWriter;
-
-    /**
-    @brief
-        The OutputHandler acts like @c std::cout, but output isn't only shown in the console.
-
-        Output passed to the OutputHandler is distributed to all registered listeners,
-        for example the console, the logfile, or the ingame shell.
-
-        You can register your own listener for output by inheriting from OutputListener.
-        And if you need the output previously processed, iterate over it with
-        OutputHandler::getOutputVectorBegin and OutputHandler::getOutputVectorEnd.
-
-        The way to output text is to first set the desired output level with
-        @ref getOutStream "OutputHandler::getOutStream(level)" and then use
-        the "<<" operator like with @c std::cout. Alternatively you can use the COUT() macro.
-    */
-    class _UtilExport OutputHandler
-    {
-        public:
-            //! Returns a reference to the only existing instance of the OutputHandler class.
-            static OutputHandler& getInstance();
-
-            //! Sets the output level and returns a stream to be used with "<<"
-            static inline OutputHandler& getOutStream(int level)
-                { return OutputHandler::getInstance().setOutputLevel(level); }
-
-            typedef std::vector<std::pair<int, std::string> > OutputVector;
-            //! Returns all output written so far (empty if disableMemoryLog() was called)
-            const OutputVector& getOutput() const;
-
-            //! Writes to all output devices
-            static inline void log(const std::string& text)
-                { OutputHandler::getOutStream(0).output(text) << std::endl; }
-
-            //! Writes an error message to the output
-            static inline void error(const std::string& text)
-                { OutputHandler::getOutStream(1).output(text) << std::endl; }
-
-            //! Writes a warning message to the output
-            static inline void warning(const std::string& text)
-                { OutputHandler::getOutStream(2).output(text) << std::endl; }
-
-            //! Writes an informational message to the output
-            static inline void info(const std::string& text)
-                { OutputHandler::getOutStream(3).output(text) << std::endl; }
-
-            //! Writes a debug message to the output
-            static inline void debug(const std::string& text)
-                { OutputHandler::getOutStream(4).output(text) << std::endl; }
-
-            //! Registers an object that receives output via a provided std::ostream
-            void registerOutputListener(OutputListener* listener);
-            //! Unregisters an object that receives output via a provided std::ostream
-            void unregisterOutputListener(OutputListener* listener);
-
-            //! Set the log path once the program has been properly initialised
-            void setLogPath(const std::string& path);
-            /** Rewrites the log file (completely respects the current debug level).
-                Once disableMemoryLog() has been called, this function will do nothing.
-            */
-            void rewriteLogFile();
-
-            //! Disables the std::cout stream for output
-            void disableCout();
-            //! Enables the std::cout stream for output (startup behaviour)
-            void enableCout();
-            //! Stop writing to the memory buffer (call this as soon as possible to minimise memory usage)
-            void disableMemoryLog();
-
-            //! Sets the level of the incoming output and returns the OutputHandler
-            inline OutputHandler& setOutputLevel(int level)
-                { this->outputLevel_ = level; return *this; }
-
-            //! Returns the level of the incoming output
-            inline int getOutputLevel() const
-                { return this->outputLevel_; }
-
-            //! Returns the maximum debug level over all registered listeners (devices)
-            static int getSoftDebugLevel() { return softDebugLevel_s; }
-            //! Returns the soft debug level for a device by its name   @return The level or -1 if the listener was not found
-            int  getSoftDebugLevel(const std::string& name) const;
-            //! Sets the soft debug level for a listener by its name   @remarks Only works for registered listeners!
-            void setSoftDebugLevel(const std::string& name, int level);
-
-            /**
-            @brief
-                General template that copes with all output.
-                Required because operator << might be ambiguous.
-                @a output will be streamed into every listener with an appropriate debug level
-            @return
-                Returns a reference to the OutputHandler so you can use it again directly
-            */
-            template <class T>
-            OutputHandler& output(const T& output);
-
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(unsigned char val)      { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(short val)              { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(unsigned short val)     { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(int val)                { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(unsigned int val)       { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(long val)               { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(unsigned long val)      { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(long long val)          { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(unsigned long long val) { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(float val)              { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(double val)             { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(long double val)        { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(const void* val)        { return this->output(val); }
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(bool val)               { return this->output(val); }
-
-            //! Overloaded << operator, redirects the output to the listeners
-            inline OutputHandler& operator<<(std::streambuf* sb)     { return this->output(sb); }
-
-            //! Overloaded << operator, redirect the output of classes with self defined 'operator <<' to the listeners
-            template <class T>
-            inline OutputHandler& operator<<(const T& val)           { return this->output(val); }
-
-            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
-            inline OutputHandler& operator<<(std::ostream&  (*manip)(std::ostream&))  { return this->output(manip); }
-            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
-            inline OutputHandler& operator<<(std::ios&      (*manip)(std::ios&))      { return this->output(manip); }
-            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
-            inline OutputHandler& operator<<(std::ios_base& (*manip)(std::ios_base&)) { return this->output(manip); }
-
-            //! Dummy operator required by Debug.h for the ternary operator
-            inline operator int() const { return 0; }
-
-        private:
-            OutputHandler();
-            ~OutputHandler();
-            OutputHandler(const OutputHandler& rhs);      //!< Copy-constructor: Unused and undefined
-
-            /// Evaluates the maximum global log level
-            void updateGlobalDebugLevel();
-
-            std::vector<OutputListener*> listeners_;        //!< Array with all registered output listeners
-            int                          outputLevel_;      //!< The level of the incoming output
-            LogFileWriter*               logFile_;          //!< Writes output to the log file
-            ConsoleWriter*               consoleWriter_;    //!< Writes to std::cout (can be disabled)
-            MemoryLogWriter*             memoryBuffer_;     //!< Writes to memory as a buffer (can/must be stopped at some time)
-            static int                   softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
-    };
-
-    /**
-    @brief
-        Interface for listening to output.
-    @remarks
-        Remember to register the listener (not done automatically!)
-    */
-    class OutputListener
-    {
-        friend class OutputHandler;
-
-    public:
-        OutputListener(const std::string& name)
-            : outputStream_(NULL)
-            , name_(name)
-            , softDebugLevel_(OutputLevel::Info)
-        {}
-        virtual ~OutputListener() {}
-
-        //! Gets called whenever output is put into the stream
-        virtual void outputChanged(int level) {}
-        //! Returns the name of this output listener
-        const std::string& getOutputListenerName() const { return this->name_; }
-
-    protected:
-        std::ostream*     outputStream_;   //!< Pointer to the associated output stream, can be NULL
-
-    private:
-        const std::string name_;           //!< Name of the listener, constant and unique!
-        int               softDebugLevel_; //!< Current soft debug level that defines what kind of output is written to the stream
-    };
-
-    template<class T>
-    inline OutputHandler& OutputHandler::output(const T& output)
-    {
-        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
-            {
-                std::ostream& stream = *((*it)->outputStream_);
-                stream << output;
-                stream.flush();
-                (*it)->outputChanged(this->outputLevel_);
-            }
-        }
-
-        return *this;
-    }
-}
-
-#endif /* _OutputHandler_H__ */

Modified: code/branches/output/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/branches/output/src/libraries/util/UtilPrereqs.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/UtilPrereqs.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -87,8 +87,9 @@
     class Exception;
     class ExprParser;
     class MultiType;
-    class OutputHandler;
     class OutputListener;
+    class OutputManager;
+    class OutputStream;
     template <ScopeID::Value>
     class Scope;
     template <class, ScopeID::Value>

Modified: code/branches/output/src/libraries/util/output/ConsoleWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.cc	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/ConsoleWriter.cc	2011-07-25 21:53:17 UTC (rev 8787)
@@ -32,8 +32,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     ConsoleWriter::ConsoleWriter()
     {
         this->setLevelMax(level::user_info);
@@ -77,4 +75,3 @@
         }
     }
 }
-}

Modified: code/branches/output/src/libraries/util/output/ConsoleWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/ConsoleWriter.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -34,8 +34,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     class _UtilExport ConsoleWriter : public OutputListener
     {
         public:
@@ -55,6 +53,5 @@
             bool bEnabled_;
     };
 }
-}
 
 #endif /* _ConsoleWriter_H__ */

Modified: code/branches/output/src/libraries/util/output/LogWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/LogWriter.cc	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/LogWriter.cc	2011-07-25 21:53:17 UTC (rev 8787)
@@ -35,8 +35,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     LogWriter::LogWriter()
     {
         this->setLevelMax(level::internal_info);
@@ -127,4 +125,3 @@
                        (timeinfo->tm_sec  < 10 ? "0" : "") << timeinfo->tm_sec  << ' ' << line << std::endl;
     }
 }
-}

Modified: code/branches/output/src/libraries/util/output/LogWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/LogWriter.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/LogWriter.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -37,8 +37,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     class _UtilExport LogWriter : public OutputListener
     {
         public:
@@ -66,6 +64,5 @@
             std::ofstream file_;
     };
 }
-}
 
 #endif /* _LogWriter_H__ */

Modified: code/branches/output/src/libraries/util/output/MemoryWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/MemoryWriter.cc	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/MemoryWriter.cc	2011-07-25 21:53:17 UTC (rev 8787)
@@ -32,8 +32,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     MemoryWriter::MemoryWriter()
     {
         this->setLevelMask(level::all);
@@ -69,4 +67,3 @@
         this->output(level::debug_output, context::undefined(), std::vector<std::string>(1, "MemoryWriter disabled, further messages may be lost"));
     }
 }
-}

Modified: code/branches/output/src/libraries/util/output/MemoryWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/MemoryWriter.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/MemoryWriter.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -34,8 +34,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     class _UtilExport MemoryWriter : public OutputListener
     {
         struct Message
@@ -65,6 +63,5 @@
             std::vector<Message> messages_;
     };
 }
-}
 
 #endif /* _MemoryWriter_H__ */

Modified: code/branches/output/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputDefinitions.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/OutputDefinitions.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -37,8 +37,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     typedef uint16_t OutputLevel;
 
     namespace level
@@ -79,6 +77,5 @@
         }
     }
 }
-}
 
 #endif /* _OutputDefinitions_H__ */

Modified: code/branches/output/src/libraries/util/output/OutputListener.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputListener.cc	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/OutputListener.cc	2011-07-25 21:53:17 UTC (rev 8787)
@@ -32,8 +32,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     OutputListener::OutputListener()
     {
         this->levelMask_ = level::none;
@@ -76,4 +74,3 @@
         OutputManager::getInstance().updateCombinedContextMask();
     }
 }
-}

Modified: code/branches/output/src/libraries/util/output/OutputListener.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputListener.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/OutputListener.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -37,8 +37,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     class _UtilExport OutputListener
     {
         public:
@@ -71,6 +69,5 @@
             OutputContext contextMask_;
     };
 }
-}
 
 #endif /* _OutputListener_H__ */

Modified: code/branches/output/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputManager.cc	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/OutputManager.cc	2011-07-25 21:53:17 UTC (rev 8787)
@@ -34,8 +34,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     OutputManager::OutputManager()
     {
         this->combinedLevelMask_ = 0;
@@ -202,4 +200,3 @@
         return prefix;
     }
 }
-}

Modified: code/branches/output/src/libraries/util/output/OutputManager.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputManager.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/OutputManager.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -32,17 +32,12 @@
 #include "util/UtilPrereqs.h"
 
 #include <vector>
-
 #include <boost/bimap.hpp>
 
 #include "OutputDefinitions.h"
 
 namespace orxonox
 {
-namespace test
-{
-    class OutputListener;
-
     class _UtilExport OutputManager
     {
         public:
@@ -86,6 +81,5 @@
             boost::bimap<OutputContext, std::string> contexts_;
     };
 }
-}
 
 #endif /* _OutputManager_H__ */

Modified: code/branches/output/src/libraries/util/output/OutputStream.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputStream.cc	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/OutputStream.cc	2011-07-25 21:53:17 UTC (rev 8787)
@@ -32,8 +32,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     OutputStream::OutputStream()
     {
         this->level_ = level::none;
@@ -55,4 +53,3 @@
         this->bAcceptsOutput_ = OutputManager::getInstanceAndCreateListeners().acceptsOutput(this->level_, this->context_);
     }
 }
-}

Modified: code/branches/output/src/libraries/util/output/OutputStream.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputStream.h	2011-07-25 21:18:20 UTC (rev 8786)
+++ code/branches/output/src/libraries/util/output/OutputStream.h	2011-07-25 21:53:17 UTC (rev 8787)
@@ -37,8 +37,6 @@
 
 namespace orxonox
 {
-namespace test
-{
     class OutputStream : public std::ostringstream
     {
         typedef std::ostream& (*EndlType)(std::ostream&);
@@ -80,6 +78,5 @@
             bool bAcceptsOutput_;
     };
 }
-}
 
 #endif /* _OutputStream_H__ */




More information about the Orxonox-commit mailing list