Warning, /include/Geant4/tools/sg/event_dispatcher is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_event_dispatcher
0005 #define tools_sg_event_dispatcher
0006
0007 // Node that holds "callbacks" that can be triggered when an event_action
0008 // traversed it. A typical example is to handle a mouse resize of the viewer/window
0009 // and response to it by changing some geomtry in the scene graphs (for example
0010 // to arrange that a tools::sg::plots maps the full viewer/window area).
0011
0012 #include "node"
0013 #include "cbks"
0014 #include "event_action"
0015 #include "ecbk"
0016
0017 namespace tools {
0018 namespace sg {
0019
0020 class event_dispatcher : public node {
0021 TOOLS_NODE(event_dispatcher,tools::sg::event_dispatcher,node)
0022 public:
0023 virtual void event(event_action& a_action) {
0024 ecbk::exec_event_cbks(m_cbks.callbacks(),a_action.get_event(),&a_action,this);
0025 }
0026 public:
0027 event_dispatcher():parent(),m_cbks(){}
0028 virtual ~event_dispatcher(){}
0029 public:
0030 event_dispatcher(const event_dispatcher& a_from):parent(a_from),m_cbks(a_from.m_cbks){}
0031 event_dispatcher& operator=(const event_dispatcher& a_from){
0032 parent::operator=(a_from);
0033 m_cbks = a_from.m_cbks;
0034 return *this;
0035 }
0036 public:
0037 const sg::cbks& cbks() const {return m_cbks;}
0038 //sg::cbks& cbks() {return m_cbks;}
0039 void add_callback(bcbk* a_cbk) {m_cbks.add(a_cbk);} //we take ownership of a_cbk
0040 void copy_cbks(const sg::cbks& a_from,bool a_clear = true) {m_cbks.copy(a_from,a_clear);}
0041 void clear_cbks(){m_cbks.clear();}
0042 protected:
0043 sg::cbks m_cbks;
0044 };
0045
0046 }}
0047
0048 #endif