X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkInterpreter.h;h=96fe7dc56e41c58e48347e185891b1956753f96f;hb=f3d05516965aece323133928f72d85e38c2b0b71;hp=490882733c83f4f9ac3b6ed7ac9f9123d4597ca4;hpb=fb65ef0feb38b84723ea928ec3d3c056ba26274e;p=bbtk.git diff --git a/kernel/src/bbtkInterpreter.h b/kernel/src/bbtkInterpreter.h index 4908827..96fe7dc 100644 --- a/kernel/src/bbtkInterpreter.h +++ b/kernel/src/bbtkInterpreter.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.h,v $ Language: C++ - Date: $Date: 2008/12/12 12:11:21 $ - Version: $Revision: 1.38 $ + Date: $Date: 2008/12/15 09:04:47 $ + Version: $Revision: 1.39 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -46,6 +46,10 @@ #include #include +// Signal/slot mechanism for 'break' commands +//#include +//#include + namespace bbtk { @@ -70,20 +74,20 @@ namespace bbtk //======================================================================= - class BBTK_EXPORT InterpreterError : public Exception + class BBTK_EXPORT InterpreterException : public Exception { public: - InterpreterError( const std::string& message, + InterpreterException( const std::string& message, bool in_script_file, const std::string& script_file, int script_line ); - InterpreterError( const Exception& excep, + InterpreterException( const Exception& excep, bool in_script_file, const std::string& script_file, int script_line ); - ~InterpreterError() throw() {} + ~InterpreterException() throw() {} bool IsInScriptFile() const { return mInScriptFile; } const std::string& GetScriptFile() const { return mScriptFile; } @@ -95,6 +99,37 @@ namespace bbtk }; //======================================================================= + /* + //======================================================================= + // The "Quit" exception + class BBTK_EXPORT QuitException : public InterpreterError + { + public: + QuitException( bool in_script_file, + const std::string& script_file, + int script_line + ) + : InterpreterError("QUIT",in_script_file,script_file,script_line) + {} + ~QuitException() throw() {} + }; + //======================================================================= + const std::string BREAK("BREAK"); + //======================================================================= + // The "Break" exception + class BBTK_EXPORT BreakException : public InterpreterError + { + public: + BreakException( bool in_script_file, + std::string script_file, + int script_line + ) + : InterpreterError(BREAK,in_script_file,script_file,script_line) + { std::cout << "BUILDING BREAK"< BreakSignalType; + typedef BreakSignalType::slot_function_type BreakCallbackType; + + // Adds a callback when 'break' command issued + void AddBreakObserver( BreakCallbackType ); + */ protected: /// The enumeration of command codes == Command name typedef enum { - cClear, + cBreak, // LG 12/12/08 : Stops the current script execution (if not exec frozen) - used in tutorial + debugging + cClear, // LG 12/12/08 : Clears the current complex black box (e.g. workspace) - used in tours cNew, cDelete, cConnect, @@ -217,7 +265,7 @@ namespace bbtk /// Interprets a line - void InterpretLine( const std::string& line, bool &insideComment ); + void DoInterpretLine( const std::string& line ); //, bool &insideComment ); /// Reads a line from prompt void GetLineFromPrompt( std::string& line ); @@ -279,6 +327,7 @@ namespace bbtk void Debug(const std::string& arg); + private: /// Constructor @@ -294,7 +343,7 @@ namespace bbtk std::string includeScriptName); /// - void CatchInterpreterException( const InterpreterError& e ); + void CatchInterpreterException( const InterpreterException& e ); void CatchBbtkException( const bbtk::Exception& e ); void CatchStdException( const std::exception& e ); void CatchUnknownException(); @@ -334,25 +383,29 @@ namespace bbtk /// Are we in a command line context ? bool mCommandLine; + /// Are we inside a commented-out zone ? + bool mInsideComment; + + /// The current interpreter status + ExitStatus mStatus; + /// The history of commands std::deque< char* > mHistory; - int bufferNb; + int bufferNb; bool mThrow; - protected: - ~Interpreter(); + /// The break signal + // BreakSignalType mBreakSignal; + + protected: + ~Interpreter(); }; // EO class Interpreter - // The "Quit" exception - struct QuitException : public bbtk::Exception - { - QuitException() : bbtk::Exception("Interpreter","","Quit") {} - }; } #endif