Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef tools_sg_event_dispatcher 5 #define tools_sg_event_dispatcher 6 7 // Node that holds "callbacks" that can be tr 8 // traversed it. A typical example is to handl 9 // and response to it by changing some geomtry 10 // to arrange that a tools::sg::plots maps the 11 12 #include "node" 13 #include "cbks" 14 #include "event_action" 15 #include "ecbk" 16 17 namespace tools { 18 namespace sg { 19 20 class event_dispatcher : public node { 21 TOOLS_NODE(event_dispatcher,tools::sg::event 22 public: 23 virtual void event(event_action& a_action) { 24 ecbk::exec_event_cbks(m_cbks.callbacks(),a 25 } 26 public: 27 event_dispatcher():parent(),m_cbks(){} 28 virtual ~event_dispatcher(){} 29 public: 30 event_dispatcher(const event_dispatcher& a_f 31 event_dispatcher& operator=(const event_disp 32 parent::operator=(a_from); 33 m_cbks = a_from.m_cbks; 34 return *this; 35 } 36 public: 37 const sg::cbks& cbks() const {return m_cbks; 38 //sg::cbks& cbks() {return m_cbks;} 39 void add_callback(bcbk* a_cbk) {m_cbks.add(a 40 void copy_cbks(const sg::cbks& a_from,bool a 41 void clear_cbks(){m_cbks.clear();} 42 protected: 43 sg::cbks m_cbks; 44 }; 45 46 }} 47 48 #endif