]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkMessageManager.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkMessageManager.cxx
index eede31b5e0b7d244c1b01f41af6844283b7c8fb8..314129343c5d47cdf49039085c97a6ed94b8fba9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkMessageManager.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/02/05 11:07:42 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2008/04/24 10:11:28 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -25,15 +25,23 @@ namespace bbtk
 {
 
   MessageManager::MessageManager() 
-    : mMaxMessageLength(8), mAllLevel(0) 
+    : mMaxMessageLength(8)//, mAllLevel(0), mMaxLevel(9)
     
   {
     std::string key;
-    key ="Core";
+    key ="all";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "Minimum level for all kind of messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key ="max";
+    mMessageLevel[key] = 9;
+    mMessageHelp[key] = "Maximum level for all kind of messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key ="Kernel";
     mMessageLevel[key] = 0;
     mMessageHelp[key] = "Messages generated by the core classes of the lib";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
-    key ="Process";
+    key ="process";
     mMessageLevel[key] = 0;
     mMessageHelp[key] = "Messages related to box processing";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
@@ -53,7 +61,7 @@ namespace bbtk
     mMessageLevel[key] = 1;
     mMessageHelp[key] = "Output messages";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
-    key = "Debug";
+    key = "debug";
     mMessageLevel[key] = 0;
     mMessageHelp[key] = "Debug messages";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
@@ -61,15 +69,35 @@ namespace bbtk
     mMessageLevel[key] = 0;
     mMessageHelp[key] = "Configuration related messages";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
-    key = "Data";
+    key = "data";
     mMessageLevel[key] = 0;
     mMessageHelp[key] = "Data related messages";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
-    key = "Wx";
+    key = "wx";
     mMessageLevel[key] = 0;
     mMessageHelp[key] = "Widgets related messages";
     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
-  }
+    key = "gui";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "Graphical user interface related messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key = "object";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "object memory related messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key = "package";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "Packages related messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key = "connection";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "Connections related messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+    key = "modified";
+    mMessageLevel[key] = 0;
+    mMessageHelp[key] = "Modified related messages";
+    if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+   }
 
 
 
@@ -104,37 +132,31 @@ namespace bbtk
                                              unsigned char level) 
   {
     std::map<std::string,int>::iterator i;
-    if (key==std::string("All")) {
-      GetInstance()->mAllLevel = level;
-      
-      for (i=GetInstance()->mMessageLevel.begin();
-          i!=GetInstance()->mMessageLevel.end();
-          ++i) 
-        (*i).second = level;
-      
-    }
-    else {
-      i = GetInstance()->mMessageLevel.find(key);
-      if (i!=GetInstance()->mMessageLevel.end()) {
+    i = GetInstance()->mMessageLevel.find(key);
+    if (i!=GetInstance()->mMessageLevel.end()) 
+      {
        (*i).second = level;
       }
-      else {
+    else 
+      {
        bbtkWarning("MessageManager::SetMessageLevel : message type=<"
                    <<key<<"> unregistered");
       }
-    }
+    
   }
-
-
-
+  
+  
+  
   int MessageManager::GetMessageLevel(std::string key) 
   {
-    int l = GetInstance()->mAllLevel;
+    int l = GetInstance()->mMessageLevel["all"];
     std::map<std::string,int>::iterator i = 
       GetInstance()->mMessageLevel.find(key);
     if (i!=GetInstance()->mMessageLevel.end()) {
       if ( (*i).second > l ) l = (*i).second;      
     }
+    int m = GetInstance()->mMessageLevel["max"];
+    if (l>m) l=m;
     return l;
   }
 
@@ -146,10 +168,11 @@ namespace bbtk
                << bbtkendl);
     bbtkMessage("Help",1, "Kind");
     for (int k=0;
-        k<(int)(GetInstance()->mMaxMessageLength-8);
-        k++) {
-      bbtkMessageCont("Help",1," "); 
-    }
+        k<(int)(GetInstance()->mMaxMessageLength-2);
+        k++) 
+      {
+       bbtkMessageCont("Help",1," "); 
+      }
     bbtkMessageCont("Help",1,"Level  Nature" << bbtkendl);
     std::map<std::string,int>::iterator i;
     std::map<std::string,std::string>::iterator j;