#ifndef GRADIDO_LOGIN_SERVER_CONTROLLER_PENDING_TASK_INCLUDE #define GRADIDO_LOGIN_SERVER_CONTROLLER_PENDING_TASK_INCLUDE #include "../model/table/PendingTask.h" #include "Poco/SharedPtr.h" #include "Poco/Timer.h" #include "Poco/Dynamic/Var.h" #include "TableControllerBase.h" #include "User.h" namespace controller { typedef Poco::Tuple NodeServerFullTuple; class PendingTask : public TableControllerBase { public: ~PendingTask(); static Poco::AutoPtr create(int userId, std::string serializedProtoRequest, model::table::TaskType type); static std::vector> load(int userId); static std::vector> loadAll(); inline Poco::AutoPtr getModel() { return _getModel(); } inline const model::table::PendingTask* getModel() const { return _getModel(); } //! \brief delete from db and remove from Pending Task Manager bool deleteFromDB(); virtual bool isTimeoutTask() = 0; virtual Poco::DateTime getNextRunTime() { return Poco::DateTime(); }; //! \return 1 run finished, more runs needed //! \return 0 run finished, no more runs needed //! \return -1 error, more runs needed //! \return -2 critical error, abort, remove virtual int run() { return false; }; void startTimer(); void calledFromTimer(Poco::Timer& timer); Poco::AutoPtr getUser(); void finishSuccess(); bool setResult(const std::string& key, const Poco::Dynamic::Var& value, bool saveIntoDB = false); bool setParam(const std::string& key, const Poco::Dynamic::Var& value, bool saveIntoDB = false); int getIntParam(const std::string& key); protected: static Poco::AutoPtr loadCorrectDerivedClass(model::table::PendingTask* dbModel); PendingTask(model::table::PendingTask* dbModel); Poco::AutoPtr mUser; Poco::Timer mTimer; }; } #endif //GRADIDO_LOGIN_SERVER_CONTROLLER_PENDING_TASK_INCLUDE