indexing description: "[ Shared registry of known XML node processors. ]" author: "Patrick Schoenbach, Michela Pedroni" author: "adapted for XAE by Fabrizio Steiner" date: "$Date$" revision: "$Revision$" class NODE_PROCESSOR_REGISTRY feature {NONE} -- Access processor (a_name: STRING): NODE_PROCESSOR is -- Node processor named `a_name' require name_exists: a_name /= Void name_not_empty: not a_name.is_empty element_exists: has_processor (a_name) do Result := clone (Processor_registry @ a_name); Result.make ensure Result_exists: Result /= Void end feature -- Status setting processor_registered (a_processor: NODE_PROCESSOR): BOOLEAN is -- Is `a_processor' registered? do Result := Processor_registry.has_item (a_processor) end feature -- Basic operations pool: OBJECT_POOL -- Reference to the object pool set_pool (a_pool: OBJECT_POOL) is -- Set object pool reference. do pool := a_pool end register_processor (a_processor: NODE_PROCESSOR) is -- Register `a_processor' in registry. require processor_exists: a_processor /= Void not_registered: not processor_registered (a_processor) do Processor_registry.force (a_processor, a_processor.name) ensure registered: Processor_registry.has_item (a_processor) end register_allowed_subnode (a_parent_name: STRING; a_subnode_name: STRING) is -- Register processor with name `a_subnode_name' as allowed subnode of processor with name `a_parent_name'. -- Use `register_processor' for new node types and -- `register_allowed_subnode' for registering their subnode types. local a: ARRAY [STRING] do if Allowed_subnode_registry.has (a_parent_name) then Allowed_subnode_registry.item (a_parent_name).force (a_subnode_name, Allowed_subnode_registry.item (a_parent_name).count + 1) else a := << a_subnode_name >> a.compare_objects Allowed_subnode_registry.force ( a, a_parent_name) end end feature {NONE} -- Status report has_processor (a_name: STRING): BOOLEAN is -- Is processor named `a_name' available? require name_exists: a_name /= Void name_not_empty: not a_name.is_empty do Result := Processor_registry.has (a_name) end feature {NONE} -- Constants Default_registry_capacity: INTEGER is 100 -- Default capacity of registry feature {NONE} -- Implementation Processor_registry: DS_HASH_TABLE [NODE_PROCESSOR, STRING] is -- System-wide registry for known map node processors -- Use `register_processor' for new node types and -- `register_allowed_subnode' for registering their subnode types. once create Result.make (Default_registry_capacity) Result.put (create {GAME_NODE_PROCESSOR}.make, "game") Result.put (create {SCENE_NODE_PROCESSOR}.make, "scene") Result.put (create {AREA_NODE_PROCESSOR}.make, "area") Result.put (create {ACTIONS_NODE_PROCESSOR}.make, "actions") Result.put (create {SHOW_SCENE_NODE_PROCESSOR}.make, "show_scene") Result.put (create {SHOW_CLOSEUP_NODE_PROCESSOR}.make, "show_closeup") Result.put (create {PICKUP_NODE_PROCESSOR}.make, "pickup") Result.put (create {CHANGE_SETTING_NODE_PROCESSOR}.make, "change_setting") Result.put (create {HIDE_CLOSEUP_NODE_PROCESSOR}.make, "hide_closeup") Result.put (create {REMOVE_NODE_PROCESSOR}.make, "remove") Result.put (create {ITEM_NODE_PROCESSOR}.make, "item") Result.put (create {CLOSEUP_NODE_PROCESSOR}.make, "closeup") Result.put (create {OPTION_NODE_PROCESSOR}.make, "option") Result.put (create {KNF_NODE_PROCESSOR}.make, "knf") Result.put (create {DNF_NODE_PROCESSOR}.make, "dnf") Result.put (create {ANIMATION_NODE_PROCESSOR}.make, "animation") Result.put (create {SETTING_NODE_PROCESSOR}.make, "setting") Result.put (create {REPOSITORY_ITEM_NODE_PROCESSOR}.make, "repository_item") Result.put (create {KEYFRAME_NODE_PROCESSOR}.make, "keyframe") Result.put (create {TIMER_NODE_PROCESSOR}.make, "timer") ensure Result_exists: Result /= Void Result_not_empty: not Result.is_empty end Allowed_subnode_registry: DS_HASH_TABLE [ARRAY [STRING], STRING] is -- System-wide registry for known map node processors -- Use `register_processor' for new node types and -- `register_allowed_subnode' for registering their subnode types. local a: ARRAY [STRING] once create Result.make (Default_registry_capacity) a := << "scene" >> a.compare_objects Result.put (a, "game") a := << "area", "item", "timer" >> a.compare_objects Result.put (a, "scene") a := << "actions", "closeup" >> a.compare_objects Result.put (a, "area") a := << "actions", "closeup", "knf", "dnf","animation" >> a.compare_objects Result.put (a, "item") a := << "show_scene","show_closeup","pickup","change_setting","hide_closeup","remove" >> a.compare_objects Result.put (a, "actions") a := << "option" >> a.compare_objects Result.put (a, "closeup") a := << "actions" >> a.compare_objects Result.put (a, "option") a := << "setting","repository_item" >> a.compare_objects Result.put (a, "knf") a := << "setting","repository_item" >> a.compare_objects Result.put (a, "dnf") a := << "knf","dnf" >> a.compare_objects Result.put (a, "show_scene") a := << "knf","dnf" >> a.compare_objects Result.put (a, "show_closeup") a := << "knf","dnf" >> a.compare_objects Result.put (a, "pickup") a := << "knf","dnf" >> a.compare_objects Result.put (a, "remove") a := << "knf","dnf" >> a.compare_objects Result.put (a, "hide_closeup") a := << "knf","dnf" >> a.compare_objects Result.put (a, "change_setting") a := << "keyframe" >> a.compare_objects Result.put (a, "animation") a := << "actions","knf","dnf" >> a.compare_objects Result.put (a, "timer") end end