1 | /*
|
---|
2 | * ReceiveResultsOperation.hpp
|
---|
3 | *
|
---|
4 | * Created on: Dec 11, 2011
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_
|
---|
9 | #define FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_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 <set>
|
---|
18 | #include <string>
|
---|
19 | #include <vector>
|
---|
20 |
|
---|
21 | #include "JobMarket/Connection.hpp"
|
---|
22 | #include "JobMarket/Operations/AsyncOperation.hpp"
|
---|
23 | #include "JobMarket/Results/FragmentResult.hpp"
|
---|
24 | #include "JobMarket/types.hpp"
|
---|
25 |
|
---|
26 | class ReceiveResultsOperation : public AsyncOperation {
|
---|
27 | public:
|
---|
28 | /// Constructor for class ReceiveResultsOperation.
|
---|
29 | ReceiveResultsOperation(Connection &_connection,
|
---|
30 | const boost::function<void ()> _callback_on_success = NoOpCallback,
|
---|
31 | const boost::function<void ()> _callback_on_failure = NoOpCallback) :
|
---|
32 | AsyncOperation(std::string("receiveresults"), _connection, _callback_on_success, _callback_on_failure),
|
---|
33 | jobids(emptyids)
|
---|
34 | {}
|
---|
35 | /// Destructor for class ReceiveResultsOperation
|
---|
36 | ~ReceiveResultsOperation() {}
|
---|
37 |
|
---|
38 | public:
|
---|
39 | // virtual function pointer to the connection handler
|
---|
40 | virtual void handle_connect(const boost::system::error_code& e,
|
---|
41 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
|
---|
42 |
|
---|
43 | /// Callback function when sending desired job ids.
|
---|
44 | void handle_SendJobIds(const boost::system::error_code& e);
|
---|
45 |
|
---|
46 | /// Callback function when results are about to be received.
|
---|
47 | void handle_ReceivingResults(const boost::system::error_code& e);
|
---|
48 |
|
---|
49 | /// Callback function when results have been received.
|
---|
50 | void handle_ReceivedResults(const boost::system::error_code& e);
|
---|
51 |
|
---|
52 | /// Getter for results
|
---|
53 | std::vector<FragmentResult::ptr> getResults();
|
---|
54 |
|
---|
55 | /// Setter for internal vector of jobids to check
|
---|
56 | void setJobIds(const std::set<JobId_t> &_jobids)
|
---|
57 | { const_cast<std::set<JobId_t> &>(jobids) = _jobids; }
|
---|
58 |
|
---|
59 | protected:
|
---|
60 | //!> internal ref to the jobids to check
|
---|
61 | const std::set<JobId_t> &jobids;
|
---|
62 |
|
---|
63 | /// bunch of results
|
---|
64 | std::vector<FragmentResult::ptr> results;
|
---|
65 |
|
---|
66 | private:
|
---|
67 | //!> internal empty ids vector to use as default ref
|
---|
68 | static const std::set<JobId_t> emptyids;
|
---|
69 |
|
---|
70 | };
|
---|
71 |
|
---|
72 | #endif /* FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_ */
|
---|