implement 'topification': adding an abstract 'Top'-class to a class diagram, and making all classes inherit from it

This commit is contained in:
Joeri Exelmans 2024-11-22 13:36:45 +01:00
parent daa50d8c82
commit ffc07fd83c
8 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,5 @@
some_class:RAM_Class
top:RAM_Class {
condition = `get_name(this) == "Top"`;
}

View file

@ -0,0 +1,7 @@
# If our class already inherits from another class, then DON'T create an inheritance link
some_class:RAM_Class
any_other_class:RAM_Class
:RAM_Inheritance(some_class -> any_other_class)

View file

@ -0,0 +1,9 @@
# Only create inheritance link once:
some_class:RAM_Class
top:RAM_Class {
condition = `get_name(this) == "Top"`;
}
:RAM_Inheritance (some_class -> top)

View file

@ -0,0 +1,9 @@
some_class:RAM_Class
top:RAM_Class {
condition = `get_name(this) == "Top"`;
}
# Create inheritance link
:RAM_Inheritance (some_class -> top)

View file

@ -0,0 +1 @@
# empty

View file

@ -0,0 +1,5 @@
# Top-class should not yet already exist:
top:RAM_Class {
condition = `get_name(this) == "Top"`;
}

View file

@ -0,0 +1,8 @@
# We create the 'Top'-class with a GlobalCondition, because that's the only way we can control the name of the object to be created.
:GlobalCondition {
condition = ```
top = create_object("Top", "Class")
set_slot_value(top, "abstract", True)
```;
}