AToMPM.alc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. include "primitives.alh"
  2. include "object_operations.alh"
  3. include "modelling.alh"
  4. Boolean function main(model : Element):
  5. // Contains three types of models: model, metamodel, and type_mapping.
  6. // Each with the obvious meanings.
  7. // Note that this is only a placeholder that serves as a proof of concept.
  8. // Thus only the check for multiple inheritance is being done, which checks for attributes.
  9. // A full example is given in the Modelverse's internal conformance relation.
  10. log("Performing conformance check!")
  11. // Find all instances of classes
  12. // First, find the class types
  13. Element classes
  14. classes = allInstances(model, "metamodel/Class")
  15. log("Got classes: " + set_to_string(classes))
  16. Element links
  17. String link
  18. Element type_mapping
  19. type_mapping = dict_create()
  20. Element instances
  21. String instance
  22. instances = allInstances(model, "type_mapping/Instance")
  23. while (set_len(instances) > 0):
  24. instance = set_pop(instances)
  25. log("Found instance: " + instance)
  26. log(" Connects to: " + cast_string(set_pop(allAssociationDestinations(model, instance, "type_mapping/TypeLink"))))
  27. log("Association connects: " + instance + " --> " + cast_string(set_pop(allAssociationDestinations(model, instance, "type_mapping/TypeLink"))))
  28. //dict_add(type_mapping, "model/" + string_replace(readAssociationSource(model, link), "type_mapping/instance_", ""), "metamodel/" + string_replace(readAssociationDestination(model, link), "type_mapping/type_", ""))
  29. log("Found type mapping: " + dict_to_string(type_mapping))
  30. // Check if each attribute is there, and satisfies the constraints
  31. instances = dict_keys(type_mapping)
  32. while (set_len(instances) > 0):
  33. instance = set_pop(instances)
  34. log("Found type: " + read_type(model, type_mapping[instance]))
  35. if (read_type(model, type_mapping[instance]) == "metamodel/Class"):
  36. // Got an instance of a Class
  37. log("Got a class instance: " + instance)
  38. // Fetch a list of attributes that should be defined
  39. // TODO
  40. return True!