model.base: add method for adding objects to namespaces
This MR implements this feature by adding a method to each relevant namespace, that iterates over the respective NamespaceSets
and adds the object to the first NamespaceSet
with a matching attribute_name
, such as id_short
, type
or name
.
The SubmodelElement collections SubmodelElementCollectionOrderedUniqueSemanticId
and SubmodelElementCollectionUnorderedUniqueSemanticId
both inherit from SubmodelElementCollectionOrdered
and SubmodelElementCollectionUnordered
respectively. Both __init__
methods call super().__init__
(e.g. SubmodelElementCollectionOrdered.__init__
), which creates a NamespaceSet
for self.value
. self.value
is then overwritten by a new NamespaceSet
for the unique semantic_id
functionality, leaving an unused NamespaceSet
in self.namespace_element_sets
.
The functionality implemented in this MR would add new Referable
objects to the first NamespaceSet
in self.namespace_element_sets
, that has id_short
in its attribute_name_list
. For the SubmodelElementCollections
with a UniqueSemanticId
namespace, this would be the unused NamespaceSet
. Thus, this unused NamespaceSet
has to be removed first in the respective __init__
function.
Alongside, this MR also fixes some docstrings and shortens some code.
Merge request reports
Activity
This does what it is supposed to do. The only drawback I see is that we now have 3 functions (
add_referable
,add_qualifier
andadd_extension
) for adding stuff to namespaces. Maybe we could add a "comfort" function that automatically determines the type of what is to be added and calls the correct function of the 3? Or is there a reason to keep it strictly separate?mentioned in commit 9cf6f664