#pragma once #include "../GuiComponent.h" #include "../HttpReq.h" #include /* Usage example: std::shared_ptr httpreq = std::make_shared("cdn.garcya.us", "/wp-content/uploads/2010/04/TD250.jpg"); AsyncReqComponent* req = new AsyncReqComponent(mWindow, httpreq, [] (std::shared_ptr r) { LOG(LogInfo) << "Request completed"; LOG(LogInfo) << " error, if any: " << r->getErrorMsg(); }, [] () { LOG(LogInfo) << "Request canceled"; }); mWindow->pushGui(req); //we can forget about req, since it will always delete itself */ class AsyncReqComponent : public GuiComponent { public: AsyncReqComponent(Window* window, std::shared_ptr req, std::function)> onSuccess, std::function onCancel = nullptr); bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; void render(const Eigen::Affine3f& parentTrans) override; private: std::function)> mSuccessFunc; std::function mCancelFunc; unsigned int mTime; std::shared_ptr mRequest; };