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 }
};
bbtk::Interpreter* I;
int argc;
std::vector<std::string> 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<std::string,std::string> param_map;
std::vector<std::string> input_file;
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
parser.Usage();
}
- command = ( parser.Found(_T("c")) ||
+ console = ( parser.Found(_T("c")) ||
((input_file.size() == 0) &&
- (!no_command) &&
+ (!no_console) &&
(!usage) ) );
+
+
+
// ----------------------------------------------------------------------------
// The `main program' equivalent, creating the windows and returning the
// main frame
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);
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);
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();
}
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
{
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<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";
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;
}
<< 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;
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
//-----------------------------------------------------------------------------
// 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
+//-----------------------------------------------------------------------------
+
+
+//-----------------------------------------------------------------------------
+namespace bbtk
+{
+
+ /// System related stuff
+ struct System
+ {
+ /// returns true iff the program has a tty
+ static int HasTTY();
+ };
+
+} // namespace bbtk
//-----------------------------------------------------------------------------
#endif