Changeset 3330 for Core/branches/0075_TR_SCRIPTING/Event/src/Event.cpp
- Timestamp:
- 01/30/10 13:18:29 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
Core/branches/0075_TR_SCRIPTING/Event/src/Event.cpp
r3308 r3330 34 34 35 35 #include "EventQueue.hpp" 36 #include "EventService.hpp" 36 37 37 38 #include <Zen/Core/Scripting/forward_declarations.hpp> … … 44 45 namespace Event { 45 46 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 46 Event_impl::Event_impl(Event Queue& _queue)47 : m_ queue(_queue)47 Event_impl::Event_impl(EventService& _service) 48 : m_service(_service) 48 49 , m_connections() 49 50 , m_pMutex(Threading::MutexFactory::create()) … … 114 115 Event_impl::getScriptModule() 115 116 { 116 return m_ queue.getScriptModule();117 return m_service.getScriptModule(); 117 118 } 118 119 119 120 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ 120 121 I_Connection& 121 Event_impl::connect(pAction_type _pAction )122 Event_impl::connect(pAction_type _pAction, I_EventQueue* _pQueue) 122 123 { 123 124 pConnection_type pConnection = new Connection_type(this, _pAction); 124 125 125 126 Threading::CriticalSection guard(m_pMutex); 127 126 128 m_connections.push_back(pConnection); 129 if (_pQueue) 130 { 131 EventQueue* pQueue = dynamic_cast<EventQueue*>(_pQueue); 132 133 if (pQueue) 134 { 135 m_queues.insert(pQueue); 136 } 137 } 138 else 139 { 140 // Dispatch to the default queue. 141 m_queues.insert(dynamic_cast<EventQueue*>(&m_service.getEventQueue("default"))); 142 } 127 143 128 144 return *pConnection; … … 133 149 Event_impl::disconnect(Connection_impl* _pConnection) 134 150 { 151 // TODO Keep a refrence count for the queues and 152 // when the last connection is disconnected for a 153 // given queue, remove it from the set. 154 135 155 Threading::CriticalSection guard(m_pMutex); 136 156 … … 146 166 Event_impl::fireEvent(boost::any _argument) 147 167 { 148 m_queue.queueEvent(this, _argument); 168 Threading::CriticalSection guard(m_pMutex); 169 170 for(Queues_type::iterator iter = m_queues.begin(); iter != m_queues.end(); iter++) 171 { 172 (*iter)->queueEvent(this, _argument); 173 } 149 174 } 150 175 … … 182 207 Event_impl::connectScript(boost::any _scriptObject, boost::any _scriptFunction) 183 208 { 184 ScriptAction* pRawAction = new ScriptAction(m_ queue.getScriptObject()->getModule(),209 ScriptAction* pRawAction = new ScriptAction(m_service.getScriptObject()->getModule(), 185 210 _scriptObject, _scriptFunction); 186 211 187 212 pAction_type pAction(pRawAction, boost::bind(&Event_impl::destroyScriptAction, this, _1)); 188 return connect(pAction); 213 214 return connect(pAction, &m_service.getEventQueue("script")); 189 215 } 190 216
