-- -- Copyright 2014 Alessandro Gerlinger Romero -- -- This file is part of Hybrid fUML. -- -- Hybrid fUML is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- Hybrid fUML is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with Hybrid fUML. If not, see . -- ------------------------------------------------------------------------------------------------------------------------------------------------------------ -- ADD STRUCTURAL FEATURE -- add a value to a structural feature from an object rule_fUML_addStructuralFeature :: FUML_Semantics_Classes_Kernel_Value -> FUML_Syntax_Classes_Kernel_Feature -> FUML_Semantics_Classes_Kernel_Value -> Rule() rule_fUML_addStructuralFeature o f nv = if function_Feature_type(f) == FUML_Syntax_Classes_Kernel_Property || function_Feature_type(f) == FUML_Syntax_Extensions_CompositeStructures_Port then -- allowing to set null value in a property if f == FUML_Syntax_Classes_Kernel_FeatureEmpty || o == FUML_Semantics_Classes_Kernel_ValueEmpty || nv == FUML_Semantics_Classes_Kernel_ValueEmpty then skip else if length fvl == 0 then create nfv do -- create feature function_Value_CompoundValue_featureValues(o) := function_Value_CompoundValue_featureValues(o) `union` {nfv} -- set value function_FeatureValue_values(nfv) := [nv] function_FeatureValue_feature(nfv) := f function_FeatureValue_position(nfv) := 0 else -- set value function_FeatureValue_values(fv) := [nv] else skip where -- featurevalue fvl = filter (\fv -> (function_FeatureValue_feature fv) == f) (expr2list $ function_Value_CompoundValue_featureValues o) fv = head $ fvl -- -- add a value to a structural feature from an object rule_fUML_addStructuralFeatureString :: FUML_Semantics_Classes_Kernel_Value -> String -> FUML_Semantics_Classes_Kernel_Value -> Rule() rule_fUML_addStructuralFeatureString o fstr nv = let f = function_fUML_retrieveFeatureAsStr fstr (function_fUML_oneClassifierType o) in if f == FUML_Syntax_Classes_Kernel_FeatureEmpty then skip else rule_fUML_addStructuralFeature o f nv -- -- add a value to a structural feature from an object created in current step (cannot check the type) rule_fUML_addStructuralFeatureStringWithClassifier :: FUML_Syntax_Classes_Kernel_Classifier -> FUML_Semantics_Classes_Kernel_Value -> String -> FUML_Semantics_Classes_Kernel_Value -> Rule() rule_fUML_addStructuralFeatureStringWithClassifier cl o fstr nv = let f = function_fUML_retrieveFeatureAsStr fstr cl in if f == FUML_Syntax_Classes_Kernel_FeatureEmpty then skip else rule_fUML_addStructuralFeature o f nv