/** * \file * * * \brief Qt-based emulator framework for embedded applications (implementation) * * \author Bernie Innocenti */ #include "emul.h" #include "emulwin.h" #include #include #include // std::exit() /// The global emulator instance. Emulator *emul; Emulator::Emulator(int &argc, char **argv) : emulApp(new QApplication(argc, argv)), emulWin(new EmulWin(this)) { emulWin->show(); } Emulator::~Emulator() { // we don't delete emulWin because it automatically // deletes itself when closed delete emulApp; } NORETURN void Emulator::quit() { // WHAT A KLUDGE! this->~Emulator(); emul = NULL; // do we have a better way to shut down the emulation? exit(0); } MOD_DEFINE(emul) /// Main emulator entry point. extern "C" void emul_init(int *argc, char *argv[]) { // setup global emulator pointer emul = new Emulator(*argc, argv); MOD_INIT(emul); } extern "C" void emul_cleanup() { MOD_CLEANUP(emul); // Timer must be made inactive before we destroy the emulator extern bool timer_initialized; ASSERT(!timer_initialized); delete emul; emul = NULL; } extern "C" void emul_idle() { // We process GUI events when the application is idle. emul->emulApp->processEvents(); }