#pragma once #include "include/global/Configs.hpp" #include "ProxyEntity.hpp" #include "Group.hpp" #include "RouteEntity.h" namespace Configs { const int INVALID_ID = -99999; class ProfileManager : private JsonStore { public: // JsonStore // order -> id QList groupsTabOrder; // Manager std::map> profiles; std::map> groups; std::map> routes; ProfileManager(); // LoadManager Reset and loads profiles & groups void LoadManager(); void SaveManager(); [[nodiscard]] static std::shared_ptr NewProxyEntity(const QString &type); [[nodiscard]] static std::shared_ptr NewGroup(); [[nodiscard]] static std::shared_ptr NewRouteChain(); bool AddProfile(const std::shared_ptr &ent, int gid = -1); bool AddProfileBatch(const QList> &ents, int gid = -1); void DeleteProfile(int id); void BatchDeleteProfiles(const QList& ids); std::shared_ptr GetProfile(int id); bool AddGroup(const std::shared_ptr &ent); void DeleteGroup(int gid); std::shared_ptr GetGroup(int id); std::shared_ptr CurrentGroup(); bool AddRouteChain(const std::shared_ptr& chain); std::shared_ptr GetRouteChain(int id); void UpdateRouteChains(const QList>& newChain); QStringList GetExtraCorePaths() const; bool AddExtraCorePath(const QString &path); private: // sort by id QList profilesIdOrder; QList groupsIdOrder; QList routesIdOrder; QSet extraCorePaths; [[nodiscard]] int NewProfileID() const; [[nodiscard]] int NewGroupID() const; [[nodiscard]] int NewRouteChainID() const; static std::shared_ptr LoadProxyEntity(const QString &jsonPath); static std::shared_ptr LoadGroup(const QString &jsonPath); static std::shared_ptr LoadRouteChain(const QString &jsonPath); void deleteProfile(int id); }; extern ProfileManager *profileManager; } // namespace Configs