-- -- 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 . -- ------------------------------------------------------------------------------------------------------------------------------------------------------------ -- APPROACH -- define reusable static functions for features ------------------------------------------------------------------------------------------------------------------------------------------------------------ function_fUML_readStructuralFeature :: FUML_Semantics_Classes_Kernel_Value -> FUML_Syntax_Classes_Kernel_Feature -> FUML_Semantics_Classes_Kernel_Value function_fUML_readStructuralFeature o f | function_Feature_type(f) == FUML_Syntax_Classes_Kernel_Property || function_Feature_type(f) == FUML_Syntax_Extensions_CompositeStructures_Port = if f == FUML_Syntax_Classes_Kernel_FeatureEmpty then FUML_Semantics_Classes_Kernel_ValueEmpty else vl | otherwise = error( "function_fUML_readStructuralFeature - unsupported featuretype " ++ show (function_Feature_type f)) where -- featurevalue fvl = filter (\fv -> (function_FeatureValue_feature fv) == f) (expr2list $ function_Value_CompoundValue_featureValues o) fv = head $ fvl vll = function_FeatureValue_values(fv) vl = if length fvl == 0 || length vll == 0 then FUML_Semantics_Classes_Kernel_ValueEmpty else head vll function_fUML_readStructuralFeatureAsStr :: FUML_Semantics_Classes_Kernel_Value -> String -> FUML_Semantics_Classes_Kernel_Value function_fUML_readStructuralFeatureAsStr o fstr = let f = function_fUML_retrieveFeatureAsStr fstr (function_fUML_oneClassifierType o) in if f == FUML_Syntax_Classes_Kernel_FeatureEmpty then FUML_Semantics_Classes_Kernel_ValueEmpty else function_fUML_readStructuralFeature o f function_fUML_retrieveFeatureAsStr :: String -> FUML_Syntax_Classes_Kernel_Classifier -> FUML_Syntax_Classes_Kernel_Feature function_fUML_retrieveFeatureAsStr fstr cl = -- features from classifier let fs = function_Classifier_feature(cl) in let fl = filter (\f1 -> (function_Feature_type(f1) == FUML_Syntax_Classes_Kernel_Property || function_Feature_type(f1) == FUML_Syntax_Extensions_CompositeStructures_Port) && function_Feature_NamedElement_name(f1) == fstr) (expr2list fs) in if (length fl) == 0 then FUML_Syntax_Classes_Kernel_FeatureEmpty else (head fl)