Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Event Class Reference

#include <switch_swigable_cpp.h>

Collaboration diagram for Event:

Collaboration graph
[legend]

Public Member Functions

SWITCH_DECLARE_CONSTRUCTOR Event (const char *type, const char *subclass_name=NULL)
SWITCH_DECLARE_CONSTRUCTOR Event (switch_event_t *wrap_me, int free_me=0)
virtual SWITCH_DECLARE_CONSTRUCTOR ~Event ()
const char * serialize (const char *format=NULL)
bool setPriority (switch_priority_t priority=SWITCH_PRIORITY_NORMAL)
const char * getHeader (char *header_name)
char * getBody (void)
const char * getType (void)
bool addBody (const char *value)
bool addHeader (const char *header_name, const char *value)
bool delHeader (const char *header_name)
bool fire (void)
 Event (const char *type, const char *subclass_name=NULL)
 Event (switch_event_t *wrap_me, int free_me=0)
virtual ~Event ()
const char * serialize (const char *format=NULL)
bool setPriority (switch_priority_t priority=SWITCH_PRIORITY_NORMAL)
char * getHeader (char *header_name)
char * getBody (void)
const char * getType (void)
bool addBody (const char *value)
bool addHeader (const char *header_name, const char *value)
bool delHeader (const char *header_name)
bool fire (void)

Data Fields

switch_event_tevent
char * serialized_string
int mine
switch_event_tevent
char * serialized_string

Constructor & Destructor Documentation

SWITCH_DECLARE_CONSTRUCTOR Event::Event const char *  type,
const char *  subclass_name = NULL
 

00141 {
00142         switch_event_types_t event_id;
00143         
00144         if (switch_name_event(type, &event_id) != SWITCH_STATUS_SUCCESS) {
00145                 event_id = SWITCH_EVENT_MESSAGE;
00146         }
00147 
00148         switch_event_create_subclass(&event, event_id, subclass_name);
00149         serialized_string = NULL;
00150         mine = 1;
00151 }

Here is the call graph for this function:

SWITCH_DECLARE_CONSTRUCTOR Event::Event switch_event_t wrap_me,
int  free_me = 0
 

00154 {
00155         event = wrap_me;
00156         mine = free_me;
00157         serialized_string = NULL;
00158 }

SWITCH_DECLARE_CONSTRUCTOR Event::~Event  )  [virtual]
 

00161 {
00162 
00163         if (serialized_string) {
00164                 free(serialized_string);
00165         }
00166 
00167         if (event && mine) {
00168                 switch_event_destroy(&event);
00169         }
00170 }

Here is the call graph for this function:

Event::Event const char *  type,
const char *  subclass_name = NULL
 

Event::Event switch_event_t wrap_me,
int  free_me = 0
 

virtual Event::~Event  )  [virtual]
 


Member Function Documentation

bool Event::addBody const char *  value  ) 
 

bool Event::addBody const char *  value  ) 
 

00275 {
00276         this_check(false);
00277 
00278         if (event) {
00279                 return switch_event_add_body(event, "%s", value) == SWITCH_STATUS_SUCCESS ? true : false;
00280         }
00281         
00282         return false;
00283 }

Here is the call graph for this function:

bool Event::addHeader const char *  header_name,
const char *  value
 

bool Event::addHeader const char *  header_name,
const char *  value
 

00252 {
00253         this_check(false);
00254 
00255         if (event) {
00256                 return switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, value) == SWITCH_STATUS_SUCCESS ? true : false;
00257         }
00258 
00259         return false;
00260 }

Here is the call graph for this function:

bool Event::delHeader const char *  header_name  ) 
 

bool Event::delHeader const char *  header_name  ) 
 

00263 {
00264         this_check(false);
00265 
00266         if (event) {
00267                 return switch_event_del_header(event, header_name) == SWITCH_STATUS_SUCCESS ? true : false;
00268         }
00269 
00270         return false;
00271 }

Here is the call graph for this function:

bool Event::fire void   ) 
 

bool Event::fire void   ) 
 

00211 {
00212 
00213         this_check(false);
00214 
00215         if (!mine) {
00216                 switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Not My event!\n");
00217                 return false;
00218         }
00219 
00220         if (event) {
00221                 switch_event_t *new_event;
00222                 if (switch_event_dup(&new_event, event) == SWITCH_STATUS_SUCCESS) {
00223                         switch_event_fire(&new_event);
00224                         return true;
00225                 }
00226         }
00227         return false;
00228 }

Here is the call graph for this function:

char* Event::getBody void   ) 
 

char * Event::getBody void   ) 
 

00286 {
00287         
00288         this_check((char *)"");
00289 
00290         if (event) {
00291                 return switch_event_get_body(event);
00292         }
00293         
00294         return NULL;
00295 }

Here is the call graph for this function:

char* Event::getHeader char *  header_name  ) 
 

const char * Event::getHeader char *  header_name  ) 
 

00242 {
00243         this_check("");
00244 
00245         if (event) {
00246                 return switch_event_get_header(event, header_name);
00247         }
00248         return NULL;
00249 }

Here is the call graph for this function:

const char* Event::getType void   ) 
 

const char * Event::getType void   ) 
 

00298 {
00299         this_check("");
00300 
00301         if (event) {
00302                 return switch_event_name(event->event_id);
00303         }
00304         
00305         return (char *) "invalid";
00306 }

Here is the call graph for this function:

const char* Event::serialize const char *  format = NULL  ) 
 

const char * Event::serialize const char *  format = NULL  ) 
 

00174 {
00175         int isxml = 0;
00176 
00177         this_check("");
00178 
00179         if (serialized_string) {
00180                 free(serialized_string);
00181         }
00182 
00183         if (!event) {
00184                 return "";
00185         }
00186 
00187         if (format && !strcasecmp(format, "xml")) {
00188                 isxml++;
00189         }
00190 
00191         if (isxml) {
00192                 switch_xml_t xml;
00193                 if ((xml = switch_event_xmlize(event, SWITCH_VA_NONE))) {
00194                         serialized_string = switch_xml_toxml(xml, SWITCH_FALSE);
00195                         switch_xml_free(xml);
00196                         return serialized_string;
00197                 } else {
00198                         return "";
00199                 }
00200         } else {
00201                 if (switch_event_serialize(event, &serialized_string, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
00202                         return serialized_string;
00203                 }
00204         }
00205         
00206         return "";
00207 
00208 }

Here is the call graph for this function:

bool Event::setPriority switch_priority_t  priority = SWITCH_PRIORITY_NORMAL  ) 
 

bool Event::setPriority switch_priority_t  priority = SWITCH_PRIORITY_NORMAL  ) 
 

00231 {
00232         this_check(false);
00233 
00234         if (event) {
00235         switch_event_set_priority(event, priority);
00236                 return true;
00237     }
00238         return false;
00239 }

Here is the call graph for this function:


Field Documentation

switch_event_t* Event::event
 

switch_event_t* Event::event
 

int Event::mine
 

char* Event::serialized_string
 

char* Event::serialized_string
 


The documentation for this class was generated from the following files:
Generated on Mon May 26 22:06:54 2008 for FreeSWITCH by  doxygen 1.3.9.1