bbtk::MessageManager Class Reference

Manages the messages displayed by bbtk. More...

#include <bbtkMessageManager.h>

List of all members.

Public Member Functions

 MessageManager ()
 ~MessageManager ()

Static Public Member Functions

static MessageManagerGetInstance ()
static void RegisterMessageType (std::string key, std::string help, unsigned char default_level=9)
static void SetMessageLevel (std::string key, unsigned char level)
static int GetMessageLevel (std::string key)
static std::string & GetTab ()
static std::string GetSpace (int n)
static void IncTab ()
static void DecTab ()
static void ResetTab ()
static void PrintInfo ()

Private Attributes

std::map< std::string, int > mMessageLevel
std::map< std::string,
std::string > 
mMessageHelp
unsigned int mMaxMessageLength


Detailed Description

Manages the messages displayed by bbtk.

Definition at line 411 of file bbtkMessageManager.h.


Constructor & Destructor Documentation

bbtk::MessageManager::MessageManager (  ) 

Definition at line 40 of file bbtkMessageManager.cxx.

References mMaxMessageLength, mMessageHelp, and mMessageLevel.

00041     : mMaxMessageLength(8)//, mAllLevel(0), mMaxLevel(9)
00042     
00043   {
00044     std::string key;
00045     key ="all";
00046     mMessageLevel[key] = 0;
00047     mMessageHelp[key] = "Minimum level for all kind of messages";
00048     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00049     key ="max";
00050     mMessageLevel[key] = 9;
00051     mMessageHelp[key] = "Maximum level for all kind of messages";
00052     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00053     key ="Kernel";
00054     mMessageLevel[key] = 0;
00055     mMessageHelp[key] = "Messages generated by the core classes of the lib";
00056     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00057     key ="process";
00058     mMessageLevel[key] = 0;
00059     mMessageHelp[key] = "Messages related to box processing";
00060     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00061     key = "Help";
00062     mMessageLevel[key] = 1;
00063     mMessageHelp[key] = "Help messages";
00064     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00065     key = "Error";
00066     mMessageLevel[key] = 0;
00067     mMessageHelp[key] = "Error messages";
00068     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00069     key = "Warning";
00070     mMessageLevel[key] = 1;
00071     mMessageHelp[key] = "Warning messages";
00072     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00073     key = "Output";
00074     mMessageLevel[key] = 1;
00075     mMessageHelp[key] = "Output messages";
00076     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00077     key = "debug";
00078     mMessageLevel[key] = 0;
00079     mMessageHelp[key] = "Debug messages";
00080     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00081     key = "Config";
00082     mMessageLevel[key] = 0;
00083     mMessageHelp[key] = "Configuration related messages";
00084     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00085     key = "data";
00086     mMessageLevel[key] = 0;
00087     mMessageHelp[key] = "Data related messages";
00088     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00089     key = "wx";
00090     mMessageLevel[key] = 0;
00091     mMessageHelp[key] = "Widgets related messages";
00092     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00093     key = "gui";
00094     mMessageLevel[key] = 0;
00095     mMessageHelp[key] = "Graphical user interface related messages";
00096     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00097     key = "object";
00098     mMessageLevel[key] = 0;
00099     mMessageHelp[key] = "object memory related messages";
00100     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00101     key = "package";
00102     mMessageLevel[key] = 0;
00103     mMessageHelp[key] = "Packages related messages";
00104     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00105     key = "connection";
00106     mMessageLevel[key] = 0;
00107     mMessageHelp[key] = "Connections related messages";
00108     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00109     key = "modified";
00110     mMessageLevel[key] = 0;
00111     mMessageHelp[key] = "Modified related messages";
00112     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00113    }

bbtk::MessageManager::~MessageManager (  ) 

Definition at line 118 of file bbtkMessageManager.cxx.

00119   {
00120     //      std::cout << "~MessageManager"<<std::endl;
00121   }


Member Function Documentation

MessageManager * bbtk::MessageManager::GetInstance (  )  [static]

Definition at line 125 of file bbtkMessageManager.cxx.

Referenced by GetMessageLevel(), PrintInfo(), RegisterMessageType(), and SetMessageLevel().

00126   { 
00127     static MessageManager* m = 0;
00128     if (!m) m = new MessageManager();
00129     return m; 
00130   }

Here is the caller graph for this function:

void bbtk::MessageManager::RegisterMessageType ( std::string  key,
std::string  help,
unsigned char  default_level = 9 
) [static]

Definition at line 132 of file bbtkMessageManager.cxx.

References GetInstance(), mMaxMessageLength, mMessageHelp, and mMessageLevel.

00135   {
00136     GetInstance()->mMessageLevel[key] = default_level;
00137     GetInstance()->mMessageHelp[key] = help;
00138     if (GetInstance()->mMaxMessageLength<key.length()) 
00139       GetInstance()->mMaxMessageLength = key.length();
00140   }

Here is the call graph for this function:

void bbtk::MessageManager::SetMessageLevel ( std::string  key,
unsigned char  level 
) [static]

Definition at line 144 of file bbtkMessageManager.cxx.

References bbtkWarning, GetInstance(), bbtk::i, and mMessageLevel.

00146   {
00147     std::map<std::string,int>::iterator i;
00148     i = GetInstance()->mMessageLevel.find(key);
00149     if (i!=GetInstance()->mMessageLevel.end()) 
00150       {
00151         (*i).second = level;
00152       }
00153     else 
00154       {
00155         bbtkWarning("MessageManager::SetMessageLevel : message type=<"
00156                     <<key<<"> unregistered");
00157       }
00158     
00159   }

Here is the call graph for this function:

int bbtk::MessageManager::GetMessageLevel ( std::string  key  )  [static]

Definition at line 163 of file bbtkMessageManager.cxx.

References GetInstance(), bbtk::i, and mMessageLevel.

00164   {
00165     int l = GetInstance()->mMessageLevel["all"];
00166     std::map<std::string,int>::iterator i = 
00167       GetInstance()->mMessageLevel.find(key);
00168     if (i!=GetInstance()->mMessageLevel.end()) {
00169       if ( (*i).second > l ) l = (*i).second;      
00170     }
00171     int m = GetInstance()->mMessageLevel["max"];
00172     if (l>m) l=m;
00173     return l;
00174   }

Here is the call graph for this function:

static std::string& bbtk::MessageManager::GetTab (  )  [inline, static]

Definition at line 429 of file bbtkMessageManager.h.

00429 { static std::string s; return s; }

static std::string bbtk::MessageManager::GetSpace ( int  n  )  [inline, static]

Definition at line 431 of file bbtkMessageManager.h.

00431                                      { 
00432       std::string s; s.insert(0,"                ",n); return s; }

static void bbtk::MessageManager::IncTab (  )  [inline, static]

Definition at line 434 of file bbtkMessageManager.h.

00434 { GetTab() += std::string(" "); }

static void bbtk::MessageManager::DecTab (  )  [inline, static]

Definition at line 436 of file bbtkMessageManager.h.

00436 { GetTab() = GetTab().substr(0,GetTab().length()-1); }

static void bbtk::MessageManager::ResetTab (  )  [inline, static]

Definition at line 438 of file bbtkMessageManager.h.

00438 { GetTab() = std::string(""); }

void bbtk::MessageManager::PrintInfo (  )  [static]

Definition at line 178 of file bbtkMessageManager.cxx.

References bbtkendl, bbtkMessage, bbtkMessageCont, GetInstance(), bbtk::i, mMaxMessageLength, mMessageHelp, and mMessageLevel.

00179   {
00180     bbtkMessage("Help",1,"================ Messages =================" 
00181                 << bbtkendl);
00182     bbtkMessage("Help",1, "Kind");
00183     for (int k=0;
00184          k<(int)(GetInstance()->mMaxMessageLength-2);
00185          k++) 
00186       {
00187         bbtkMessageCont("Help",1," "); 
00188       }
00189     bbtkMessageCont("Help",1,"Level  Nature" << bbtkendl);
00190     std::map<std::string,int>::iterator i;
00191     std::map<std::string,std::string>::iterator j;  
00192     for (i=GetInstance()->mMessageLevel.begin(),
00193            j=GetInstance()->mMessageHelp.begin();
00194          i!=GetInstance()->mMessageLevel.end();++i,++j) {
00195       bbtkMessage("Help",1, (*i).first);
00196       for (int k=0;
00197            k<(int)(GetInstance()->mMaxMessageLength+2-(*i).first.length());
00198            k++) {
00199         bbtkMessageCont("Help",1," ");
00200       }
00201       bbtkMessageCont("Help",1, (*i).second << "\t" 
00202                       << (*j).second << bbtkendl);
00203     }
00204     bbtkMessage("Help",1,"===========================================" 
00205                 << bbtkendl);
00206   }

Here is the call graph for this function:


Member Data Documentation

std::map<std::string,int> bbtk::MessageManager::mMessageLevel [private]

std::map<std::string,std::string> bbtk::MessageManager::mMessageHelp [private]

Definition at line 444 of file bbtkMessageManager.h.

Referenced by MessageManager(), PrintInfo(), and RegisterMessageType().

unsigned int bbtk::MessageManager::mMaxMessageLength [private]

Definition at line 445 of file bbtkMessageManager.h.

Referenced by MessageManager(), PrintInfo(), and RegisterMessageType().


The documentation for this class was generated from the following files:

Generated on Wed Nov 12 11:38:49 2008 for BBTK by  doxygen 1.5.6