Skip to content

Commit

Permalink
fix(model): Fix States.functions
Browse files Browse the repository at this point in the history
The definition of `capellacommon.States.functions` was using the
`AbstractFunction` base class to attempt to capture all possible
subclasses, which is not currently supported. Also, it was wrongly using
camelCase instead of snake_case for the lookup attribute.

Fixes #358
  • Loading branch information
Wuestengecko committed Nov 21, 2023
1 parent cfe37c8 commit 0f26cb3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 16 additions & 0 deletions capellambse/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,19 @@ def _reference_attributes(objtype: type[ModelObject], /) -> tuple[str, ...]:
):
attrs.append(i)
return tuple(attrs)


common.set_accessor(
capellacommon.State,
"functions",
common.ReferenceSearchingAccessor(
(
oa.OperationalActivity,
ctx.SystemFunction,
la.LogicalFunction,
pa.PhysicalFunction,
),
"available_in_states",
aslist=common.ElementList,
),
)
4 changes: 2 additions & 2 deletions capellambse/model/crosslayer/capellacommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class AbstractStateMode(c.GenericElement):

regions = c.DirectProxyAccessor(Region, aslist=c.ElementList)

functions: c.Accessor


@c.xtype_handler(None)
class State(AbstractStateMode):
Expand All @@ -45,6 +43,8 @@ class State(AbstractStateMode):
c.GenericElement, "exit", aslist=c.MixedElementList
)

functions: c.Accessor


@c.xtype_handler(None)
class Mode(AbstractStateMode):
Expand Down
10 changes: 0 additions & 10 deletions capellambse/model/crosslayer/fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,6 @@ def __dir__(self) -> list[str]:
),
)

c.set_accessor(
capellacommon.State,
"functions",
c.ReferenceSearchingAccessor(
AbstractFunction,
"availableInStates",
aslist=c.ElementList,
),
)

c.set_accessor(
Function,
"exchanges",
Expand Down

0 comments on commit 0f26cb3

Please sign in to comment.