get_slots and is_instance added to readonly api + is_instance implementation

This commit is contained in:
robbe 2025-04-24 12:27:28 +02:00
parent 5e5865d0d5
commit 756b3f30da
2 changed files with 7 additions and 2 deletions

View file

@ -53,7 +53,7 @@ class CDAPI:
return self.bottom.read_outgoing_elements(self.m, type_name)[0]
def is_direct_subtype(self, super_type_name: str, sub_type_name: str):
return sub_type_name in self.direct_sub_types[super_type]
return sub_type_name in self.direct_sub_types[super_type_name]
def is_direct_supertype(self, sub_type_name: str, super_type_name: str):
return super_type_name in self.direct_super_types[sub_type_name]
@ -83,3 +83,6 @@ class CDAPI:
result = self.find_attribute_type(supertype, attr_name)
if result != None:
return result
def get_type(self, type_name: str):
return next(k for k, v in self.type_model_names.items() if v == type_name)

View file

@ -143,7 +143,7 @@ class ODAPI:
typ = self.cdapi.get_type(type_name)
types = set(typ) if not include_subtypes else self.cdapi.transitive_sub_types[type_name]
for type_of_obj in self.bottom.read_outgoing_elements(obj, "Morphism"):
if type_of_obj in types:
if self.get_name(type_of_obj) in types:
return True
return False
@ -262,6 +262,7 @@ def bind_api_readonly(odapi):
'get_target': odapi.get_target,
'get_source': odapi.get_source,
'get_slot': odapi.get_slot,
'get_slots': odapi.get_slots,
'get_slot_value': odapi.get_slot_value,
'get_slot_value_default': odapi.get_slot_value_default,
'get_all_instances': odapi.get_all_instances,
@ -270,6 +271,7 @@ def bind_api_readonly(odapi):
'get_outgoing': odapi.get_outgoing,
'get_incoming': odapi.get_incoming,
'has_slot': odapi.has_slot,
'is_instance': odapi.is_instance,
}
return funcs