| 1 | /*
|
|---|
| 2 | * CheckResultsOperation.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Dec 11, 2011
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_
|
|---|
| 9 | #define FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_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 |
|
|---|
| 19 | #include "Connection.hpp"
|
|---|
| 20 |
|
|---|
| 21 | #include "Operations/AsyncOperation.hpp"
|
|---|
| 22 |
|
|---|
| 23 | /** This Operations requests number of present jobs and present results (done
|
|---|
| 24 | * jobs) from the server.
|
|---|
| 25 | *
|
|---|
| 26 | */
|
|---|
| 27 | class CheckResultsOperation : public AsyncOperation {
|
|---|
| 28 | public:
|
|---|
| 29 | /// Constructor for class CheckResultsOperation.
|
|---|
| 30 | CheckResultsOperation(Connection &_connection,
|
|---|
| 31 | const boost::function<void ()> &_callback_on_success = NoOpCallback,
|
|---|
| 32 | const boost::function<void ()> &_callback_on_failure = NoOpCallback) :
|
|---|
| 33 | AsyncOperation(std::string("checkresults"), _connection, _callback_on_success, _callback_on_failure),
|
|---|
| 34 | jobInfo((size_t)2, 0)
|
|---|
| 35 | {}
|
|---|
| 36 | /// Destructor for class CheckResultsOperation
|
|---|
| 37 | ~CheckResultsOperation() {}
|
|---|
| 38 |
|
|---|
| 39 | public:
|
|---|
| 40 | // virtual function pointer to the connection handler
|
|---|
| 41 | virtual void handle_connect(const boost::system::error_code& e,
|
|---|
| 42 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
|
|---|
| 43 |
|
|---|
| 44 | /// Callback function when doneJobs have been received.
|
|---|
| 45 | void handle_ReceiveJobInfo(const boost::system::error_code& e);
|
|---|
| 46 |
|
|---|
| 47 | /// Getter for presentJobs
|
|---|
| 48 | size_t getPresentJobs() const;
|
|---|
| 49 |
|
|---|
| 50 | /// Getter for doneJobs
|
|---|
| 51 | size_t getDoneJobs() const;
|
|---|
| 52 |
|
|---|
| 53 | protected:
|
|---|
| 54 | /// current jobs left to calculate and currently calculated results
|
|---|
| 55 | std::vector<size_t> jobInfo;
|
|---|
| 56 | };
|
|---|
| 57 |
|
|---|
| 58 | #endif /* FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_ */
|
|---|