如何在 UML 中将 class 方法的调用指定为状态的入口行为
How to specify invocation of a class method as entry behavior of a state in UML
下面如何用UML表示:
I have a class, whose behavior is modeled as a state machine. On entry
to a particular state in that state machine, I want to invoke an
operation (method) of the class instance.
我正在尝试找出捕捉上述关系的正式方法。我知道状态的进入行为可以有不同的类型(例如 FunctionBehavior)。 类 可以有本质上是函数规范的操作(如函数 typedef)。我很困惑如何指定一个函数来实现特定的操作,然后让它从潜在的多个状态进入行为中调用。
引用 2.5 的上层建筑(第 14.2.3.4.3 章第 307 页):
State entry, exit, and doActivity Behaviors
A State may have an associated entry Behavior. This Behavior, if defined, is executed whenever the State is entered through an external Transition. In addition, a State may also have an associated exit Behavior, which, if defined, is executed whenever the State is exited.
A State may also have an associated doActivity Behavior. This Behavior commences execution when the State is entered (but only after the State entry Behavior has completed) and executes concurrently with any other Behaviors that may be associated with the State, until:
- it completes (in which case a completion event is generated) or
- the State is exited, in which case execution of the doActivity Behavior is aborted.
The execution of a doActivity Behavior of a State is not affected by the firing of an internal Transition of that State.
也就是说你可以在class中定义一个操作,在进入状态时执行。你这样显示:
编辑:只需复制下面 Geert 的评论使其防水:-)
The UML specs are quite specific saying that the state has an associated Behavior. The Behavior might be the method of an operation but it doesn't have to be. Since Behavior itself is an abstract meta-class it can be any of Activity, OpaqueBehavior, FunctionBehavior, Interaction, StateMachine or ProtocolStateMachine
下面如何用UML表示:
I have a class, whose behavior is modeled as a state machine. On entry to a particular state in that state machine, I want to invoke an operation (method) of the class instance.
我正在尝试找出捕捉上述关系的正式方法。我知道状态的进入行为可以有不同的类型(例如 FunctionBehavior)。 类 可以有本质上是函数规范的操作(如函数 typedef)。我很困惑如何指定一个函数来实现特定的操作,然后让它从潜在的多个状态进入行为中调用。
引用 2.5 的上层建筑(第 14.2.3.4.3 章第 307 页):
State entry, exit, and doActivity Behaviors
A State may have an associated entry Behavior. This Behavior, if defined, is executed whenever the State is entered through an external Transition. In addition, a State may also have an associated exit Behavior, which, if defined, is executed whenever the State is exited. A State may also have an associated doActivity Behavior. This Behavior commences execution when the State is entered (but only after the State entry Behavior has completed) and executes concurrently with any other Behaviors that may be associated with the State, until:
- it completes (in which case a completion event is generated) or
- the State is exited, in which case execution of the doActivity Behavior is aborted.
The execution of a doActivity Behavior of a State is not affected by the firing of an internal Transition of that State.
也就是说你可以在class中定义一个操作,在进入状态时执行。你这样显示:
编辑:只需复制下面 Geert 的评论使其防水:-)
The UML specs are quite specific saying that the state has an associated Behavior. The Behavior might be the method of an operation but it doesn't have to be. Since Behavior itself is an abstract meta-class it can be any of Activity, OpaqueBehavior, FunctionBehavior, Interaction, StateMachine or ProtocolStateMachine