absolute_timeout.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #ifndef ASTXX_MANAGER_ACTION_ABSOLUTE_TIMEOUT_H
00028 #define ASTXX_MANAGER_ACTION_ABSOLUTE_TIMEOUT_H
00029
00030 #include <astxx/manager/basic_action.h>
00031 #include <astxx/manager/message.h>
00032 #include <string>
00033 #include <ctime>
00034 #include <boost/lexical_cast.hpp>
00035 #include <boost/date_time/posix_time/posix_time_types.hpp>
00036
00037 namespace astxx {
00038 namespace manager {
00039 namespace action {
00040 using boost::lexical_cast;
00041 using boost::posix_time::time_duration;
00042 using boost::posix_time::seconds;
00043
00045 class absolute_timeout : public basic_action {
00046 public:
00052 absolute_timeout(const std::string& channel, std::time_t timeout)
00053 : channel(channel), timeout(seconds(timeout)) {
00054 }
00055
00062 absolute_timeout(const std::string& channel, time_duration timeout)
00063 : channel(channel), timeout(timeout) {
00064 }
00065
00066 message::action action() const {
00067 message::action action("AbsoluteTimeout");
00068 action["Channel"] = channel;
00069 if (timeout.is_special()) {
00070 action["Timeout"] = "0";
00071 }
00072 else {
00073 action["Timeout"] = lexical_cast<std::string>(timeout.total_seconds());
00074 }
00075
00076 return action;
00077 }
00078
00079 private:
00080 std::string channel;
00081 time_duration timeout;
00082 };
00083 }
00084 }
00085 }
00086
00087 #endif