indexing description: "[ Shared registry of known XML node processors. ]" date: "$Date$" revision: "$Revision$" class EM_GOOF_LOADER_NODE_PROCESSOR_REGISTRY feature {NONE} -- Access processor (a_name: STRING): EM_GOOF_LOADER_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 := (Processor_registry @ a_name).twin Result.make ensure Result_exists: Result /= Void end feature -- Status setting level_factory: EM_GOOF_LOADER_LEVEL_FACTORY -- Reference to the goof level factory. level: EM_GOOF_PHYSICS is -- Map that is built. do Result := level_factory.level end set_level_factory (a_factory: EM_GOOF_LOADER_LEVEL_FACTORY) is -- Set level reference. do level_factory := a_factory ensure level_factory_set: level_factory = a_factory end processor_registered (a_processor: EM_GOOF_LOADER_NODE_PROCESSOR): BOOLEAN is -- Is `a_processor' registered? do Result := Processor_registry.has_item (a_processor) end feature -- Basic operations register_processor (a_processor: EM_GOOF_LOADER_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) a_processor.set_level_factory(level_factory) 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 [EM_GOOF_LOADER_NODE_PROCESSOR, STRING] is -- System-wide registry for known level 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) ensure Result_exists: Result /= Void end Allowed_subnode_registry: DS_HASH_TABLE [ARRAY [STRING], STRING] is -- System-wide registry for known level 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) end end