#pragma once #include #include #include #include #include #include class Station; class Device; using VecPairSS = std::vector>; struct DeviceType { int typeId {}; std::string name; std::string attrs; }; struct Role { int roleId {}; std::string name; bool isOpen {false}; }; class AppData { public: void init(); std::shared_ptr getStation(int stationId); std::shared_ptr getStationByName(std::string name); std::shared_ptr getDevice(int stationId, int deviceId); /////////////////////////////////////////////////////////////////////////////////////////////// // 获取角色名称列表 std::vector getRoleNames(); // 获取场站名称列表 std::vector getStationNames(); // 获取设备类型 std::vector getDeviceTypes(); // 获取设备类型定义 std::unordered_map>& getDeviceTypeDef(); // 读取统计数据: 今日统计数据,累计统计数据 void loadStatData(); void initUser(); public: /////////////////////////////////////////////////////////////////////////////////////////////// // === 系统 === int64_t sysActivationTime {}; /////////////////////////////////////////////////////////////////////////////////////////////// // === 数据库 === struct { std::string host; int port; std::string user; std::string passwd; } db; struct { VecPairSS isopen {{"0", "禁用"}, {"1", "启用"}}; VecPairSS gender {{"0", "女"}, {"1", "男"}}; // 角色 Mapping (id->name) VecPairSS role; VecPairSS deviceType; } mapping; /////////////////////////////////////////////////////////////////////////////////////////////// // === 场站信息 === std::unordered_map> mapStation; /////////////////////////////////////////////////////////////////////////////////////////////// // === 角色定义 === std::unordered_map> mapRole; /////////////////////////////////////////////////////////////////////////////////////////////// // === 设备类型定义 === std::unordered_map> mapDeviceType; };