/* * FragmentController.hpp * * Created on: Nov 27, 2011 * Author: heber */ #ifndef FRAGMENTCONTROLLER_HPP_ #define FRAGMENTCONTROLLER_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "Connection.hpp" #include "ExitflagContainer.hpp" #include "JobId.hpp" #include "Jobs/FragmentJob.hpp" #include "Results/FragmentResult.hpp" #include "Operations/OperationRegistry.hpp" /** The FragmentController sends bunches of jobs to a FragmentScheduler, * waits for their calculation and is called when they are done. Then, * he loads the bunch of results from the Scheduler. * * While the FragmentScheduler and FragmentWorker rather act on their own * this is the piece to implant into the user software to allow for * communication with the Server/Worker duo to perform the calculation * of the fragments on distant computers. */ class FragmentController : public ExitflagContainer { public: FragmentController(boost::asio::io_service& io_service); ~FragmentController(); void requestIds(const std::string &host, const std::string &service, const size_t NumberIds); JobId_t getAvailableId(); void addJobs(std::vector &jobs); void sendJobs(const std::string &host, const std::string &service); void checkResults(const std::string &host, const std::string &service); std::pair getJobStatus() const; void removeall(const std::string &host, const std::string &service); void receiveResults(const std::string &host, const std::string &service); std::vector getReceivedResults(); void shutdown(const std::string &host, const std::string &service); protected: /// The Connection to the server. Connection connection_; public: //!> registry with all operations of this controller OperationRegistry Commands; private: //!> internally bound function that sets the Exitflag to ErrorFlag boost::function failed; }; #endif /* FRAGMENTCONTROLLER_HPP_ */