indexing description: "[ An extended weak reference. It provides name (STRING) access and a feature type which can be set to any of the types defined in EM3D_IDENTIFIED_TYPES. ]" date: "$Date$" revision: "$Revision$" class EM3D_IDENTIFIED[ G->EM3D_IDENTIFIED_SUPPORT ] inherit EWG_IDENTIFIED rename ewg_object_id as object_id export {NONE} ewg_id_object redefine dispose end EM3D_IDENTIFIED_SUPPORT undefine is_equal, copy redefine set_name end EM3D_IDENTIFIED_FUNCTIONS export {NONE} all undefine is_equal, copy end EM_SHARED_ERROR_HANDLER export {NONE} all undefine is_equal, copy end feature -- Access object_by_name (a_name: STRING): G is -- Returns either Void or a reference to the corresponding object. do result := id_object( em3d_name_object( type, a_name ) ) end id_object( an_id: INTEGER ): G is -- Returns the object attached to id do result ?= ewg_id_object( an_id ) end feature {EM3D_IDENTIFIED} -- Properties default_name: STRING is -- Generate the default name from the class name once result := "IDENTIFIED" end type: INTEGER is once result := em3d_basic_identified end feature {EM3D_OBJECT_MANAGER} -- Element change set_name (a_name: STRING) is -- Set `name' to `a_name' local nm: STRING do if name /= void and then not a_name.is_equal( name ) then error_handler.raise_warning ( error_codes.em_error_em3d_identified, [ "Resetting the name %""+name.out+"%" to %""+a_name.out+"%" is not very wise!"]) end if name = void or else not a_name.is_equal ( name ) then nm := a_name if object_by_name( a_name ) /= void then check name_already_in_use: false end error_handler.raise_warning ( error_codes.em_error_em3d_identified, [ "Name %""+a_name.out+"%" already in use! Trying %""+a_name.out+object_id.out+"%"!"]) nm := a_name + object_id.out if object_by_name( nm ) /= void then error_handler.raise_error ( error_codes.em_error_em3d_identified, [ "Names %""+a_name.out+"%" and %""+a_name.out+object_id.out+"%" already in use!"]) end end if name /= void then em3d_object_remove_name( type, name ) end em3d_object_set_name ( type, nm, object_id ) Precursor (nm) end ensure then name_set: object_by_name( a_name ) = current end feature {NONE} -- Implementation dispose is -- Perform clean up do Precursor if name /= void then em3d_object_remove_name ( type, name ) end ensure then name_freed: name = void or else object_by_name ( name )=void end invariant valid_type: em3d_is_valid_type( type )>0 -- TODO: Is there a way to have a invaraint type_must_be_constant? constant_type: type = type end