// Event Observer Interface void dmz::AudioPluginEventSimple::close_event ( const Handle EventHandle, const EventType &Type, const EventLocalityEnum Locality) { EventType current (Type); EventStruct *es (0); while (!es && current) { es = _eventTable.lookup (current.get_handle ()); if (!es) { current.become_parent (); } } if (es && es->sound) { EventModule *eventMod (get_event_module ()); if (_audioMod && eventMod) { Vector pos; if (eventMod->lookup_position (EventHandle, _defaultEventHandle, pos)) { SoundInit init; SoundAttributes attributes; attributes.set_position (pos); _audioMod->play_sound (es->sound, init, attributes); } } } }
// RenderPluginEventOSG Interface dmz::RenderPluginEventOSG::TypeStruct * dmz::RenderPluginEventOSG::_get_type ( const Handle EventHandle, const EventType &Type) { TypeStruct *result (0); EventModule *module = get_event_module (); TypeTable *table (0); EventType event (Type); while (event && !result) { TypeTable *table = _get_type_table (Type); if (table) { ObjectType current; if (module) { module->lookup_object_type (EventHandle, table->TypeAttr, current); } const ObjectType Start (current); while (current && !result) { result = table->map.lookup (current.get_handle ()); if (!result) { result = _create_type (EventHandle, event, current, *table); } if (!result) { current.become_parent (); } } if (result && (current != Start)) { table->map.store (Start.get_handle (), result); } } if (!result) { event.become_parent (); } } return result; }
dmz::Boolean dmz::NetModulePacketCodecBasic::encode_event ( const EventType &Type, const Handle EventHandle, Marshal &outData) { Boolean result (False); EncodeEventStruct *ees (_eventTypeTable.lookup (Type.get_handle ())); if (!ees) { EventType current (Type); current.become_parent (); while (!ees && current) { ees = _eventTypeTable.lookup (current.get_handle ()); current.become_parent (); } } if (ees && _headerCodec) { const Int32 Place (outData.get_place ()); if (_headerCodec->write_header (ees->PacketID, outData)) { if (ees->codec.encode_event (EventHandle, outData)) { outData.set_place (Place); result = _headerCodec->write_header (ees->PacketID, outData); } } } return result; }
/*! \brief Tests if event type is stored in set. \param[in] Type EventType to use in test. \return Returns dmz::True if the \a Type or one of its parents is contained in the set. */ dmz::Boolean dmz::EventTypeSet::contains_type (const EventType &Type) const { Boolean result (False); EventType current (Type); Boolean done (current ? False : True); while (!done) { if (_state.table.lookup (current.get_handle ())) { result = done = True; } else { current.become_parent (); if (!current) { done = True; } } } return result; }
/*! \brief Test if event type is a related type. \param[in] Type EventType to test against. \return Returns dmz::True if \a Type is the same or a parent. */ dmz::Boolean dmz::EventType::is_of_type (const EventType &Type) const { Boolean result (False); EventType current (_context); if (Type) { while (current && !result) { if (Type == current) { result = True; } else { current.become_parent (); } } } return result; }
/*! \brief Finds Config. \details Looks for Config up the EventType tree until Config is found or the root EventType is reached. Uses dmz::Config::lookup_all_config_merged(). \param[in] Name String containing the name of the Config data to find. \param[out] type EventType that the Config was found in. \return Returns a Config object. The Config object will be empty if the named Config can not be found. */ dmz::Config dmz::EventType::find_config (const String &Name, EventType &type) const { Config result; EventType current (_context); while (current) { if (current.get_config ().lookup_all_config_merged (Name, result)) { type = current; current.set_type_context (0); } else { current.become_parent (); } } return result; }
void dmz::EventModuleBasic::_close_event (EventStruct &event) { EventType current (event.type); while (current) { EventObserverStruct *eos (_createTable.lookup (current.get_handle ())); if (eos) { HashTableHandleIterator it; EventObserver *obs (eos->get_first (it)); while (obs) { obs->create_event (event.handle, event.type, event.locality); obs = eos->get_next (it); } } current.become_parent (); } event.closed = True; event.closeTime = _time.get_frame_time (); current = event.type; while (current) { EventObserverStruct *eos (_closeTable.lookup (current.get_handle ())); if (eos) { HashTableHandleIterator it; EventObserver *obs (eos->get_first (it)); while (obs) { obs->close_event (event.handle, event.type, event.locality); obs = eos->get_next (it); } } current.become_parent (); } // Move to end of the table. if (_eventTable.remove (event.handle)) { if (!_eventTable.store (event.handle, &event)) { _log.error << "Internal error: Failed to save event: " << event.handle << " of type: " << event.type.get_name () << endl; _eventCache = 0; delete &event; } } }