#ifndef DEVICE_CTRL_APP_H
#define DEVICE_CTRL_APP_H
#include <mutex>
#include <QObject>
#include <QSharedPointer.h>
#include <oneapi/tbb/concurrent_unordered_map.h>

#include "app/app_config.pb.h"
#include "bean.h"

namespace zsy
{
    class App : public QObject
    {
        Q_OBJECT

    public:
        explicit App(QObject *parent = nullptr);

        ~App() override = default;

        Q_SIGNALS:
        

        void startApp();

        void stopApp();

        void restartApp();

        void resetApp();

    public
        Q_SLOTS:
        

        void onStartApp();

        void onStopApp();

        void onRestartApp();

        void onResetApp();

    public:
        static std::string HOME_DIR;
        static std::string CONFIG_DIR;
        static std::string JSON_CONFIG_FILE;
        static std::string BIN_CONFIG_FILE;
        inline static std::shared_ptr<const AppConfig> APP_CONFIG;

        static void run();

        static void stop();

        static void restart();

        static void reset(const std::string &configStr);

        static std::string sn();

        static std::string stationSn();

        static std::string name();

        static bool loadConfig();

        static bool saveConfig();

        static const AppConfig &defaultConfig();
    };

    inline static QSharedPointer<App> APP = QSharedPointer<App>(new App());
} // zsy

#endif //DEVICE_CTRL_APP_H