[Orxonox-commit 4109] r8780 - in code/branches/output/src/libraries/util: . output
landauf at orxonox.net
landauf at orxonox.net
Mon Jul 25 20:03:06 CEST 2011
Author: landauf
Date: 2011-07-25 20:03:05 +0200 (Mon, 25 Jul 2011)
New Revision: 8780
Added:
code/branches/output/src/libraries/util/output/ConsoleWriter.cc
code/branches/output/src/libraries/util/output/ConsoleWriter.h
Modified:
code/branches/output/src/libraries/util/CMakeLists.txt
code/branches/output/src/libraries/util/output/OutputManager.cc
Log:
added ConsoleWriter
Modified: code/branches/output/src/libraries/util/CMakeLists.txt
===================================================================
--- code/branches/output/src/libraries/util/CMakeLists.txt 2011-07-25 16:28:57 UTC (rev 8779)
+++ code/branches/output/src/libraries/util/CMakeLists.txt 2011-07-25 18:03:05 UTC (rev 8780)
@@ -42,6 +42,7 @@
output/OutputStream.cc
output/OutputManager.cc
output/OutputListener.cc
+ output/ConsoleWriter.cc
output/LogWriter.cc
output/MemoryWriter.cc
)
Added: code/branches/output/src/libraries/util/output/ConsoleWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.cc (rev 0)
+++ code/branches/output/src/libraries/util/output/ConsoleWriter.cc 2011-07-25 18:03:05 UTC (rev 8780)
@@ -0,0 +1,80 @@
+/*
+ * 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
+ *
+ */
+
+#include "ConsoleWriter.h"
+
+#include "OutputManager.h"
+
+namespace orxonox
+{
+namespace test
+{
+ ConsoleWriter::ConsoleWriter()
+ {
+ this->setLevelMax(level::user_info);
+ this->bEnabled_ = true;
+ }
+
+ ConsoleWriter::~ConsoleWriter()
+ {
+ }
+
+ /*static*/ ConsoleWriter& ConsoleWriter::getInstance()
+ {
+ static ConsoleWriter instance;
+ return instance;
+ }
+
+ void ConsoleWriter::output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines)
+ {
+ const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
+ std::string blanks(prefix.length(), ' ');
+
+ for (size_t i = 0; i < lines.size(); ++i)
+ std::cout << (i == 0 ? prefix : blanks) << lines[i] << std::endl;
+ }
+
+ void ConsoleWriter::enable()
+ {
+ if (!this->bEnabled_)
+ {
+ OutputManager::getInstance().registerListener(this);
+ this->bEnabled_ = true;
+ }
+ }
+
+ void ConsoleWriter::disable()
+ {
+ if (this->bEnabled_)
+ {
+ OutputManager::getInstance().unregisterListener(this);
+ this->bEnabled_ = false;
+ }
+ }
+}
+}
Added: code/branches/output/src/libraries/util/output/ConsoleWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.h (rev 0)
+++ code/branches/output/src/libraries/util/output/ConsoleWriter.h 2011-07-25 18:03:05 UTC (rev 8780)
@@ -0,0 +1,60 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#ifndef _ConsoleWriter_H__
+#define _ConsoleWriter_H__
+
+#include "util/UtilPrereqs.h"
+#include "OutputListener.h"
+
+namespace orxonox
+{
+namespace test
+{
+ class _UtilExport ConsoleWriter : public OutputListener
+ {
+ public:
+ static ConsoleWriter& getInstance();
+
+ void enable();
+ void disable();
+
+ protected:
+ virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines);
+
+ private:
+ ConsoleWriter();
+ ConsoleWriter(const ConsoleWriter&);
+ ~ConsoleWriter();
+
+ bool bEnabled_;
+ };
+}
+}
+
+#endif /* _ConsoleWriter_H__ */
Property changes on: code/branches/output/src/libraries/util/output/ConsoleWriter.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/output/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputManager.cc 2011-07-25 16:28:57 UTC (rev 8779)
+++ code/branches/output/src/libraries/util/output/OutputManager.cc 2011-07-25 18:03:05 UTC (rev 8780)
@@ -28,34 +28,14 @@
#include "OutputManager.h"
-#include "util/Debug.h"
-#include "OutputListener.h"
#include "MemoryWriter.h"
+#include "ConsoleWriter.h"
#include "LogWriter.h"
namespace orxonox
{
namespace test
{
- class ConsoleOutput : public OutputListener
- {
- public:
- ConsoleOutput()
- {
- this->setLevelMax(level::user_info);
- }
-
- protected:
- virtual void output(OutputLevel level, OutputContext context, const std::vector<std::string>& lines)
- {
- const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
- std::string blanks(prefix.length(), ' ');
-
- for (size_t i = 0; i < lines.size(); ++i)
- COUT(0) << (i == 0 ? prefix : blanks) << lines[i] << endl;
- }
- };
-
OutputManager::OutputManager()
{
this->combinedLevelMask_ = 0;
@@ -76,8 +56,8 @@
{
static OutputManager& instance = OutputManager::getInstance();
- static ConsoleOutput consoleOutputInstance;
static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
+ static ConsoleWriter& consoleWriterInstance = ConsoleWriter::getInstance(); (void)consoleWriterInstance;
static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
return instance;
@@ -152,7 +132,6 @@
OutputContext registerContext(const std::string& name)
{
- COUT(0) << "### register context " << name << std::endl;
return OutputManager::getInstance().registerContext(name);
}
More information about the Orxonox-commit
mailing list