#pragma once #include #include #include #include #include #include #include #include "types/VehicleCommand.h" #include "network/HTTPClient.h" struct VehicleRegistryEntry { std::string vehicleID; std::string vehicleType; // WUREN/TEQIN/HANGKONG/PUTONG/JIUYUAN }; class ControllableVehicles { private: ControllableVehicles(); ControllableVehicles(const ControllableVehicles&) = delete; ControllableVehicles& operator=(const ControllableVehicles&) = delete; ~ControllableVehicles() = default; // 运行时车辆类型注册表(由前端接口增量更新) mutable std::shared_mutex mutex_; std::unordered_map vehicle_type_by_id_; std::unordered_set controllable_vehicle_ids_; // vehicleType == WUREN std::unordered_set managed_vehicle_ids_; // vehicleType in {WUREN, TEQIN} std::unordered_set selected_aircraft_ids_; // vehicleType == HANGKONG(前端选择参与碰撞的航空器 flightNo/id) std::unique_ptr http_client_; public: static ControllableVehicles& getInstance(); // 增量更新车辆注册表(仅更新 entries 中出现的 vehicleID),并同步可控车辆集合(WUREN) void updateRegistry(const std::vector& entries); // 查询 std::optional getVehicleType(const std::string& vehicleID) const; std::unordered_set getControllableVehicleIdsSnapshot() const; std::unordered_set getSelectedAircraftIdsSnapshot() const; bool isControllable(const std::string& vehicleNo) const; bool isManagedVehicle(const std::string& vehicleNo) const; bool isSelectedAircraft(const std::string& aircraftId) const; bool sendCommand(const std::string& vehicleNo, const VehicleCommand& command); };