#pragma once #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #include #include #include #include #include #include class UserDataManager { public: // State flags (similar to C# properties) bool IsLoadingModel() { return isLoadingModel_; } bool ReceivedModelsResponse() { return receivedModelsResponse_; } const std::string& ModelLoadingError() const { return modelLoadingError_; } void SetModelLoadingError(const std::string& err) { modelLoadingError_ = err; } // User / token / server configuration const std::string UserId() const { return userId_; } const std::string TestingToken() const { return testingToken_; } void SetTestingToken(const std::string& value); const std::string ServerApiAddress() const { return serverApiAddress_; } const std::vector& UserTrainedModels() const { return userTrainedModels_; } // Event / callback hooks std::function OnUserIdChanged; std::function&)> OnUserTrainedModelsChanged; // AuthenticationResponse: 0 = failure, 1 = expired, 2 = success std::function OnAuthenticationResponse; // API interaction (HTTP GET/POST) void FetchUserIdFromApi(); void FetchUserTrainedModels(); // Downloads a model file and writes it to outputPath. bool DownloadModel(const std::string& modelKey, const std::string& outputPath); private: void ResetData(); static std::string SanitizeString(const std::string& input); static std::string TrimTrailingSlash(const std::string& url); static std::string GetExecutableDirectory(); // Backing fields std::string userId_; std::string testingToken_{ "" }; std::string serverApiAddress_{ "http://104.171.203.65:8000" }; std::vector userTrainedModels_; bool isLoadingModel_{ false }; bool receivedModelsResponse_{ false }; std::string modelLoadingError_; }; extern UserDataManager userManager;