8 #include <cc++/thread.h>
9 #include <cc++/cmdoptns.h>
13 // available generic ui's
14 #include <F_Batch_UI.H>
15 #include <F_Linux_Console_UI.H>
16 #include <F_FLTK_UI.H>
18 //! ×ËÌÀÞÁÅÔ × ÓÅÂÑ ×ÓÅ ËÌÁÓÓÙ ÂÉÂÌÉÏÔÅËÉ Forms
24 * ÷ÓÐÏÍÏÇÁÔÅÌØÎÙÊ ËÌÁÓÓ ÄÌÑ ÓÏÚÄÁÎÉÑ ÐÒÉÌÏÖÅÎÉÊ, ÐÏÒÑÄÏË ÒÁÂÏÔÙ Ó app :
26 * - ÒÁÚÂÏÒ ÏÐÃÉÊ ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÉ
27 * - app-oriented ÉÎÉÃÉÁÌÉÚÁÃÉÑ
28 * - app-oriented run() ÆÕÎËÃÉÑ / app-oriented callback's
29 * - app-oriented quit()
35 static F_App *this_; //!< needed for signal handlers
36 static std::string name_; //!< ÎÁÚ×ÁÎÉÅ ÐÒÉÌÏÖÅÎÉÑ
37 std::string version_; //!< ×ÅÒÓÉÑ ÐÒÉÌÏÖÅÎÉÑ
38 std::string author_; //!< Á×ÔÏÒ ÐÒÉÌÏÖÅÎÉÑ
39 std::string license_; //!< ÌÉÃÅÎÚÉÑ ÐÒÉÌÏÖÅÎÉÑ
43 ost::CommandOptionParse *cmd_opts_;
45 std::new_handler old_new_handler;
47 //! all signals going here first
48 static void signal_handler(int signo, siginfo_t* siginfo, void* ptr);
49 static void signals_setup(void);
51 static void (*idle_)(void); //!< ÕËÁÚÁÔÅÌØ ÎÁ idle-ÆÕÎËÃÉÀ
58 static int argc_; //!< original argc
59 static char **argv_; //!< original argv
61 //! F_App ËÏÎÓÔÒÕËÔÏÒ, ÐÒÁÍÅÔÒÙ :
62 // name - ÉÍÑ ÐÒÏÇÒÁÍÍÙ
63 F_App(int argc, char **argv, const char *name = 0, const char *version = 0,
64 const char *author = 0, const char *license = 0,
65 ost::CommandOption *user_cmd_opts = ost::defaultCommandOptionList,
66 const char *comment = 0, const char *log_prefix = 0);
68 static const char *name() { return name_.c_str(); }
69 static const char argc() { return argc_; }
70 static const char *argv(int idx) { return argv_[idx]; }
72 virtual void parse_command_options(void) { } //!< called before ui creation
73 virtual void sigcont() { log("sigcont", "Continuing app"); }
74 virtual bool sigstop() { log("sigstop", "app is stopped"); return true; }
75 virtual bool exit_confirm(bool from_sighandler) { return (ui_ ? ui_->exit_confirm(from_sighandler) : true); }
78 start_ui(); // start ui
79 if (how == start_only)
81 while (1) // wait for ui events
86 init(); // parse command options, create ui
87 // ui_->pid = getpid();
89 // wait for main thread to run
90 ui_->wait_for_started();
93 void idle(void (*cb)()) { idle_ = cb; }
94 static void idle() { idle_(); }
95 static void shutdown() {
96 std::set_new_handler(this_->old_new_handler);
98 this_->ui_->shutdown();
101 // int get_key() { return ui->get_key(); }
102 // virtual void beep() { ui->beep(); }
103 virtual void run(void) { start_ui(); while(1) default_idle(); }
107 static void default_idle(void);