#pragma once #include #include "JDefines.h" #include "JTerminal.h" namespace Incart::Common { class JSys { protected: public: static QCoreApplication* Core(QCoreApplication* app = nullptr) { static QCoreApplication* m_app = nullptr; if(app != nullptr) m_app= app; return m_app; } static void processEvents() { if(Core() != nullptr) Core()->processEvents(); } static void exit() { if(Core() == nullptr) std::exit(0); Core()->exit(); } static void abort() { if(Core() == nullptr) std::exit(1); Core()->exit(-1); } static void test(bool res, QString str) { if(!res) { JTerminal(JCL_RED) << str; if(Core() == nullptr) std::exit(1); Core()->exit(-1); } } }; #define JTEST(res,str) JSys::test(res,QString(__FUNCTION__) + ' ' + str) } // namespace Incart::Common