From: guigues Date: Wed, 23 Apr 2008 08:34:06 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: r0.6.1~64 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d33068ec2ab1ca79aaa44809df32dc9e39c9c0a3;p=bbtk.git *** empty log message *** --- diff --git a/kernel/appli/bbi/bbi.cxx b/kernel/appli/bbi/bbi.cxx index 3c00bb8..42d5ec5 100644 --- a/kernel/appli/bbi/bbi.cxx +++ b/kernel/appli/bbi/bbi.cxx @@ -15,15 +15,14 @@ static const wxCmdLineEntryDesc cmdLineDesc[] = { - { wxCMD_LINE_SWITCH, _T("M"), _T("Memory debug"), _T("Display memory debug message on exit") }, - { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Debug messages on (message All 9)") }, - { wxCMD_LINE_SWITCH, _T("c"), _T("command"), _T("turn to command line mode after file(s) processing") }, - { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet") }, - { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("print help") }, - { wxCMD_LINE_SWITCH, _T("g"), _T("graphical-dialog"), _T("prompts the user for the parameters values using dialog boxes") }, - { wxCMD_LINE_SWITCH, _T("t"), _T("text-dialog"), _T("prompts the user for the parameters values in text mode") }, - { wxCMD_LINE_SWITCH, _T("n"), _T("no-command"), _T("do not show command window except on error") }, - { wxCMD_LINE_SWITCH, _T("N"), _T("no-command-at-all"), _T("do not show command window even on error") }, + { wxCMD_LINE_SWITCH, _T("M"), _T("Memory debug"), _T("Display memory debug message on exit ('object -S')") }, + { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("all messages on ('message all 9')") }, + { wxCMD_LINE_SWITCH, _T("c"), _T("console"), _T("open a console") }, + { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet ('message max 0')") }, + { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("print help on bbi or on workspace defined if any") }, + { wxCMD_LINE_SWITCH, _T("g"), _T("graphical-dialog"), _T("prompts the user for the parameter values using graphical dialog") }, + { wxCMD_LINE_SWITCH, _T("t"), _T("text-dialog"), _T("prompts the user for the parameter values in text mode") }, + { wxCMD_LINE_SWITCH, _T("N"), _T("no-console"), _T("do not show console (even on error)") }, { wxCMD_LINE_PARAM, NULL, NULL, _T("input_file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, { wxCMD_LINE_NONE } }; @@ -45,14 +44,13 @@ public: bbtk::Interpreter* I; int argc; std::vector argv; - bool command; + bool console; bool debug; bool quiet; bool help; bool graphical_dialog; bool text_dialog; - bool no_command; - bool no_command_at_all; + bool no_console; std::map param_map; std::vector input_file; @@ -79,9 +77,7 @@ bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser) help = ( parser.Found(_T("h")) ); graphical_dialog = ( parser.Found(_T("g")) ); text_dialog = ( parser.Found(_T("t")) ); - no_command_at_all = ( parser.Found(_T("N")) ); - no_command = ( parser.Found(_T("n")) || no_command_at_all ); - + no_console = ( parser.Found(_T("N")) ); // parse the arguments and consider those which contain a "=" // as set input commands, other as files @@ -112,9 +108,9 @@ bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser) parser.Usage(); } - command = ( parser.Found(_T("c")) || + console = ( parser.Found(_T("c")) || ((input_file.size() == 0) && - (!no_command) && + (!no_console) && (!usage) ) ); @@ -124,6 +120,9 @@ bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser) + + + // ---------------------------------------------------------------------------- // The `main program' equivalent, creating the windows and returning the // main frame @@ -136,13 +135,15 @@ bool wxBBIApp::OnInit( ) setlocale(LC_NUMERIC, "C"); #endif - if (quiet) bbtk::MessageManager::SetMessageLevel("All",0); - if (debug) bbtk::MessageManager::SetMessageLevel("All",9); + + if (quiet) bbtk::MessageManager::SetMessageLevel("max",0); + if (debug) bbtk::MessageManager::SetMessageLevel("all",9); bbtk::WxGUIConsole *I = new bbtk::WxGUIConsole(0,_T("bbi"),wxSize(800,600)); SetTopWindow(I); - if (!no_command) I->Show(true); + if (console) I->Show(true); + I->SetInputs(param_map); @@ -160,7 +161,7 @@ bool wxBBIApp::OnInit( ) error = ! I->InterpretFile(*i); if (error) break; } - bool show_on_error = error && ! no_command_at_all; + bool show_on_error = error && ! no_console; if (show_on_error) I->Show(); I->SetNoExecMode(false); @@ -171,7 +172,7 @@ bool wxBBIApp::OnInit( ) I->GetInterpreter()->GetExecuter()->GetFactory()->HelpBlackBox("workspace",package,false); } - if (!(show_on_error || command || bbtk::Wx::IsSomeWindowShown() )) + if (!(show_on_error || console || bbtk::Wx::IsSomeWindowShown() )) { I->Close(); } diff --git a/kernel/src/bbtkMessageManager.cxx b/kernel/src/bbtkMessageManager.cxx index 31c486b..56c3227 100644 --- a/kernel/src/bbtkMessageManager.cxx +++ b/kernel/src/bbtkMessageManager.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkMessageManager.cxx,v $ Language: C++ - Date: $Date: 2008/04/22 14:30:25 $ - Version: $Revision: 1.8 $ + Date: $Date: 2008/04/23 08:34:06 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -25,10 +25,18 @@ namespace bbtk { MessageManager::MessageManager() - : mMaxMessageLength(8), mAllLevel(0) + : mMaxMessageLength(8)//, mAllLevel(0), mMaxLevel(9) { std::string key; + key ="all"; + mMessageLevel[key] = 0; + mMessageHelp[key] = "Minimum level for all kind of messages"; + if (mMaxMessageLength::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=<" < unregistered"); } - } + } - - - + + + int MessageManager::GetMessageLevel(std::string key) { - int l = GetInstance()->mAllLevel; + int l = GetInstance()->mMessageLevel["all"]; std::map::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; } @@ -162,10 +164,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::iterator i; std::map::iterator j; diff --git a/kernel/src/bbtkMessageManager.h b/kernel/src/bbtkMessageManager.h index 0bf85d0..496a225 100644 --- a/kernel/src/bbtkMessageManager.h +++ b/kernel/src/bbtkMessageManager.h @@ -413,7 +413,6 @@ namespace bbtk std::map mMessageLevel; std::map mMessageHelp; unsigned int mMaxMessageLength; - int mAllLevel; }; //=========================================================== diff --git a/kernel/src/bbtkSystem.cxx b/kernel/src/bbtkSystem.cxx new file mode 100644 index 0000000..3b6da4b --- /dev/null +++ b/kernel/src/bbtkSystem.cxx @@ -0,0 +1,16 @@ +#include "bbtkSystem.h" + +namespace bbtk +{ + +#ifdef _WIN32 + int System::HasTTY() { return false; } +#else +#include + int System::HasTTY() + { + return isatty(fileno(stdin)); + } +#endif + +} // namespace bbtk diff --git a/kernel/src/bbtkSystem.h b/kernel/src/bbtkSystem.h index f59df06..f9f22eb 100644 --- a/kernel/src/bbtkSystem.h +++ b/kernel/src/bbtkSystem.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkSystem.h,v $ Language: C++ - Date: $Date: 2008/03/11 18:46:47 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008/04/23 08:34:06 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -71,7 +71,8 @@ //----------------------------------------------------------------------------- // Micro$oft shared library related stuff // -// all the classes should be defined as : +// all the classes that must be visible outside the bbtk library +// should be defined as : // class BBTK_EXPORT ClassName // instead of : // class ClassName @@ -214,6 +215,21 @@ typedef unsigned int uint32_t; +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +namespace bbtk +{ + + /// System related stuff + struct System + { + /// returns true iff the program has a tty + static int HasTTY(); + }; + +} // namespace bbtk //----------------------------------------------------------------------------- #endif