X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkInterpreter.h;h=483068bf8935c230eb008e9b08a5c6ef09941029;hb=7a26044dd46cb80ab90ee1f63d3b4d8ce52b2d39;hp=48bd0ae2c22cd492ce927a5faf544a458cbb2807;hpb=c2a4b1893412e50a3d9abff221938a2d16c4a7cb;p=bbtk.git diff --git a/kernel/src/bbtkInterpreter.h b/kernel/src/bbtkInterpreter.h index 48bd0ae..483068b 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/04/09 11:16:57 $ - Version: $Revision: 1.25 $ + Date: $Date: 2008/04/22 09:40:11 $ + Version: $Revision: 1.28 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -28,6 +28,7 @@ #define __bbtkInterpreter_h__ #include "bbtkVirtualExec.h" +#include "bbtkExecuter.h" #include #include @@ -39,6 +40,7 @@ namespace bbtk class WxConsole; #endif + //======================================================================= class BBTK_EXPORT InterpreterUser { public: @@ -50,8 +52,11 @@ namespace bbtk }; + //======================================================================= - /// + + + //======================================================================= class BBTK_EXPORT InterpreterError : public Exception { public: @@ -75,67 +80,16 @@ namespace bbtk std::string mScriptFile; int mScriptLine; }; + //======================================================================= - /// - class BBTK_EXPORT Interpreter + //======================================================================= + class BBTK_EXPORT Interpreter : public Object { - - private: - - /// The enumeration of command codes == Command name - typedef enum - { - cNew, - cDelete, - cConnect, - cExec, - cPackage, - cEndPackage, - cDefine, - cEndDefine, - cInput, - cOutput, - cSet, - cConfig, // JPR - cReset, // EED - cAuthor, - cCategory, // JPR - cDescription, - cHelp, - cMessage, - cInclude, - cQuit, - cLoad, - cUnload, - cGraph, - cPrint, - cIndex, - cKind, // LG - cNewGUI, // LG - cWorkspace // LG - } CommandCodeType; - - /// The structure storing the informations on a command - typedef struct - { - std::string keyword; - int argmin, argmax; - CommandCodeType code; - std::string syntax; - std::string help; - } CommandInfoType; - - /// The type of dictionnary of commands - typedef std::map CommandDictType; - + BBTK_OBJECT_INTERFACE(Interpreter); + typedef Object Superclass; public: - /// Constructor - Interpreter(const std::string& cpp_file = ""); - - /// Destructor - ~Interpreter(); - + static Pointer New(const std::string& cpp_file = ""); typedef enum { @@ -163,17 +117,18 @@ namespace bbtk /// Sets the inputs of the workspace : /// the map is passed as is to the Executer void SetInputs(const std::map& m) - { mExecuter->SetInputs(m); } + { mVirtualExecuter->SetInputs(m); } /// Puts the executer in "no exec" mode, /// which creates but does not execute pipelines. - void SetNoExecMode(bool b) { mExecuter->SetNoExecMode(b); } + void SetNoExecMode(bool b) { mVirtualExecuter->SetNoExecMode(b); } /// //typedef Executer::DialogModeType DialogModeType; typedef VirtualExec::DialogModeType DialogModeType; - void SetDialogMode(DialogModeType t) { mExecuter->SetDialogMode(t); } + void SetDialogMode(DialogModeType t) + { mVirtualExecuter->SetDialogMode(t); } /// Sets the bool that indicates wether we are in command line context void SetCommandLine(bool v = true) { mCommandLine = v; } @@ -191,12 +146,59 @@ namespace bbtk #endif /// Gets the Executer - VirtualExec* GetExecuter() { return mExecuter; } - /// Gets the Executer (const) - const VirtualExec* GetExecuter() const { return mExecuter; } + VirtualExec::Pointer GetExecuter() const { return mVirtualExecuter; } protected: + + /// The enumeration of command codes == Command name + typedef enum + { + cNew, + cDelete, + cConnect, + cExec, + cPackage, + cEndPackage, + cDefine, + cEndDefine, + cInput, + cOutput, + cSet, + cConfig, // JPR + cReset, // EED + cAuthor, + cCategory, // JPR + cDescription, + cHelp, + cMessage, + cInclude, + cQuit, + cLoad, + cUnload, + cGraph, + cPrint, + cIndex, + cKind, // LG + cNewGUI, // LG + cWorkspace, // LG + cObject + } CommandCodeType; + + /// The structure storing the informations on a command + typedef struct + { + std::string keyword; + int argmin, argmax; + CommandCodeType code; + std::string syntax; + std::string help; + } CommandInfoType; + + /// The type of dictionnary of commands + typedef std::map CommandDictType; + + /// Interprets a line void InterpretLine( const std::string& line, bool &insideComment ); @@ -223,6 +225,9 @@ namespace bbtk /// Closes all open files void CloseAllFiles(); + /// Resets all + void Reset(); + /// Displays help (entry point of any help) void Help(const std::vector& words); @@ -255,8 +260,13 @@ namespace bbtk void NewGUI(const std::string& box, const std::string& instanceName); + void ObjectInfo(const std::string& name); + private: + /// Constructor + Interpreter(const std::string& cpp_file = ""); + /// Opens the file fullPathScriptName /// includeScriptName is the name as given to the include command void LoadScript( std::string fullPathScriptName, @@ -267,13 +277,14 @@ namespace bbtk void CatchStdException( const std::exception& e ); void CatchUnknownException(); - private: + //================================================================== // ATTRIBUTES /// The command executer used - bbtk::VirtualExec* mExecuter; + bbtk::VirtualExec::Pointer mVirtualExecuter; + bbtk::Executer::WeakPointer mRealExecuter; /// The user of the interpreter (0 if none) bbtk::InterpreterUser* mUser;