1 | /*
|
---|
2 | * ObtainJobOperation.hpp
|
---|
3 | *
|
---|
4 | * Created on: Feb 26, 2012
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef OBTAINJOBOPERATION_HPP_
|
---|
9 | #define OBTAINJOBOPERATION_HPP_
|
---|
10 |
|
---|
11 | // include config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 |
|
---|
17 | #include <boost/asio.hpp>
|
---|
18 | #include <string>
|
---|
19 | #include <vector>
|
---|
20 |
|
---|
21 | #include "JobMarket/Connection.hpp"
|
---|
22 |
|
---|
23 | #include "JobMarket/Jobs/FragmentJob.hpp"
|
---|
24 | #include "JobMarket/Operations/AsyncOperation.hpp"
|
---|
25 | #include "JobMarket/Results/FragmentResult.hpp"
|
---|
26 |
|
---|
27 | class ObtainJobOperation : public AsyncOperation {
|
---|
28 | public:
|
---|
29 | /// Constructor for class ObtainJobOperation.
|
---|
30 | ObtainJobOperation(Connection &_connection,
|
---|
31 | const boost::function<void ()> _callback_on_success = NoOpCallback,
|
---|
32 | const boost::function<void ()> _callback_on_failure = NoOpCallback) :
|
---|
33 | AsyncOperation(std::string("obtainjob"),_connection, _callback_on_success, _callback_on_failure)
|
---|
34 | {}
|
---|
35 | /// Destructor for class ObtainJobOperation
|
---|
36 | ~ObtainJobOperation() {}
|
---|
37 |
|
---|
38 | /** Getter for the obtained job.
|
---|
39 | *
|
---|
40 | * @return obtained FragmentJob
|
---|
41 | */
|
---|
42 | FragmentJob::ptr getJob()
|
---|
43 | {
|
---|
44 | return job;
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected:
|
---|
48 | // virtual function pointer to the connection handler
|
---|
49 | void handle_connect(const boost::system::error_code& e,
|
---|
50 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
|
---|
51 |
|
---|
52 | /// Callback function when job has been received.
|
---|
53 | void handle_ReceiveJob(const boost::system::error_code& e);
|
---|
54 |
|
---|
55 | private:
|
---|
56 | /// The data received from the server.
|
---|
57 | FragmentJob::ptr job;
|
---|
58 | };
|
---|
59 |
|
---|
60 |
|
---|
61 | #endif /* OBTAINJOBOPERATION_HPP_ */
|
---|