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 bool 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 ()
static std::string FormatKey (const std::string &key, int value)

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 412 of file bbtkMessageManager.h.


Constructor & Destructor Documentation

bbtk::MessageManager::MessageManager (  ) 

Definition at line 40 of file bbtkMessageManager.cxx.

References mMaxMessageLength, mMessageHelp, and mMessageLevel.

Referenced by GetInstance().

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 = "widget";
00090     mMessageLevel[key] = 0;
00091     mMessageHelp[key] = "Widgets related messages";
00092     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00093     key = "wx";
00094     mMessageLevel[key] = 0;
00095     mMessageHelp[key] = "wxWidgets related messages";
00096     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00097     key = "qt";
00098     mMessageLevel[key] = 0;
00099     mMessageHelp[key] = "Qt related messages";
00100     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00101     key = "gui";
00102     mMessageLevel[key] = 0;
00103     mMessageHelp[key] = "Graphical user interface related messages";
00104     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00105     key = "object";
00106     mMessageLevel[key] = 0;
00107     mMessageHelp[key] = "object memory related messages";
00108     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00109     key = "package";
00110     mMessageLevel[key] = 0;
00111     mMessageHelp[key] = "Packages related messages";
00112     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00113     key = "connection";
00114     mMessageLevel[key] = 0;
00115     mMessageHelp[key] = "Connections related messages";
00116     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00117     key = "change";
00118     mMessageLevel[key] = 0;
00119     mMessageHelp[key] = "Box i/o changes related messages";
00120     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00121     key = "code";
00122     mMessageLevel[key] = 0;
00123     mMessageHelp[key] = "If positive then codes of the messages are displayed";
00124     if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
00125     }

Here is the caller graph for this function:

bbtk::MessageManager::~MessageManager (  ) 

Definition at line 130 of file bbtkMessageManager.cxx.

00131   {
00132     //      std::cout << "~MessageManager"<<std::endl;
00133   }


Member Function Documentation

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

Definition at line 437 of file bbtkMessageManager.h.

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

std::string bbtk::MessageManager::FormatKey ( const std::string &  key,
int  value 
) [static]

Definition at line 222 of file bbtkMessageManager.cxx.

References GetInstance(), and mMessageLevel.

00224   {
00225     std::string s;
00226     if ( GetInstance()->mMessageLevel["code"] != 0 )
00227       {
00228         s = key.substr(0,4);
00229         std::stringstream ss;
00230         ss << value;
00231         //      s += " ";
00232         s += ss.str();
00233         s += "> ";
00234       }
00235     return s;
00236   }

Here is the call graph for this function:

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

Definition at line 137 of file bbtkMessageManager.cxx.

References MessageManager().

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

00138   { 
00139     static MessageManager* m = 0;
00140     if (!m) m = new MessageManager();
00141     return m; 
00142   }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 177 of file bbtkMessageManager.cxx.

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

Referenced by bbtk::Exception::Print().

00178   {
00179     int l = GetInstance()->mMessageLevel["all"];
00180     std::map<std::string,int>::iterator i = 
00181       GetInstance()->mMessageLevel.find(key);
00182     if (i!=GetInstance()->mMessageLevel.end()) {
00183       if ( (*i).second > l ) l = (*i).second;      
00184     }
00185     int m = GetInstance()->mMessageLevel["max"];
00186     if (l>m) l=m;
00187     return l;
00188   }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 432 of file bbtkMessageManager.h.

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

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

Definition at line 430 of file bbtkMessageManager.h.

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

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

Definition at line 435 of file bbtkMessageManager.h.

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

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

Definition at line 192 of file bbtkMessageManager.cxx.

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

Referenced by bbtk::Executer::HelpMessages().

00193   {
00194     bbtkMessage("help",1,"================ Messages =================" 
00195                 << bbtkendl);
00196     bbtkMessage("help",1, "Kind");
00197     for (int k=0;
00198          k<(int)(GetInstance()->mMaxMessageLength-2);
00199          k++) 
00200       {
00201         bbtkMessageCont("help",1," "); 
00202       }
00203     bbtkMessageCont("help",1,"Level  Nature" << bbtkendl);
00204     std::map<std::string,int>::iterator i;
00205     std::map<std::string,std::string>::iterator j;  
00206     for (i=GetInstance()->mMessageLevel.begin(),
00207            j=GetInstance()->mMessageHelp.begin();
00208          i!=GetInstance()->mMessageLevel.end();++i,++j) {
00209       bbtkMessage("help",1, (*i).first);
00210       for (int k=0;
00211            k<(int)(GetInstance()->mMaxMessageLength+2-(*i).first.length());
00212            k++) {
00213         bbtkMessageCont("help",1," ");
00214       }
00215       bbtkMessageCont("help",1, (*i).second << "\t" 
00216                       << (*j).second << bbtkendl);
00217     }
00218     bbtkMessage("help",1,"===========================================" 
00219                 << bbtkendl);
00220   }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 144 of file bbtkMessageManager.cxx.

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

Referenced by bbtk::InterpreterVirtual::Init().

00147   {
00148     GetInstance()->mMessageLevel[key] = default_level;
00149     GetInstance()->mMessageHelp[key] = help;
00150     if (GetInstance()->mMaxMessageLength<key.length()) 
00151       GetInstance()->mMaxMessageLength = key.length();
00152     return true;
00153   }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 439 of file bbtkMessageManager.h.

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

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

Definition at line 158 of file bbtkMessageManager.cxx.

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

Referenced by wxBBIApp::OnInit(), and WxProcessCmdLine::Process().

00160   {
00161     std::map<std::string,int>::iterator i;
00162     i = GetInstance()->mMessageLevel.find(key);
00163     if (i!=GetInstance()->mMessageLevel.end()) 
00164       {
00165         (*i).second = level;
00166       }
00167     else 
00168       {
00169         bbtkWarning("MessageManager::SetMessageLevel : message type=<"
00170                     <<key<<"> unregistered");
00171       }
00172     
00173   }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 448 of file bbtkMessageManager.h.

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

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

Definition at line 447 of file bbtkMessageManager.h.

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

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


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

Generated on Thu May 31 14:14:54 2012 for BBTK by  doxygen 1.5.7.1