| 1 | /* | 
|---|
| 2 | * SendResultsOperation.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Dec 11, 2011 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef FRAGMENTCONTROLLER_SENDRESULTSOPERATION_HPP_ | 
|---|
| 9 | #define FRAGMENTCONTROLLER_SENDRESULTSOPERATION_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include <boost/asio.hpp> | 
|---|
| 17 | #include <string> | 
|---|
| 18 | #include <vector> | 
|---|
| 19 |  | 
|---|
| 20 | #include "Connection.hpp" | 
|---|
| 21 | #include "FragmentResult.hpp" | 
|---|
| 22 |  | 
|---|
| 23 | #include "Controller/Commands/Operation.hpp" | 
|---|
| 24 |  | 
|---|
| 25 | class SendResultsOperation : public Operation  { | 
|---|
| 26 | public: | 
|---|
| 27 | /// Constructor for class SendResultsOperation. | 
|---|
| 28 | SendResultsOperation(Connection &_connection, const std::string& _host, const std::string& _service) : | 
|---|
| 29 | Operation(_connection, _host, _service) {} | 
|---|
| 30 | /// Destructor for class SendResultsOperation | 
|---|
| 31 | ~SendResultsOperation() {} | 
|---|
| 32 |  | 
|---|
| 33 | public: | 
|---|
| 34 | // placing receive jobs operations into an io_service | 
|---|
| 35 | virtual void operator()(); | 
|---|
| 36 |  | 
|---|
| 37 | // virtual function pointer to the connection handler | 
|---|
| 38 | virtual void handle_connect(const boost::system::error_code& e, | 
|---|
| 39 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator); | 
|---|
| 40 |  | 
|---|
| 41 | /// Handle completion of a GetResults operation. | 
|---|
| 42 | void handle_connect_get(const boost::system::error_code& e, | 
|---|
| 43 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator); | 
|---|
| 44 |  | 
|---|
| 45 | /// Callback function when results are about to be received. | 
|---|
| 46 | void handle_ReceivingResults(const boost::system::error_code& e); | 
|---|
| 47 |  | 
|---|
| 48 | /// Callback function when results have been received. | 
|---|
| 49 | void handle_ReceivedResults(const boost::system::error_code& e); | 
|---|
| 50 |  | 
|---|
| 51 | /// internal function to connect to server and receive calculated results | 
|---|
| 52 | void connect_get(); | 
|---|
| 53 |  | 
|---|
| 54 | /// Getter for results | 
|---|
| 55 | std::vector<FragmentResult> getResults(); | 
|---|
| 56 |  | 
|---|
| 57 | protected: | 
|---|
| 58 | /// bunch of results | 
|---|
| 59 | std::vector<FragmentResult> results; | 
|---|
| 60 | }; | 
|---|
| 61 |  | 
|---|
| 62 | #endif /* FRAGMENTCONTROLLER_SENDRESULTSOPERATION_HPP_ */ | 
|---|