mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-24 06:48:13 -06:00
The Python generator emits add_folder() again on a concrete collection class when the folder type narrows: SurfaceCollection.add_folder() returns SurfaceCollection and PolygonCollection.add_folder() returns PolygonCollection, while PdmNestedCollectionBase keeps the declared type. PdmObjectMethod::classKeywordReturnedTypeForSelf() reports the narrowed type, and the super class method check in the generator accepts such an override (same arguments, subclass return type). PdmNestedCollectionBase: subCollectionClassKeyword() names the folder type without creating one, addNewSubCollection() is a template method over createSubCollection() and returns PdmNestedCollectionBase*, and the base virtuals are pure. The leaf polygon containers only override canAddSubCollection(). collection_name() in rips returns the folder name for every nested collection; the class specific name attributes are kept.
16 lines
475 B
Python
16 lines
475 B
Python
from .pdmobject import add_method
|
|
from .resinsight_classes import PdmNestedCollectionBase
|
|
|
|
|
|
@add_method(PdmNestedCollectionBase)
|
|
def collection_name(self: PdmNestedCollectionBase) -> str:
|
|
"""Get the name of this folder
|
|
|
|
The same for every folder class. The class specific attributes
|
|
(surface_user_description, polygon_collection_name) remain for existing scripts.
|
|
|
|
Returns:
|
|
The folder name
|
|
"""
|
|
return self.collection_name_internal().values[0]
|