/* * SubmitResultOperation.hpp * * Created on: Feb 26, 2012 * Author: heber */ #ifndef SUBMITRESULTOPERATION_HPP_ #define SUBMITRESULTOPERATION_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "Connection.hpp" #include "Jobs/FragmentJob.hpp" #include "Operations/AsyncOperation.hpp" #include "Results/FragmentResult.hpp" #include "WorkerAddress.hpp" class SubmitResultOperation : public AsyncOperation { public: /// Constructor for class SubmitResultOperation. SubmitResultOperation(Connection &_connection, const WorkerAddress &_address, const boost::function &_callback_on_success = NoOpCallback, const boost::function &_callback_on_failure = NoOpCallback) : AsyncOperation(std::string("submitresult"),_connection, _callback_on_success, _callback_on_failure), result( new FragmentResult(JobId::NoJob, std::string("EmptyResult")) ), address(_address) {} /// Destructor for class SubmitResultOperation ~SubmitResultOperation() {} /** Sets the result to submit. * * @param _result result to submit */ void setResult(FragmentResult::ptr &_result) { result.reset(); result = _result; } protected: // virtual function pointer to the connection handler void handle_connect(const boost::system::error_code& e, boost::asio::ip::tcp::resolver::iterator endpoint_iterator); /// Callback function when address has been sent and result is about to. void handle_SendChoice(const boost::system::error_code& e); /// Callback function when result has been sent. void handle_SendResult(const boost::system::error_code& e); /// Callback function when result has been sent. void handle_FinishOperation(const boost::system::error_code& e); private: // static entity of an empty result FragmentResult::ptr result; //!> address for listener WorkerAddress address; }; #endif /* SUBMITRESULTOPERATION_HPP_ */