00001 #ifndef oc_h 00002 #define oc_h 00003 00004 #include <Dispatch/iohandler.h> 00005 #include <Dispatch/dispatcher.h> 00006 #include <InterViews/session.h> 00007 #include <OS/string.h> 00008 #include <stdio.h> 00009 #include <ivstream.h> 00010 class Observer; 00011 class Observable; 00012 class Cursor; 00013 struct Object; 00014 00015 class HandleStdin: public IOHandler { 00016 public: 00017 HandleStdin(); 00018 virtual int inputReady(int fd); 00019 virtual int exceptionRaised(int fd); 00020 boolean stdinSeen_; 00021 boolean acceptInput_; 00022 }; 00023 00024 struct Symbol; 00025 struct Symlist; 00026 00027 class Oc { 00028 public: 00029 Oc(); 00030 Oc(Session*, char* pname = nil, char** env = nil); 00031 virtual ~Oc(); 00032 00033 int run(int argc, char** argv); 00034 int run(const char *, boolean show_err_mes = true); 00035 00036 Symbol* parseExpr(const char *, Symlist** = nil); 00037 double runExpr(Symbol*); 00038 static boolean valid_expr(Symbol*); 00039 static boolean valid_stmt(const char*, Object* ob = nil); 00040 const char* name(Symbol*); 00041 00042 void notifyHocValue(); // loops over HocValueBS buttonstates. 00043 00044 void notify(); // called on doNotify from oc 00045 void notify_attach(Observer*); // add to notify list 00046 void notify_detach(Observer*); 00047 00048 void notify_freed(void (*pf)(void*, int)); // register a callback func 00049 void notify_when_freed(void* p, Observer*); 00050 void notify_when_freed(double* p, Observer*); 00051 void notify_pointer_disconnect(Observer*); 00052 00053 static Session* getSession(); 00054 static int getStdinSeen() {return handleStdin_->stdinSeen_;} 00055 static void setStdinSeen(boolean i) {handleStdin_->stdinSeen_ = i;} 00056 static boolean setAcceptInput(boolean); 00057 static boolean helpmode() {return helpmode_;} 00058 static void helpmode(boolean); 00059 static void helpmode(Window*); 00060 static void help(const char*); 00061 00062 static ostream* save_stream; 00063 static void cleanup(); 00064 private: 00065 static int refcnt_; 00066 static Session* session_; 00067 static HandleStdin* handleStdin_; 00068 static boolean helpmode_; 00069 static Cursor* help_cursor(); 00070 static Cursor* help_cursor_; 00071 static Observable* notify_change_; 00072 }; 00073 00074 #endif