# The following meta-model has an inheritance relation: mm_cs = """ MyAbstractClass:Class { abstract = True; } MyConcreteClass:Class :Inheritance (MyConcreteClass -> MyAbstractClass) Z:Class myZ:Association (MyAbstractClass -> Z) { target_lower_cardinality = 1; } """ # Note that we didn't give our inheritance link a name. A unique name will be auto-generated by the parser. # A (non-conforming) instance: m_nonconform_cs = """ cc:MyConcreteClass z:Z """ # Check conformance: from state.devstate import DevState from bootstrap.scd import bootstrap_scd from util import loader state = DevState() mmm = bootstrap_scd(state) mm = loader.parse_and_check(state, mm_cs, mmm, "mm") print("should be non-conform:") m_nonconform = loader.parse_and_check(state, m_nonconform_cs, mm, "m_nonconform") # The reason for the non-conformance is that all cardinalities and constraints are inherited. Therefore 'MyConcreteClass' must have at least one outgoing 'myZ' link as well. # We fix the non-conformance by adding this link: m_conform_cs = m_nonconform_cs + """ :myZ (cc -> z) """ # Now everything will be fine print("should be conform:") m_conform = loader.parse_and_check(state, m_conform_cs, mm, "m_conform") print("OK") # On to the next tutorial...