#include "engine.hpp"
+/***********************************************************************/
+inline void terminateCommand(int dummy) {
+
+ //mothurOut("Stopping command....");
+ //CommandFactory* cFactory = CommandFactory::getInstance();
+ //cFactory->getCommand(); //deletes old command and makes new no command.
+ //this may cause memory leak if old commands execute function allocated memory
+ //that is freed in the execute function and not the deconstructor
+ //mothurOut("DONE."); mothurOutEndLine();
+}
+/***********************************************************************/
+Engine::Engine(){
+ try {
+ cFactory = CommandFactory::getInstance();
+ }
+ catch(exception& e) {
+ errorOut(e, "Engine", "Engine");
+ exit(1);
+ }
+}
/***********************************************************************/
int quitCommandCalled = 0;
while(quitCommandCalled != 1){
-
+
mothurOutEndLine();
input = getCommand();
- mothurOutJustToLog("mothur > " + input);
- mothurOutEndLine();
-
//allow user to omit the () on the quit command
if (input == "quit") { input = "quit()"; }
/***********************************************************************/
string Engine::getCommand() {
try {
- char* nextCommand = NULL;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #ifdef USE_READLINE
+ char* nextCommand = NULL;
+ nextCommand = readline("mothur > ");
+ if(nextCommand != NULL) { add_history(nextCommand); }
+ mothurOutJustToLog("mothur > " + toString(nextCommand));
+ return nextCommand;
+ #else
+ string nextCommand = "";
+ mothurOut("mothur > ");
+ getline(cin, nextCommand);
+ return nextCommand;
+ #endif
+ #else
+ string nextCommand = "";
+ mothurOut("mothur > ");
+ getline(cin, nextCommand);
+ return nextCommand;
+ #endif
- nextCommand = readline("mothur > ");
- if(nextCommand != NULL) { add_history(nextCommand); }
+ mothurOutEndLine();
- return nextCommand;
}
catch(exception& e) {
errorOut(e, "Engine", "getCommand");
}
}
/***********************************************************************/
-void Engine::terminateCommand(int dummy) {
- try {
- mothurOut("Stopping command."); mothurOutEndLine();
- cFactory->getCommand(); //terminates command
- }
- catch(exception& e) {
- errorOut(e, "Engine", "terminateCommand");
- exit(1);
- }
-}
-/***********************************************************************/
//This function opens the batchfile to be used by BatchEngine::getInput.
BatchEngine::BatchEngine(string path, string batchFileName){
try {