| 1 | /* | 
|---|
| 2 | * RemoveFromPoolOperation.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Mar 01, 2012 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_ | 
|---|
| 9 | #define FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_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 |  | 
|---|
| 22 | #include "Operations/AsyncOperation.hpp" | 
|---|
| 23 | #include "WorkerAddress.hpp" | 
|---|
| 24 |  | 
|---|
| 25 | class RemoveFromPoolOperation : public AsyncOperation  { | 
|---|
| 26 | public: | 
|---|
| 27 | /// Constructor for class RemoveFromPoolOperation. | 
|---|
| 28 | RemoveFromPoolOperation(Connection &_connection, const WorkerAddress &_address, | 
|---|
| 29 | const boost::function<void ()> &_callback_on_success = NoOpCallback, | 
|---|
| 30 | const boost::function<void ()> &_callback_on_failure = NoOpCallback) : | 
|---|
| 31 | AsyncOperation(std::string("shutdownworker"),_connection, _callback_on_success, _callback_on_failure), | 
|---|
| 32 | address(_address) | 
|---|
| 33 | {} | 
|---|
| 34 | /// Destructor for class RemoveFromPoolOperation | 
|---|
| 35 | ~RemoveFromPoolOperation() {} | 
|---|
| 36 |  | 
|---|
| 37 | public: | 
|---|
| 38 | // virtual function pointer to the connection handler | 
|---|
| 39 | void handle_connect(const boost::system::error_code& e, | 
|---|
| 40 | boost::asio::ip::tcp::resolver::iterator endpoint_iterator); | 
|---|
| 41 |  | 
|---|
| 42 | /// Callback function when address has been sent and we ask for removal | 
|---|
| 43 | void handle_SendChoice(const boost::system::error_code& e); | 
|---|
| 44 |  | 
|---|
| 45 | /// Callback function when receiving flag indication succesful removal | 
|---|
| 46 | void handle_ReceiveFlag(const boost::system::error_code& e); | 
|---|
| 47 |  | 
|---|
| 48 | /// Callback function when op is finished. | 
|---|
| 49 | void handle_FinishOperation(const boost::system::error_code& e); | 
|---|
| 50 |  | 
|---|
| 51 | private: | 
|---|
| 52 | //!> address to enroll with | 
|---|
| 53 | WorkerAddress address; | 
|---|
| 54 |  | 
|---|
| 55 | //!> flag indication successful removal from server | 
|---|
| 56 | bool RemovalFlag; | 
|---|
| 57 | }; | 
|---|
| 58 |  | 
|---|
| 59 | #endif /* FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_ */ | 
|---|