/* * 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 "FragmentJob.hpp" #include "FragmentResult.hpp" #include "Controller/Commands/Operation.hpp" #include "Controller/Commands/CheckResultsOperation.hpp" #include "Controller/Commands/ReceiveJobsOperation.hpp" #include "Controller/Commands/SendResultsOperation.hpp" #include "Controller/Commands/ShutdownOperation.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: FragmentController(boost::asio::io_service& io_service); ~FragmentController(); protected: /// The Connection to the server. Connection connection_; public: ReceiveJobsOperation recjobs; CheckResultsOperation checkres; SendResultsOperation sendres; ShutdownOperation shutdown; // get the exit flag of the last operations size_t getExitflag() const { if (recjobs.getExitflag() != 0) return recjobs.getExitflag(); if (checkres.getExitflag() != 0) return checkres.getExitflag(); if (sendres.getExitflag() != 0) return sendres.getExitflag(); if (shutdown.getExitflag() != 0) return shutdown.getExitflag(); return 0; } }; #endif /* FRAGMENTCONTROLLER_HPP_ */