events.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_EVENTS_H
00028 #define ASTXX_MANAGER_ACTION_EVENTS_H
00029
00030 #include <astxx/manager/basic_action.h>
00031 #include <astxx/manager/message.h>
00032 #include <string>
00033 #include <boost/lexical_cast.hpp>
00034
00035 namespace astxx {
00036 namespace manager {
00037 namespace action {
00038 using boost::lexical_cast;
00039
00041 class events : public basic_action {
00042 public:
00043 static const unsigned short system;
00044 static const unsigned short call;
00045 static const unsigned short log;
00046 static const unsigned short verbose;
00047 static const unsigned short command;
00048 static const unsigned short agent;
00049 static const unsigned short user;
00050 static const unsigned short config;
00051 public:
00059 events(unsigned short mask) : int_mask(mask), bool_mask(false), string_mask("") {
00060 }
00061
00069 events(const std::string& mask) : int_mask(0), bool_mask(false), string_mask(mask) {
00070 }
00071
00079 events(bool mask) : int_mask(0), bool_mask(mask), string_mask("") {
00080 }
00081
00082 message::action action() const {
00083 message::action action("Events");
00084 if (int_mask) {
00085 action["EventMask"] = lexical_cast<std::string>(int_mask);
00086 }
00087 else if (not string_mask.empty()) {
00088 action["EventMask"] = string_mask;
00089 }
00090 else if (bool_mask) {
00091 action["EventMask"] = "on";
00092 }
00093 else {
00094 action["EventMask"] = "off";
00095 }
00096
00097 return action;
00098 }
00099
00100 private:
00101 unsigned short int_mask;
00102 bool bool_mask;
00103 std::string string_mask;
00104 };
00105
00106
00107 static const unsigned short events::system = 1 << 0;
00108 static const unsigned short events::call = 1 << 1;
00109 static const unsigned short events::log = 1 << 2;
00110 static const unsigned short events::verbose = 1 << 3;
00111 static const unsigned short events::command = 1 << 4;
00112 static const unsigned short events::agent = 1 << 5;
00113 static const unsigned short events::user = 1 << 6;
00114 static const unsigned short events::config = 1 << 7;
00115
00116 }
00117 }
00118 }
00119
00120 #endif