]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.h
=== MAJOR RELEASE ====
[bbtk.git] / kernel / src / bbtkInterpreter.h
index bf40302851bed3b2edff02f1ba21a41749dd7f18..b5ca18f3d168b349e071155f4eb53a76c83d8b41 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.h,v $ $
   Language:  C++
-  Date:      $Date: 2008/04/08 06:59:30 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2008/04/18 12:59:15 $
+  Version:   $Revision: 1.26 $
 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,6 +39,7 @@ namespace bbtk
   class WxConsole;
 #endif
   
+  //=======================================================================
   class BBTK_EXPORT InterpreterUser
   {
   public: 
@@ -50,8 +51,11 @@ namespace bbtk
 
 
   };
+  //=======================================================================
 
-  ///
+
+
+  //=======================================================================
   class BBTK_EXPORT InterpreterError : public Exception
   {
   public:
@@ -75,67 +79,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<std::string,CommandInfoType> 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 
       {
@@ -191,12 +144,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 mExecuter; }
 
 
   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<std::string,CommandInfoType> CommandDictType;
+
+
     /// Interprets a line 
     void InterpretLine( const std::string& line, bool &insideComment );
 
@@ -255,8 +255,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 +272,13 @@ namespace bbtk
     void CatchStdException( const std::exception& e );
     void CatchUnknownException();
 
-  private:
 
+  
     //==================================================================
     // ATTRIBUTES
 
     /// The command executer used
-    bbtk::VirtualExec* mExecuter;
+    bbtk::VirtualExec::Pointer mExecuter;
 
     /// The user of  the interpreter (0 if none)
     bbtk::InterpreterUser* mUser;
@@ -284,6 +289,11 @@ namespace bbtk
     /// Vector of names of open files with full path (as open)
     std::vector<std::string> mFileName;
 
+    /// Vector of names of files which have been open 
+    /// before (and may closed then which are no more in mFileName)
+    /// with full path (as open)
+    std::vector<std::string> mFileNameHistory;
+
     /// Vector of names of open files as given to the include command
     std::vector<std::string> mIncludeFileName;