00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2010 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef INTERPRETERMANAGER_H 00011 #define INTERPRETERMANAGER_H 00012 00013 #include "Subject.h" 00014 00015 #include <string> 00016 00017 class Interpreter; 00018 00019 /** 00020 * All interpreters must implement this interface 00021 * which defines how the application and plug-ins 00022 * execute commands with an interpreter implementation. 00023 * 00024 * %Interpreter implementations must also implement 00025 * the PlugIn interface. It is recommended a 00026 * interpreter implementation subclass from 00027 * InterpreterManagerShell. 00028 * 00029 * An interpreter implementation must also 00030 * provide an implementation of the Interpreter 00031 * interface. 00032 * 00033 * @see Interpreter 00034 */ 00035 class InterpreterManager : public Subject 00036 { 00037 public: 00038 /** 00039 * Emitted when the interpreter starts. If 00040 * a given interpreter implementation executes 00041 * during application start-up, this signal 00042 * may never be emitted. It only suggested 00043 * you attach to this signal if calling 00044 * isStarted() returns \c false. This 00045 * signal is permitted to be emitted even 00046 * if no calls to start() have been 00047 * made (i.e. the user entered required configuration 00048 * information into a dialog while the application 00049 * was running). 00050 */ 00051 SIGNAL_METHOD(InterpreterManager, InterpreterStarted); 00052 00053 /** 00054 * Returns if the interpreter is started 00055 * and running. 00056 * 00057 * If this returns \c true, getInterpreter() 00058 * must return \c non-NULL. If this returns 00059 * \c false, getInterpreter() must return \c NULL. 00060 * 00061 * @return \c True if the interpreter is 00062 * started and running, \c false 00063 * otherwise. 00064 * 00065 * @see getStartupMessage() 00066 */ 00067 virtual bool isStarted() const = 0; 00068 00069 /** 00070 * Attempt to start the interpreter. 00071 * This method can be called multiple times without 00072 * any ill effect. This method can be called even 00073 * if the interpreter is already started and no 00074 * changes will be made to the already running 00075 * interpreter. If this method returns \c true, 00076 * subsequent calls to isStarted() must 00077 * return \c true 00078 * 00079 * If this result of calling this method will change 00080 * the return value of \c isStarted() from \c false 00081 * to \c true, then 00082 * SIGNAL_NAME(InterpreterManager, InterpreterStarted) 00083 * must be emitted. 00084 * 00085 * @return \c True if the interpreter 00086 * was started or was already 00087 * running. Returns \c false 00088 * if the interpreter was not 00089 * already running and could 00090 * not be started. 00091 * 00092 * @see getStartupMessage() 00093 */ 00094 virtual bool start() = 0; 00095 00096 /** 00097 * Returns the startup message from the last 00098 * failed start or the message from a 00099 * successful start. 00100 * 00101 * @return The startup message from the last 00102 * failed start or the message from a 00103 * successful start. 00104 * 00105 * @see start(), isStarted() 00106 */ 00107 virtual std::string getStartupMessage() const = 0; 00108 00109 /** 00110 * Returns whether the user should be permitted 00111 * to enter commands into the Scripting Window. 00112 * 00113 * If \c true is returned, the user will be 00114 * permitted to enter commands into the Scripting 00115 * Window. If \c false, the Scripting Window 00116 * will be made read-only. The value returned 00117 * from this function must not change between 00118 * calls to this function. 00119 * 00120 * The behavior of Interpreter::executeCommand() 00121 * and Interpreter::executeScopedCommand() must 00122 * NOT be different based upon the return 00123 * value of this function. 00124 * 00125 * @return Returns whether the user should be permitted 00126 * to enter commands into the Scripting Window. 00127 */ 00128 virtual bool isInteractiveEnabled() const = 0; 00129 00130 /** 00131 * Returns the Interpreter instance that can be used 00132 * to execute commands. 00133 * 00134 * The lifetime of the returned instance 00135 * is guaranteed to be at least as long as the lifetime 00136 * of the InterpreterManager instance this method was 00137 * called on. However, after the InterpreterManager 00138 * instance has been deleted, the returned Interpreter 00139 * instance should be considered invalid. 00140 * 00141 * @return The Interpreter instance that can be 00142 * used to execute commands. This must 00143 * return NULL if a call to isStarted() 00144 * \c false and must return non-NULL if 00145 * a call to isStarted() returns \c true. 00146 */ 00147 virtual Interpreter* getInterpreter() const = 0; 00148 00149 /** 00150 * Returns the default scripting file extensions recognized by the interpreter. 00151 * 00152 * @return The file extensions recognized by the interpreter as a string. 00153 * The string consists of a description followed by one or more 00154 * file extensions separated by a space. Multiple file 00155 * types may be specified with a double semicolon. Examples 00156 * include "ENVI Header Files (*.hdr)", "TIFF Files (*.tif *.tiff)", 00157 * and "Source Files (*.c*);;Header Files (*.h)". 00158 */ 00159 virtual std::string getFileExtensions() const = 0; 00160 00161 protected: 00162 /** 00163 * This should be destroyed by calling PlugInManagerServices::destroyPlugIn. 00164 */ 00165 virtual ~InterpreterManager() {} 00166 }; 00167 00168 #endif