include "primitives.alh"
include "object_operations.alh"
include "modelling.alh"

SimpleAttribute Action {
    name = "Action"
}
SimpleAttribute Boolean {
    name = "Boolean"
}
SimpleAttribute String {
    name = "String"
}
SimpleAttribute Natural {
    name = "Natural"
}

Class Diagram{
    name = "Diagram"
    name : String
    author : String
    description : String
    lower_cardinality = 1
    upper_cardinality = 1
}

Class Class{
    name = "Class"
    name : String
    constructor_body? : Action
    destructor? : Action
    default : Boolean
    external : Boolean
}

Association diagram_classes(Diagram, Class){
    name = "diagram_classes"
    target_lower_cardinality = 1
}

Class Attribute{
    name = "Attribute"
    name : String
}
Association class_attributes(Class, Attribute){
    name = "class_attributes"
}

Class Method{
    name = "Method"
    name : String
    body : Action
}

Association association(Class, Class){
    name = "association"
    name : String
    source_upper_cardinality = 1
}

Association inheritance(Class, Class){
    name = "inheritance"
    priority ?: Natural
    source_upper_cardinality = 1
}

Class State{
    name = "State"
    name : String
}

Class BasicState : State{
    name = "BasicState"
    isInitial : Boolean
    onEntryScript? : Action
    onExitScript? : Action
}

Class Raise{
    name = "Raise"
    event : String
    scope? : String
    target? : String
    parameter? : Action
}
Association onEntryRaise (BasicState, Raise) {
    name = "onEntryRaise"
}
Association onExitRaise (BasicState, Raise) {
    name = "onExitRaise"
}

Association behaviour(Class, BasicState){
    name = "behaviour"
    target_lower_cardinality = 1
    target_upper_cardinality = 1
}

Association state_onentry_raises(BasicState, Raise){
    name = "state_onentry_raises"
    order : Natural
}
Association state_onexit_raises(BasicState, Raise){
    name = "state_onexit_raises"
    order : Natural
}

Class CompositeState : BasicState{
    name = "CompositeState"
}

Association composite_children(CompositeState, State){
    name = "composite_children"
    source_upper_cardinality = 1
}

Class ParallelState : BasicState{
    name = "ParallelState"
}
Association parallel_children(ParallelState, CompositeState){
    name = "parallel_children"
    source_upper_cardinality = 1
}

Class HistoryState : State{
    name = "HistoryState"
}

Association transition(State, State){
    name = "transition"
    name: String
    cond? : Action
    script? : Action
    after? : Action
    event? : String
    source_upper_cardinality = 1
}
Association transition_raises(transition, Raise){
    name = "transition_raises"
    order : Natural
}
