/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : Link.pkg */ /* Version : 22 Mai 2000 */ /* Link struct and basic functions */ /* */ /***************************************************************************************/ struct Link = [ LINKsource : Module , /* outgoing module */ LINKevent : S , /* event */ LINKdestination : Module , /* incoming module */ LINKaction : S , /* action */ LINKparameter : S , /* user parameter */ LINKcondition : S /* condition */ ] mkLink ;; /**************************************************************************************** Interface function prototypes ****************************************************************************************/ proto MODULE_GetPathName = fun [Site Module Module] S;; proto MODULE_GetName = fun [Module] S;; /**************************************************************************************** create link between two modules ****************************************************************************************/ fun LINK_RealCreation (source, event, destination, action, sParameter, sCondition) = if source == nil || event == nil || destination == nil || action == nil then nil else mkLink [source event destination action sParameter sCondition] ;; /**************************************************************************************** compare link and parameter ****************************************************************************************/ fun LINK_CompareAll (elt, param) = let param -> [source event destination action parame cond] in (source == elt.LINKsource) && (destination == elt.LINKdestination) && (! strcmpi event elt.LINKevent) && (! strcmpi action elt.LINKaction) && (! strcmpi parame elt.LINKparameter) && (! strcmpi cond elt.LINKcondition) ;; /**************************************************************************************** compare link and parameter but not event ****************************************************************************************/ fun LINK_CompareAllExceptEvent (elt, param) = let param -> [source destination action parame cond] in (source == elt.LINKsource) && (destination == elt.LINKdestination) && (! strcmpi action elt.LINKaction) && (! strcmpi parame elt.LINKparameter) && (! strcmpi cond elt.LINKcondition) ;; /**************************************************************************************** compare link and parameter but not action ****************************************************************************************/ fun LINK_CompareAllExceptAction (elt, param) = let param -> [source event destination parame cond] in (source == elt.LINKsource) && (! strcmpi event elt.LINKevent) && (destination == elt.LINKdestination) && (! strcmpi parame elt.LINKparameter) && (! strcmpi cond elt.LINKcondition) ;; /**************************************************************************************** compare links data ****************************************************************************************/ fun LINK_Compare (link1, link2) = (link1.LINKsource == link2.LINKsource) && (link1.LINKdestination == link2.LINKdestination) && (! strcmpi link1.LINKevent link2.LINKevent) && (! strcmpi link1.LINKaction link2.LINKaction) ;; /**************************************************************************************** compare links data ****************************************************************************************/ fun LINK_CompareStrBySource (link1, link2) = let strcmpi MODULE_GetName link1.LINKsource MODULE_GetName link2.LINKsource -> result in if result != 0 then result else let strcmpi link1.LINKevent link2.LINKevent -> result in if result != 0 then result else let strcmpi MODULE_GetName link1.LINKdestination MODULE_GetName link2.LINKdestination -> result in if result != 0 then result else strcmpi link1.LINKaction link2.LINKaction ;; /**************************************************************************************** compare links data ****************************************************************************************/ fun LINK_CompareStrByDestination (link1, link2) = let strcmpi MODULE_GetName link1.LINKdestination MODULE_GetName link2.LINKdestination -> result in if result != 0 then result else let strcmpi link1.LINKaction link2.LINKaction -> result in if result != 0 then result else let strcmpi MODULE_GetName link1.LINKsource MODULE_GetName link2.LINKsource -> result in if result != 0 then result else strcmpi link1.LINKevent link2.LINKevent ;; /**************************************************************************************** compare link modules ****************************************************************************************/ fun LINK_CompareModules (link, param) = let param -> [module1 module2] in ((link.LINKsource == module1) && (link.LINKdestination == module2)) || ((link.LINKsource == module2) && (link.LINKdestination == module1)) ;; /**************************************************************************************** return true if destination module is the same as the module in parameter ****************************************************************************************/ fun LINK_CompareDestination (link, module) = link.LINKdestination == module ;; fun LINK_DestinationCompare (module, link) = link.LINKdestination == module ;; /**************************************************************************************** return true if source module is the same as the module in parameter ****************************************************************************************/ fun LINK_CompareSource (link, module) = link.LINKsource == module ;; fun LINK_SourceCompare (module, link) = link.LINKsource == module ;; /**************************************************************************************** return true if source or destination module is the same as the module in parameter ****************************************************************************************/ fun LINK_ModuleCompare (module, link) = link.LINKsource == module || link.LINKdestination == module ;; /**************************************************************************************** return true if source and destination module is the same as the module in parameter ****************************************************************************************/ /* fun LINK_ValidateModule (module, link) = link.LINKsource == module && link.LINKdestination == module ;; */ /**************************************************************************************** return true if source and destination module are the same ****************************************************************************************/ /* fun LINK_SameModule (link) = link.LINKsource == link.LINKdestination ;; */ /*************************************************************************************** build link definition from source ***************************************************************************************/ fun LINK_BuildLinkDef (site, link) = let if IsEmptyString link.LINKparameter then "_" else (link.LINKparameter) -> parameter in let if IsEmptyString link.LINKcondition then "_" else (link.LINKcondition) -> condition in (link.LINKevent)::(MODULE_GetPathName site link.LINKdestination link.LINKsource)::(link.LINKaction)::parameter::"_"::condition::nil ;; /*************************************************************************************** build links definition from source ***************************************************************************************/ fun LINK_GetLinksDefinitions (site, linkList) = if linkList == nil then nil else let LINK_BuildLinkDef site hd linkList -> lineList in lineList::(LINK_GetLinksDefinitions site tl linkList) ;; fun LINK_CompareCompleteSource (link, param) = let param -> [source event] in (link.LINKsource == source) && (!strcmpi link.LINKevent event) ;; fun LINK_CompareCompleteDestination (link, param) = let param -> [destination action] in (link.LINKdestination == destination) && (!strcmpi link.LINKaction action) ;; /**************************************************************************************** modify module destination ****************************************************************************************/ fun LINK_SetDestination (link, destination) = set link.LINKdestination = destination ;; /**************************************************************************************** modify module source ****************************************************************************************/ fun LINK_SetSource (link, source) = set link.LINKsource = source ;; fun LINK_GetPredecessors (linkList) = if linkList == nil then nil else let linkList -> [cur next] in (cur.LINKsource)::(LINK_GetPredecessors next) ;; fun LINK_GetSuccessors (linkList) = if linkList == nil then nil else let linkList -> [cur next] in (cur.LINKdestination)::(LINK_GetSuccessors next) ;;