#ifndef APPCORE_H
#define APPCORE_H

#include <QMenu>
#include <QObject>
#include <commandsdispatcher.h>
#include <libConfig.h>
#include <libParse.h>
#include <libProjectManager.h>

class MainWindow;

namespace Enhancement {
    class HighlightFeature;
}

namespace MakeTools {
    class StoryTool;
    class DocsManager;
    class FilePresent;
}

class SimpleException : public std::exception
{
public:
    explicit SimpleException(const QString &msg);

private:
    QString msg_store;

    // exception interface
public:
    virtual const char *what() const override;
};

namespace Core {
    class Extension;
    class AppCore;

    enum class Scale
    {
        Global,
        Project,
        File,
    };

    /**
     * @brief 软件内核类型
     */
    class AppCore : public QObject, public Schedule::AccessibleObject
    {
      public:
        AppCore(QObject *parent = nullptr);
        virtual ~AppCore() = default;

        void registerHighlightType(Enhancement::HighlightFeature *base_type);
        bool isHighlightDemand(void* ins) const;

        QList<MakeTools::FilePresent *> allViews() const;

        /**
         * @brief 全局保存操作
         */
        void save();

        /**
         * @brief 全局配置端口
         * @return
         */
        Config::Configration * globalConfig() const;

        void setCurrentProject(Project::ProjectManager *project);
        Project::ProjectManager* currentProject() const;
        QList<Config::Configration*> getConfigs(QList<Scale> types) const;
        Parse::Result::ParseCore * parseCore() const;

        QList<MakeTools::FilePresent*> extensions(const QString &suffix = QString()) const;

        MakeTools::StoryTool *getMakeCore() const;

      private:
        Config::Configration *const global_config;
        Project::ProjectManager * current_project;
        QList<MakeTools::FilePresent*> present_types;
        QList<Enhancement::HighlightFeature *> render_types;

        MakeTools::StoryTool *const makes_core;

        // AccessibleObject interface
    public:
        virtual QString name() const override;
    };

}

#endif // APPCORE_H
