diff options
29 files changed, 161 insertions, 100 deletions
diff --git a/base/main.cpp b/base/main.cpp index b78f1be154..2658d1dc67 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -40,6 +40,7 @@ #include "common/archive.h" #include "common/config-manager.h" #include "common/debug.h" +#include "common/debug-channels.h" #include "common/events.h" #include "common/EventRecorder.h" #include "common/file.h" diff --git a/common/debug-channels.h b/common/debug-channels.h new file mode 100644 index 0000000000..445d0e0261 --- /dev/null +++ b/common/debug-channels.h @@ -0,0 +1,132 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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. + * + * $URL$ + * $Id$ + */ + +#ifndef COMMON_DEBUG_CHANNELS_H +#define COMMON_DEBUG_CHANNELS_H + +#include "common/scummsys.h" + +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/list.h" +#include "common/singleton.h" +#include "common/str.h" + + +namespace Common { + +// TODO: Find a better name for this +class DebugManager : public Singleton<DebugManager> { +public: + + struct DebugChannel { + DebugChannel() : channel(0), enabled(false) {} + DebugChannel(uint32 c, const String &n, const String &d) + : name(n), description(d), channel(c), enabled(false) {} + + String name; + String description; + + uint32 channel; + bool enabled; + }; + + /** + * Adds a debug channel. + * + * A debug channel is considered roughly similar to what our debug levels described by + * gDebugLevel try to achieve: + * + * Debug channels should only affect the display of additional debug output, based on + * their state. That is if they are enabled, channel specific debug messages should + * be shown. If they are disabled on the other hand, those messages will be hidden. + * + * @see gDebugLevel. + * + * Note that we have debug* functions which depend both on the debug level set and + * specific debug channels. Those functions will only show output, when *both* criteria + * are satisfied. + * + * @param channel the channel flag (should be OR-able i.e. first one should be 1 then 2, 4, etc.) + * @param name the option name which is used in the debugger/on the command line to enable + * this special debug level (case will be ignored) + * @param description the description which shows up in the debugger + * @return true on success false on failure + */ + bool addDebugChannel(uint32 channel, const String &name, const String &description); + + /** + * Resets all engine specific debug channels. + */ + void clearAllDebugChannels(); + + /** + * Enables an debug channel. + * + * @param name the name of the debug channel to enable + * @return true on success, false on failure + */ + bool enableDebugChannel(const String &name); + + /** + * Disables an debug channel. + * + * @param name the name of the debug channel to disable + * @return true on success, false on failure + */ + bool disableDebugChannel(const String &name); + + + + typedef List<DebugChannel> DebugChannelList; + + /** + * Lists all engine specific debug channels. + * + * @return returns an array with all debug channels + */ + DebugChannelList listDebugChannels(); + + + /** + * Test whether the given debug channel is enabled. + */ + bool isDebugChannelEnabled(uint32 channel); + +private: + typedef HashMap<String, DebugChannel, IgnoreCase_Hash, IgnoreCase_EqualTo> DebugChannelMap; + + DebugChannelMap gDebugChannels; + uint32 gDebugChannelsEnabled; + + friend class Singleton<SingletonBaseType>; + DebugManager() : gDebugChannelsEnabled(0) {} +}; + +/** Shortcut for accessing the debug manager. */ +#define DebugMan Common::DebugManager::instance() + +} // End of namespace Common + +#endif diff --git a/common/debug.cpp b/common/debug.cpp index 30f4534f56..116c0d0d56 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -23,6 +23,7 @@ */ #include "common/debug.h" +#include "common/debug-channels.h" #include "common/util.h" #include <stdarg.h> // For va_list etc. diff --git a/common/debug.h b/common/debug.h index b70b838fab..784b3454b5 100644 --- a/common/debug.h +++ b/common/debug.h @@ -26,108 +26,11 @@ #define COMMON_DEBUG_H #include "common/scummsys.h" -#include "common/singleton.h" +#include "common/debug-channels.h" #include "common/textconsole.h" -#include "common/list.h" -#include "common/str.h" - -#include "common/hashmap.h" -#include "common/hash-str.h" - namespace Common { -// TODO: Find a better name for this -class DebugManager : public Singleton<DebugManager> { -public: - - struct DebugChannel { - DebugChannel() : channel(0), enabled(false) {} - DebugChannel(uint32 c, const String &n, const String &d) - : name(n), description(d), channel(c), enabled(false) {} - - String name; - String description; - - uint32 channel; - bool enabled; - }; - - /** - * Adds a debug channel. - * - * A debug channel is considered roughly similar to what our debug levels described by - * gDebugLevel try to achieve: - * - * Debug channels should only affect the display of additional debug output, based on - * their state. That is if they are enabled, channel specific debug messages should - * be shown. If they are disabled on the other hand, those messages will be hidden. - * - * @see gDebugLevel. - * - * Note that we have debug* functions which depend both on the debug level set and - * specific debug channels. Those functions will only show output, when *both* criteria - * are satisfied. - * - * @param channel the channel flag (should be OR-able i.e. first one should be 1 then 2, 4, etc.) - * @param name the option name which is used in the debugger/on the command line to enable - * this special debug level (case will be ignored) - * @param description the description which shows up in the debugger - * @return true on success false on failure - */ - bool addDebugChannel(uint32 channel, const String &name, const String &description); - - /** - * Resets all engine specific debug channels. - */ - void clearAllDebugChannels(); - - /** - * Enables an debug channel. - * - * @param name the name of the debug channel to enable - * @return true on success, false on failure - */ - bool enableDebugChannel(const String &name); - - /** - * Disables an debug channel. - * - * @param name the name of the debug channel to disable - * @return true on success, false on failure - */ - bool disableDebugChannel(const String &name); - - - - typedef List<DebugChannel> DebugChannelList; - - /** - * Lists all engine specific debug channels. - * - * @return returns an array with all debug channels - */ - DebugChannelList listDebugChannels(); - - - /** - * Test whether the given debug channel is enabled. - */ - bool isDebugChannelEnabled(uint32 channel); - -private: - typedef HashMap<String, DebugChannel, IgnoreCase_Hash, IgnoreCase_EqualTo> DebugChannelMap; - - DebugChannelMap gDebugChannels; - uint32 gDebugChannelsEnabled; - - friend class Singleton<SingletonBaseType>; - DebugManager() : gDebugChannelsEnabled(0) {} -}; - -/** Shortcut for accessing the debug manager. */ -#define DebugMan Common::DebugManager::instance() - /** * Set the output formatter used by debug() and related functions. */ diff --git a/common/system.h b/common/system.h index ca006950e3..76689bf381 100644 --- a/common/system.h +++ b/common/system.h @@ -29,6 +29,7 @@ #include "common/scummsys.h" #include "common/noncopyable.h" #include "common/rect.h" +#include "common/list.h" // For OSystem::getSupportedFormats() #include "graphics/pixelformat.h" diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 561989ee66..c2c6d10bfe 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -29,6 +29,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/random.h" #include "engines/util.h" diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index 76fe901705..35285798d4 100644 --- a/engines/agi/preagi.cpp +++ b/engines/agi/preagi.cpp @@ -24,6 +24,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/random.h" #include "sound/mididrv.h" diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index b91efb58db..c33349173a 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -28,6 +28,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/system.h" #include "engines/util.h" diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp index c91dfdd540..e6d0359059 100644 --- a/engines/cruise/cruise.cpp +++ b/engines/cruise/cruise.cpp @@ -28,6 +28,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/system.h" #include "engines/util.h" diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index 5fbad40a4f..cbf878279b 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/events.h" #include "common/file.h" #include "common/keyboard.h" diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index ca6266e321..e3472e9fe1 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -23,6 +23,7 @@ * */ +#include "common/debug-channels.h" #include "common/endian.h" #include "common/events.h" #include "common/EventRecorder.h" diff --git a/engines/groovie/debug.cpp b/engines/groovie/debug.cpp index 2a4eaf4894..41ebb2fbcd 100644 --- a/engines/groovie/debug.cpp +++ b/engines/groovie/debug.cpp @@ -27,6 +27,8 @@ #include "groovie/groovie.h" #include "groovie/script.h" +#include "common/debug-channels.h" + namespace Groovie { Debugger::Debugger(GroovieEngine *vm) : diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp index 0e460a9049..3b83b880d5 100644 --- a/engines/groovie/groovie.cpp +++ b/engines/groovie/groovie.cpp @@ -24,6 +24,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/events.h" #include "engines/util.h" diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 2ff14f2706..c7c7f21738 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -31,6 +31,7 @@ #include "groovie/saveload.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/endian.h" #include "common/events.h" #include "common/EventRecorder.h" diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index 4f2246d264..cf61b58326 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -29,6 +29,7 @@ #include "common/system.h" #include "common/savefile.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "gui/message.h" diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index e43c4381b8..0b852eb025 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -24,6 +24,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/EventRecorder.h" #include "sound/mididrv.h" diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index 45e207f0da..310480d2e1 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -24,6 +24,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/system.h" #include "common/savefile.h" #include "common/EventRecorder.h" diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp index 37666f6880..33a2fe6b68 100644 --- a/engines/m4/m4.cpp +++ b/engines/m4/m4.cpp @@ -58,6 +58,7 @@ #include "common/endian.h" #include "common/system.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "engines/util.h" #include "graphics/surface.h" #include "sound/mididrv.h" diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index ab55552ef4..d1ef3b2137 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -24,6 +24,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "mohawk/graphics.h" #include "mohawk/myst.h" diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index a529c7fb46..67d081120e 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -24,6 +24,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/events.h" #include "common/EventRecorder.h" #include "common/file.h" diff --git a/engines/sci/decompressor.cpp b/engines/sci/decompressor.cpp index 6ceb4c4f54..84af50b596 100644 --- a/engines/sci/decompressor.cpp +++ b/engines/sci/decompressor.cpp @@ -28,6 +28,7 @@ #include "common/util.h" #include "common/endian.h" #include "common/debug.h" +#include "common/debug-channels.h" #include "common/stream.h" #include "sci/decompressor.h" diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 9746bbada1..25d967c247 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -31,6 +31,7 @@ #include "sci/graphics/palette.h" #include "sci/graphics/screen.h" +#include "common/debug-channels.h" #include "common/list.h" #include "common/system.h" diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index d32b2babc5..3683795a79 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -24,6 +24,7 @@ */ #include "common/debug.h" +#include "common/debug-channels.h" #include "common/stack.h" #include "common/config-manager.h" diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index e96bfbad03..36318e1a32 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -23,9 +23,9 @@ * */ - #include "common/system.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "engines/advancedDetector.h" #include "engines/util.h" diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index 035f97350f..a0975839d6 100644 --- a/engines/scumm/debugger.cpp +++ b/engines/scumm/debugger.cpp @@ -23,8 +23,8 @@ * */ - #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/file.h" #include "common/str.h" #include "common/system.h" diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 93d4de6e97..a69ed40e3b 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -24,6 +24,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/md5.h" #include "common/events.h" #include "common/EventRecorder.h" diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 5f012ddff3..8d11efef3c 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -23,6 +23,7 @@ * */ +#include "common/debug-channels.h" #include "common/endian.h" #include "common/error.h" #include "common/events.h" diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index 9c54f18a79..187e685d06 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -25,6 +25,7 @@ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/events.h" #include "common/EventRecorder.h" #include "common/system.h" diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 24c908716f..13dc02452d 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -24,6 +24,7 @@ */ #include "common/debug.h" +#include "common/debug-channels.h" #include "common/system.h" #include "gui/debugger.h" |