00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __HOM_ShellIO_h__
00017 #define __HOM_ShellIO_h__
00018
00019 #include "HOM_API.h"
00020 #include "HOM_Module.h"
00021 #include <string>
00022 #include <boost/tuple/tuple.hpp>
00023
00024 SWIGOUT(%rename(ShellIO) HOM_ShellIO;)
00025
00026 class HOM_API HOM_ShellIO
00027 {
00028 public:
00029 HOM_ShellIO()
00030 { HOM_CONSTRUCT_OBJECT(this) }
00031 HOM_ShellIO(const HOM_ShellIO &)
00032 { HOM_CONSTRUCT_OBJECT(this) }
00033 virtual ~HOM_ShellIO()
00034 { HOM_DESTRUCT_OBJECT(this) }
00035
00036
00037
00038 #ifdef SWIG
00039 %extend {
00040 SWIGPYTHONOUT(%feature("autodoc",
00041 "readline(self, size=-1) -> string") readline;)
00042 %kwargs readline;
00043 InterpreterObject readline(int size=-1) throw(HOM_Error)
00044 {
00045
00046
00047
00048 boost::tuple<std::string, bool> result =
00049 self->readlineWithKeyboardInterrupt(size);
00050 if (result.get<1>())
00051 {
00052
00053
00054 return NULL;
00055 }
00056 return HOMconvertValueForInterpreter(result.get<0>(), SWIG_POINTER_OWN);
00057 }
00058
00059 void addExitCallback(InterpreterObject callback)
00060 throw(HOM_Error)
00061 { self->addOpaqueExitCallback(callback); }
00062
00063 void removeExitCallback(InterpreterObject callback)
00064 throw(HOM_Error)
00065 { self->removeOpaqueExitCallback(callback); }
00066
00067
00068
00069 std::vector<InterpreterObject> exitCallbacks()
00070 throw(HOM_Error)
00071 {
00072 std::vector<void *> opaque_callbacks(self->opaqueExitCallbacks());
00073
00074 std::vector<InterpreterObject> callbacks;
00075 for (int i=0; i< opaque_callbacks.size(); ++i)
00076 callbacks.push_back((InterpreterObject)opaque_callbacks[i]);
00077 return callbacks;
00078 }
00079 }
00080 #endif
00081
00082
00083
00084
00085 SWIGOUT(%ignore readlineWithKeyboardInterrupt;)
00086 virtual boost::tuple<std::string, bool /*interrupt_occurred*/>
00087 readlineWithKeyboardInterrupt(int size) throw(HOM_Error) = 0;
00088
00089 SWIGOUT(%ignore addOpaqueExitCallback;)
00090 virtual void addOpaqueExitCallback(void *callback)
00091 throw(HOM_Error) = 0;
00092 SWIGOUT(%ignore removeOpaqueExitCallback;)
00093 virtual void removeOpaqueExitCallback(void *callback)
00094 throw(HOM_OperationFailed, HOM_Error) = 0;
00095 SWIGOUT(%ignore opaqueExitCallbacks;)
00096 virtual std::vector<void *> opaqueExitCallbacks()
00097 throw(HOM_Error) = 0;
00098 SWIGOUT(%ignore executeExitCallbacks;)
00099 virtual void executeExitCallbacks() = 0;
00100
00101
00102 virtual void write(const std::string &data) throw(HOM_Error) = 0;
00103
00104
00105
00106
00107 SWIGOUT(%ignore hasWrittenData;)
00108 virtual bool hasWrittenData() = 0;
00109
00110
00111
00112 virtual std::string getAndClearWrittenData() throw(HOM_Error) = 0;
00113
00114
00115
00116 virtual void addDataForReading(const char *data) throw(HOM_Error) = 0;
00117
00118
00119
00120
00121 virtual void addEOFForReading() throw(HOM_Error) = 0;
00122
00123
00124
00125
00126 virtual void interruptShellThread() throw(HOM_Error) = 0;
00127
00128
00129
00130
00131
00132 virtual bool isWaitingForCommand() throw(HOM_Error) = 0;
00133 virtual void setIsWaitingForCommand(bool on) throw(HOM_Error) = 0;
00134
00135 virtual bool isatty() throw(HOM_Error) = 0;
00136 virtual void flush() throw (HOM_Error) = 0;
00137 };
00138
00139 #endif