2005-11-01 16:35:23 +00:00
|
|
|
(*****************************************************************************
|
|
|
|
* su4sml - a SecureUML repository for SML
|
|
|
|
*
|
|
|
|
* component_uml.sml - a design language implementing mds.sig for
|
|
|
|
* component-based systems
|
|
|
|
* Copyright (C) 2005 Achim D. Brucker <brucker@inf.ethz.ch>
|
|
|
|
* Juergen Doser <doserj@inf.ethz.ch>
|
|
|
|
* Burkhart Wolff <bwolff@inf.ethz.ch>
|
|
|
|
*
|
|
|
|
* This file is part of su4sml.
|
|
|
|
*
|
|
|
|
* su4sml 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 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* su4sml 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 this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
******************************************************************************)
|
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
(** ComponentUML is a simple language for component-based modeling. *)
|
|
|
|
structure ComponentUML (* : DESIGN_LANGUAGE*) =
|
2005-11-01 16:35:23 +00:00
|
|
|
struct
|
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
(** The type of resource, plus a path name specifiying the resource.
|
|
|
|
* Resource types can be entities, methods, and attributes.
|
|
|
|
* FIX: using Path for methods is unsafe, there can be severable
|
|
|
|
* methods with the same name, but different signature.
|
|
|
|
*)
|
|
|
|
datatype Resource = Entity of Rep.Classifier
|
|
|
|
| EntityMethod of Rep.operation
|
|
|
|
| EntityAttribute of Rep.attribute
|
2005-11-01 16:35:23 +00:00
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
(* val resource_types = ["Entity","EntityMethod","EntityAttribute"] *)
|
2005-11-01 16:35:23 +00:00
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
(** The resources that are contained in the given resource.
|
|
|
|
* does nothing sensible yet, but perhaps you get the idea...
|
|
|
|
* FIXME: do something sensible
|
|
|
|
*)
|
|
|
|
fun contained_resources (Entity (Rep.Class c)) = List.concat [map EntityMethod (#operations c),
|
|
|
|
map EntityAttribute (#attributes c)]
|
|
|
|
(** The list of all attributes of an entity.
|
|
|
|
*)
|
|
|
|
fun entity_contained_attributes (Entity c) = nil
|
|
|
|
|
|
|
|
(** The list of all side-effect free methods of an entity.
|
|
|
|
*)
|
|
|
|
fun entity_contained_read_methods (Entity c) = nil
|
|
|
|
|
|
|
|
(** The list of all methods with side-effects of an entity *)
|
|
|
|
fun entity_contained_update_methods (Entity c) = nil
|
2005-11-01 16:35:23 +00:00
|
|
|
|
|
|
|
datatype Action = SimpleAction of string * Resource
|
|
|
|
| CompositeAction of string * Resource
|
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
fun actionType_of (SimpleAction (t,_)) = t
|
|
|
|
| actionType_of (CompositeAction (t,_)) = t
|
|
|
|
|
|
|
|
(* val action_names = ["create","read","update","delete","full_access","execute"] *)
|
2005-11-01 16:35:23 +00:00
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
(** The actions possible on the given resource. *)
|
|
|
|
fun actions_of (e as (Entity c)) = [SimpleAction ("create", e),
|
2005-11-01 16:35:23 +00:00
|
|
|
CompositeAction ("read", e),
|
|
|
|
CompositeAction ("update", e),
|
|
|
|
SimpleAction ("delete", e),
|
|
|
|
CompositeAction ("full_access",e)]
|
2006-04-11 16:36:10 +00:00
|
|
|
| actions_of (m as (EntityMethod p)) = [SimpleAction ("execute", m)]
|
|
|
|
| actions_of (a as (EntityAttribute p)) = [SimpleAction ("read", a),
|
2005-11-01 16:35:23 +00:00
|
|
|
SimpleAction ("update", a),
|
|
|
|
CompositeAction ("full_access", a)]
|
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
(** The resource an action acts on. *)
|
2005-11-01 16:35:23 +00:00
|
|
|
fun resource_of (SimpleAction x) = #2 x
|
|
|
|
| resource_of (CompositeAction x) = #2 x
|
|
|
|
|
2006-04-11 16:36:10 +00:00
|
|
|
(** The list of actions a composite actions consists of. *)
|
2005-11-01 16:35:23 +00:00
|
|
|
fun subordinated_actions (SimpleAction _) = nil
|
2006-04-11 16:36:10 +00:00
|
|
|
| subordinated_actions (CompositeAction ("read", e as (Entity c))) =
|
2006-01-22 21:18:26 +00:00
|
|
|
let val read_attributes = List.map (fn x => SimpleAction ("read", x))
|
|
|
|
(entity_contained_attributes e)
|
|
|
|
val read_methods = List.map (fn x => SimpleAction ("execute",x))
|
|
|
|
(entity_contained_read_methods e)
|
2005-11-01 16:35:23 +00:00
|
|
|
in
|
|
|
|
List.concat [read_attributes,read_methods]
|
|
|
|
end
|
2006-04-11 16:36:10 +00:00
|
|
|
| subordinated_actions (CompositeAction ("full_access", e as (Entity c)))
|
2006-01-22 21:18:26 +00:00
|
|
|
= [SimpleAction ("create",e),
|
|
|
|
CompositeAction ("read",e),
|
|
|
|
CompositeAction ("update",e),
|
|
|
|
SimpleAction ("delete",e)]
|
2006-04-11 16:36:10 +00:00
|
|
|
| subordinated_actions (CompositeAction ("update", e as (Entity c))) =
|
2006-01-22 21:18:26 +00:00
|
|
|
let val update_attributes = List.map (fn x => SimpleAction ("update", x))
|
|
|
|
(entity_contained_attributes e)
|
|
|
|
val update_methods = List.map (fn x => SimpleAction ("execute",x))
|
|
|
|
(entity_contained_update_methods e)
|
|
|
|
in
|
|
|
|
List.concat [update_attributes,update_methods]
|
|
|
|
end
|
2006-04-11 16:36:10 +00:00
|
|
|
| subordinated_actions (CompositeAction ("full_access", a as (EntityAttribute ae)))
|
2006-01-22 21:18:26 +00:00
|
|
|
= [SimpleAction ("read", a),
|
|
|
|
SimpleAction ("update", a)]
|
2005-11-01 16:35:23 +00:00
|
|
|
end
|