Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members

event_filtering.h

00001 //-*- C++ -*-
00002 //
00003 #ifndef __IGSLISTENER__event_filtering_h__
00004 #define __IGSLISTENER__event_filtering_h__
00005 
00006 #include "common.h"
00007 #include "event_filter.h"
00008 #include <vector>
00009 #include <string>
00010 
00011 namespace listener { 
00012 
00033   /*__LICENCE_HERE__*/
00034 
00035   class IGSLISTENER EventFiltering: public EventFilter {
00036   public:
00037     virtual ~EventFiltering() ;
00038     virtual bool filter(Event* e) ;
00039 
00043     template <class EVENT>
00044     void register_for_event() {
00045       event_types_.push_back(typeid(EVENT).name()) ;
00046     }
00047 
00051     template <class EVENT>
00052     void unregister_for_event() {
00053       std::vector<std::string>::iterator it = 
00054         std::find(event_types_.begin(), event_types_.end(), typeid(EVENT).name()) ;
00055       if (it != event_types_.end())
00056         event_types_.erase(it) ;
00057     }
00058 
00059   private:
00060     // typeid copy ctor is private, uses name instead
00061     std::vector<std::string> event_types_ ;
00062 
00063   } ;
00064 
00065   // ===================================
00066 
00067   template <typename EVENT>
00068   class FilterForEvent: public EventFiltering {
00069   public:
00070     FilterForEvent() ;
00071     virtual ~FilterForEvent() ;
00072     virtual bool filter(EVENT* e) = 0 ;
00073     virtual bool filter(Event* e) ;
00074   } ;
00075 
00076 }
00077 
00078 #include "inline_src/event_filtering.hxx"
00079 #endif

Generated on Mon Jan 30 11:57:50 2006 for EventListener by  doxygen 1.3.9.1