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