Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 3 4 #ifndef toolx_X11_dispatcher 5 #define toolx_X11_dispatcher 6 7 #include <X11/Xlib.h> 8 9 #ifdef TOOLS_MEM 10 #include <tools/mem> 11 #endif 12 13 namespace toolx { 14 namespace X11 { 15 16 class dispatcher { 17 protected: 18 #ifdef TOOLS_MEM 19 static const std::string& s_class() { 20 static const std::string s_v("toolx::X11::dispatcher"); 21 return s_v; 22 } 23 #endif 24 public: 25 virtual bool dispatch(XEvent&) = 0; 26 virtual Window window() const = 0; 27 virtual dispatcher* copy() const = 0; 28 public: 29 dispatcher():m_is_valid(true){ 30 #ifdef TOOLS_MEM 31 tools::mem::increment(s_class().c_str()); 32 #endif 33 } 34 virtual ~dispatcher(){ 35 #ifdef TOOLS_MEM 36 tools::mem::decrement(s_class().c_str()); 37 #endif 38 } 39 public: 40 dispatcher(const dispatcher& a_from):m_is_valid(a_from.m_is_valid){ 41 #ifdef TOOLS_MEM 42 tools::mem::increment(s_class().c_str()); 43 #endif 44 } 45 dispatcher& operator=(const dispatcher& a_from) { m_is_valid = a_from.m_is_valid;return *this;} 46 public: 47 bool is_valid() const {return m_is_valid;} 48 void invalidate() {m_is_valid = false;} 49 protected: 50 bool m_is_valid; 51 }; 52 53 }} 54 55 56 #endif