[Orxonox-commit 4137] r8808 - in code/branches/output/src/libraries: core core/command util util/output

landauf at orxonox.net landauf at orxonox.net
Sun Jul 31 23:42:55 CEST 2011


Author: landauf
Date: 2011-07-31 23:42:55 +0200 (Sun, 31 Jul 2011)
New Revision: 8808

Modified:
   code/branches/output/src/libraries/core/Loader.cc
   code/branches/output/src/libraries/core/Loader.h
   code/branches/output/src/libraries/core/command/Shell.cc
   code/branches/output/src/libraries/core/command/Shell.h
   code/branches/output/src/libraries/util/Output.h
   code/branches/output/src/libraries/util/output/BaseWriter.cc
   code/branches/output/src/libraries/util/output/BaseWriter.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/OutputManager.cc
Log:
Removed debugLevel_ from Shell, using correct variable inherited from BaseWriter as config value.
Fixed OutputListener::setLevelMax() which ignored the new output level "message".
Fixed using a boolean called "verbose" instead of the output level with the same name in Loader.
Preventing further problems of this kind by defining OutputLevel as an enum.

Modified: code/branches/output/src/libraries/core/Loader.cc
===================================================================
--- code/branches/output/src/libraries/core/Loader.cc	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/core/Loader.cc	2011-07-31 21:42:55 UTC (rev 8808)
@@ -92,16 +92,16 @@
         Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
     @param mask
         A ClassTreeMask, which defines which types of classes are loaded and which aren't.
-    @param verbose
+    @param bVerbose
         Whether the loader is verbose (prints its progress in a low output level) or not.
     @return
         Returns true if successful.
     */
-    bool Loader::load(const ClassTreeMask& mask, bool verbose)
+    bool Loader::load(const ClassTreeMask& mask, bool bVerbose)
     {
         bool success = true;
         for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
-            if (!Loader::load(it->first, it->second * mask, verbose))
+            if (!Loader::load(it->first, it->second * mask, bVerbose))
                 success = false;
 
         return success;
@@ -123,15 +123,15 @@
         Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
     @param mask
         A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
-    @param verbose
+    @param bVerbose
         Whether the loader is verbose (prints its progress in a low output level) or not.
     @return
         Returns true if successful.
     */
-    bool Loader::reload(const ClassTreeMask& mask, bool verbose)
+    bool Loader::reload(const ClassTreeMask& mask, bool bVerbose)
     {
         Loader::unload(mask);
-        return Loader::load(mask, verbose);
+        return Loader::load(mask, bVerbose);
     }
 
     /**
@@ -141,14 +141,14 @@
         The file to be loaded.
     @param mask
         A ClassTreeMask, which defines which types of classes are loaded and which aren't.
-    @param verbose
+    @param bVerbose
         Whether the loader is verbose (prints its progress in a low output level) or not.
     @param bRemoveLuaTags
         If true lua tags are just ignored and removed. The default is false.
     @return
         Returns true if successful.
     */
-    bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose, bool bRemoveLuaTags)
+    bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose, bool bRemoveLuaTags)
     {
         if (!file)
             return false;
@@ -186,7 +186,7 @@
 
         try
         {
-            if(verbose)
+            if(bVerbose)
             {
                 orxout(user_status, context::loader) << "Start loading " << file->getFilename() << "..." << endl;
                 orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl;
@@ -215,7 +215,7 @@
             rootNamespace->setRoot(true);
             rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
 
-            if(verbose)
+            if(bVerbose)
                 orxout(user_status, context::loader) << "Finished loading " << file->getFilename() << '.' << endl;
             else
                 orxout(verbose, context::loader) << "Finished loading " << file->getFilename() << '.' << endl;
@@ -270,15 +270,15 @@
         The file to be reloaded.
     @param mask
         A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
-    @param verbose
+    @param bVerbose
         Whether the loader is verbose (prints its progress in a low output level) or not.
     @return
         Returns true if successful.
     */
-    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool verbose)
+    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
     {
         Loader::unload(file, mask);
-        return Loader::load(file, mask, verbose);
+        return Loader::load(file, mask, bVerbose);
     }
 
     bool Loader::getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags)
@@ -338,7 +338,7 @@
             {
                 orxout(internal_error, context::loader) << "Error in level file" << endl;
                 // TODO: error handling
-                return false; 
+                return false;
             }
         }
 

Modified: code/branches/output/src/libraries/core/Loader.h
===================================================================
--- code/branches/output/src/libraries/core/Loader.h	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/core/Loader.h	2011-07-31 21:42:55 UTC (rev 8808)
@@ -57,14 +57,14 @@
             static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
             static void remove(const XMLFile* file);
 
-            static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
+            static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
             static void unload(const ClassTreeMask& mask = ClassTreeMask());
-            static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
+            static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
 
             static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),
-                             bool verbose = true, bool bRemoveLuaTags = false);
+                             bool bVerbose = true, bool bRemoveLuaTags = false);
             static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
-            static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
+            static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
 
             static std::string replaceLuaTags(const std::string& text);
             static std::string removeLuaTags(const std::string& text);

Modified: code/branches/output/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/output/src/libraries/core/command/Shell.cc	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/core/command/Shell.cc	2011-07-31 21:42:55 UTC (rev 8808)
@@ -169,12 +169,12 @@
         bool isNormal = (value == PathConfig::buildDirectoryRun());
         if (isNormal)
         {
-            ModifyConfigValueExternal(debugLevel_, this->getConfigurableMaxLevelName(), update);
+            ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), update);
         }
         else
         {
             OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
-            ModifyConfigValueExternal(debugLevel_, this->getConfigurableMaxLevelName(), tset, level);
+            ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, level);
         }
     }
 

Modified: code/branches/output/src/libraries/core/command/Shell.h
===================================================================
--- code/branches/output/src/libraries/core/command/Shell.h	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/core/command/Shell.h	2011-07-31 21:42:55 UTC (rev 8808)
@@ -199,7 +199,6 @@
             unsigned int              maxHistoryLength_;    ///< The maximum number of saved commands
             unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
             std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
-            OutputLevel               debugLevel_;          //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
             static unsigned int       cacheSize_s;          ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass
     };
 }

Modified: code/branches/output/src/libraries/util/Output.h
===================================================================
--- code/branches/output/src/libraries/util/Output.h	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/util/Output.h	2011-07-31 21:42:55 UTC (rev 8808)
@@ -36,7 +36,6 @@
 {
     // Just for convenience
     using std::endl;
-    using namespace level;
 
     inline OutputStream& orxout(OutputLevel level = level::debug_output, OutputContext context = context::undefined())
     {

Modified: code/branches/output/src/libraries/util/output/BaseWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/BaseWriter.cc	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/util/output/BaseWriter.cc	2011-07-31 21:42:55 UTC (rev 8808)
@@ -64,8 +64,8 @@
 
     void BaseWriter::changedConfigurableLevels()
     {
-        OutputLevel max_level = std::max(this->configurableMaxLevel_, this->configurableContextsMaxLevel_);
-        OutputListener::setLevelMax(max_level);
+        int max_level = std::max(this->configurableMaxLevel_, this->configurableContextsMaxLevel_);
+        OutputListener::setLevelMax(static_cast<OutputLevel>(max_level));
     }
 
     void BaseWriter::changedConfigurableContexts()

Modified: code/branches/output/src/libraries/util/output/BaseWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/BaseWriter.h	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/util/output/BaseWriter.h	2011-07-31 21:42:55 UTC (rev 8808)
@@ -49,11 +49,11 @@
 
             void setLevelMax(OutputLevel max);
 
-            OutputLevel configurableMaxLevel_;
+            int configurableMaxLevel_;
             inline std::string getConfigurableMaxLevelName() const
                 { return "outputLevel" + this->name_; }
 
-            OutputLevel configurableContextsMaxLevel_;
+            int configurableContextsMaxLevel_;
             inline std::string getConfigurableContextsMaxLevelName() const
                 { return "outputContextsLevel" + this->name_; }
 

Modified: code/branches/output/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputDefinitions.h	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/util/output/OutputDefinitions.h	2011-07-31 21:42:55 UTC (rev 8808)
@@ -37,28 +37,31 @@
 
 namespace orxonox
 {
-    typedef uint16_t OutputLevel;
-
     namespace level
     {
-        static const OutputLevel all              = 0xFFFF;
-        static const OutputLevel none             = 0x0000;
+        enum OutputLevel
+        {
+            all              = 0xFFFF,
+            none             = 0x0000,
 
-        static const OutputLevel message          = 0x0001;
-        static const OutputLevel debug_output     = 0x0002;
-        static const OutputLevel user_error       = 0x0004;
-        static const OutputLevel user_warning     = 0x0008;
-        static const OutputLevel user_status      = 0x0010;
-        static const OutputLevel user_info        = 0x0020;
-        static const OutputLevel internal_error   = 0x0040;
-        static const OutputLevel internal_warning = 0x0080;
-        static const OutputLevel internal_status  = 0x0100;
-        static const OutputLevel internal_info    = 0x0200;
-        static const OutputLevel verbose          = 0x0400;
-        static const OutputLevel verbose_more     = 0x0800;
-        static const OutputLevel verbose_ultra    = 0x1000;
+            message          = 0x0001,
+            debug_output     = 0x0002,
+            user_error       = 0x0004,
+            user_warning     = 0x0008,
+            user_status      = 0x0010,
+            user_info        = 0x0020,
+            internal_error   = 0x0040,
+            internal_warning = 0x0080,
+            internal_status  = 0x0100,
+            internal_info    = 0x0200,
+            verbose          = 0x0400,
+            verbose_more     = 0x0800,
+            verbose_ultra    = 0x1000
+        };
     }
 
+    using namespace level;
+
     typedef uint64_t OutputContext;
     typedef OutputContext (OutputContextFunction)();
 

Modified: code/branches/output/src/libraries/util/output/OutputListener.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputListener.cc	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/util/output/OutputListener.cc	2011-07-31 21:42:55 UTC (rev 8808)
@@ -47,17 +47,16 @@
 
     void OutputListener::setLevelMax(OutputLevel max)
     {
-        this->setLevelRange(level::debug_output, max);
+        this->setLevelRange(static_cast<OutputLevel>(0x1), max);
     }
 
     void OutputListener::setLevelRange(OutputLevel min, OutputLevel max)
     {
-        OutputLevel mask = 0;
-
-        for (OutputLevel level = min; level <= max; level = level << 1)
+        int mask = 0;
+        for (int level = min; level <= max; level = level << 1)
             mask |= level;
 
-        this->setLevelMask(mask);
+        this->setLevelMask(static_cast<OutputLevel>(mask));
     }
 
     void OutputListener::setLevelMask(OutputLevel mask)

Modified: code/branches/output/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputManager.cc	2011-07-31 19:09:23 UTC (rev 8807)
+++ code/branches/output/src/libraries/util/output/OutputManager.cc	2011-07-31 21:42:55 UTC (rev 8808)
@@ -37,7 +37,7 @@
 {
     OutputManager::OutputManager()
     {
-        this->combinedLevelMask_ = 0;
+        this->combinedLevelMask_ = level::none;
         this->combinedContextMask_ = 0;
     }
 
@@ -98,9 +98,10 @@
 
     void OutputManager::updateCombinedLevelMask()
     {
-        this->combinedLevelMask_ = 0;
+        int mask = 0;
         for (size_t i = 0; i < this->listeners_.size(); ++i)
-            this->combinedLevelMask_ |= this->listeners_[i]->getLevelMask();
+            mask |= this->listeners_[i]->getLevelMask();
+        this->combinedLevelMask_ = static_cast<OutputLevel>(mask);
     }
 
     void OutputManager::updateCombinedContextMask()




More information about the Orxonox-commit mailing list