X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkInterpreter.h;h=a5e66f424f3ec0e18ce7c3a903ed2f1414c489cc;hb=b253812964e57b9592fe64bb3bc97f2aac72d3a7;hp=851a8aae3b72b38bfcd5073f5399dc3192505fac;hpb=9244821a79f4853a78564d37b993b48d4b2ad4e9;p=bbtk.git diff --git a/kernel/src/bbtkInterpreter.h b/kernel/src/bbtkInterpreter.h index 851a8aa..a5e66f4 100644 --- a/kernel/src/bbtkInterpreter.h +++ b/kernel/src/bbtkInterpreter.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.h,v $ $ Language: C++ - Date: $Date: 2008/02/05 08:25:22 $ - Version: $Revision: 1.8 $ + Date: $Date: 2008/03/14 14:58:53 $ + Version: $Revision: 1.14 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,6 +36,11 @@ namespace bbtk { + +#ifdef _USE_WXWIDGETS_ + class WxConsole; +#endif + class BBTK_EXPORT Interpreter { @@ -58,7 +63,7 @@ namespace bbtk cConfig, // JPR cReset, // EED cAuthor, - cKeyword, // JPR + cCategory, // JPR cDescription, cHelp, cMessage, @@ -75,7 +80,7 @@ namespace bbtk /// The structure storing the informations on a command typedef struct { - std::string keyword; + std::string category; int argmin, argmax; CommandCodeType code; std::string syntax; @@ -92,8 +97,6 @@ namespace bbtk /// Destructor ~Interpreter(); - static Interpreter* mGlobalInterpreter; - /// Launches a command line interpreter (with a prompt) void CommandLineInterpreter(); @@ -113,8 +116,7 @@ namespace bbtk void SetDialogMode(DialogModeType t) { mExecuter->SetDialogMode(t); } /// Runs the interpretation of a file - void InterpretFile( const std::string& filename, - bool use_configuration_file=true); + void InterpretFile( const std::string& filename); /// Interprets a line (either from a file or typed interactively) void InterpretLine( const std::string& line, bool &insideComment ); @@ -131,8 +133,10 @@ namespace bbtk CommandInfoType& info ); /// Switch to the interpretation of a file - void SwitchToFile( const std::string& filename, - bool use_configuration_file=true); + void SwitchToFile( const std::string& filename ); + + /// Switch to the interpretation of a stringstream + void SwitchToStream( std::stringstream* stream ); /// Closes the currently open file void CloseCurrentFile(); @@ -167,27 +171,49 @@ namespace bbtk /// Sets the bool that indicates wether we are in command line context void SetCommandLine(bool v = true) { mCommandLine = v; } +#ifdef _USE_WXWIDGETS_ + /// Sets the WxConsole that created the interpreter (if any) + void SetWxConsole(WxConsole* c) { mWxConsole = c; } + /// Gets the WxConsole that created the interpreter (if any) + WxConsole* GetWxConsole() { return mWxConsole; } + /// Gets the WxConsole that created the interpreter (if any) - const + const WxConsole* GetWxConsole() const { return mWxConsole; } +#endif + + /// Gets the Executer + VirtualExec* GetExecuter() { return mExecuter; } + /// Gets the Executer (const) + const VirtualExec* GetExecuter() const { return mExecuter; } + private: - void LoadScript( std::string fullPathScriptName); + /// Opens the file fullPathScriptName + /// includeScriptName is the name as given to the include command + void LoadScript( std::string fullPathScriptName, + std::string includeScriptName); private: //================================================================== // ATTRIBUTES - /// The factory - // bbtk::Factory* mFactory; - - /// The command executer + /// The command executer used bbtk::VirtualExec* mExecuter; - /// Vector of opened files - std::vector mFile; +#ifdef _USE_WXWIDGETS_ + /// The WxConsole which uses the interpreter (0 if none) + bbtk::WxConsole* mWxConsole; +#endif - /// Vector of names of open files + /// Vector of open files / buffers (can be stringstream) + std::vector mFile; + + /// Vector of names of open files with full path (as open) std::vector mFileName; + /// Vector of names of open files as given to the include command + std::vector mIncludeFileName; + /// Stores the current line number in each open file std::vector mLine; @@ -200,7 +226,9 @@ namespace bbtk /// The history of commands std::deque< char* > mHistory; + int bufferNb; }; + // EO class Interpreter // The "Quit" exception