events.h

Go to the documentation of this file.
00001 /* vim: set et sw=3 tw=0 fo=croqlaw cino=t0:
00002  *
00003  * Astxx, the Asterisk C++ API and Utility Library.
00004  * Copyright (C) 2005-2007  Matthew A. Nicholson
00005  * Copyright (C) 2005-2007  Digium, Inc.
00006  * 
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License version 2.1 as published by the Free Software Foundation.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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          // these values are taken from manager.h in the asterisk source
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

Generated on Thu Jul 3 01:32:42 2008 for Astxx by  doxygen 1.5.6