indexing description: "Information on a class of the system for XMI export" date: "$Date$" revision: "$Revision$" class XMI_CLASS inherit XMI_TYPE redefine code end create make feature --Initialization make (id: INTEGER; id_package: INTEGER c: CLASS_C) is -- Initialization of `Current' -- assign `id' to `xmi_id' -- assign `id_package' to `id_model' -- assign `c' to `compiled_class'. local c_ast: CLASS_AS do create associations.make create generalizations.make create features.make xmi_id := id id_model := id_package compiled_class := c if compiled_class.is_basic then name := compiled_class.name name.to_lower else name := compiled_class.name_in_upper end if compiled_class.has_ast and compiled_class.generics /= Void then c_ast := compiled_class.ast name.append (" ") name.append (c_ast.generics_as_string) end end feature -- Access compiled_class: CLASS_C -- Class from which `Current' is a representation. generalizations: LINKED_LIST [XMI_GENERALIZATION] -- Relations of inheritance from which `Current' is -- either subtype or supertype. features: LINKED_LIST [XMI_FEATURE] -- Attributes and operations defined in `Current'. id_model: INTEGER -- Number identifying the model (package) to which `Current' belongs. feature -- Status report is_subtype (g: XMI_GENERALIZATION): BOOLEAN is -- Is `Current' subtype of relation `g'? require current_involved_in_g: generalizations.has (g) do Result := (g.subtype = Current) ensure result_set: Result = (g.subtype = Current) end is_supertype (g: XMI_GENERALIZATION): BOOLEAN is -- Is `Current' supertype of relation `g'? require current_involved_in_g: generalizations.has (g) do Result := (g.supertype = Current) ensure result_set: Result = (g.supertype = Current) end is_generalized: BOOLEAN is -- Is `Current' subtype of an item in `generalizations'? do Result := false from generalizations.start until (Result = true) or else generalizations.after loop Result := is_subtype (generalizations.item) generalizations.forth end end is_specialized: BOOLEAN is -- Is `Current' subtype of an item in `generalizations'? do Result := false from generalizations.start until (Result = true) or else generalizations.after loop Result := is_supertype (generalizations.item) generalizations.forth end end feature -- Element change add_generalization (g: XMI_GENERALIZATION) is -- Adds `g' to `generalization'. require new_generalization_not_void: g /= Void class_involved: g.subtype = Current or else g.supertype = Current do generalizations.extend (g) ensure new_generalization_added: generalizations.has (g) end add_feature (f: XMI_FEATURE) is -- Adds `f' to `features'. require new_feature_not_void: f /= Void do features.extend (f) ensure new_feature_added: features.has (f) end feature -- Action code: STRING is -- XMI representation of the class. local l_association: XMI_ASSOCIATION do Result := "%N") Result.append (name) Result.append ("%N% %%N% %%N% %%N% %%N% %%N% %%N% % %N% %%N") if is_generalized then from generalizations.start Result.append ("%N") until generalizations.after loop if is_subtype (generalizations.item) then Result.append (" ") end generalizations.forth end Result.append ("%N") end if is_specialized then from generalizations.start Result.append ("%N") until generalizations.after loop if is_supertype (generalizations.item) then Result.append (" ") end generalizations.forth end Result.append ("%N") end if not associations.is_empty then Result.append ("%N") from associations.start until associations.after loop l_association := associations.item if l_association.has_type (xmi_id) then Result.append (" %N") end associations.forth end Result.append ("%N") end Result.append ("%N% %%N% %persistence%N% %transient%N% %%N% %%N") Result.append ("%N") from features.start until features.after loop Result.append (features.item.code) features.forth end Result.append ("%N% %%N") end end -- class XMI_CLASS