ActiveVariable
- class osaft.core.variable.ActiveVariable(function_call, name=None)[source]
Bases:
BaseActiveVariableVariables that depended on at least one
BaseVariable- Parameters
function_call (Callable[[], Any]) – function signature that defines how
ActiveVariable._valueis computedname (None | str, optional) – Name of the variable
Default:NonePublic Data Attributes:
Returns the value of the attribute.
Inherited from
BaseActiveVariableReturns if an update is needed for the next value retrieval
Inherited from
BaseVariablePublic Methods:
Inherited from
BaseActiveVariableis_computed_by(*variables)Adds the notification dependencies
Inherited from
BaseVariablenotify()Notifies all items in
BaseVariable._variables_to_notifythat a dependent value changed.
- is_computed_by(*variables)
Adds the notification dependencies
- Parameters
variables (
Any) – variables that are referenced in_update()- Raises
TypeError if no arguments are passed
- Return type
None
- notify()
Notifies all items in
BaseVariable._variables_to_notifythat a dependent value changed. Just the information of a changed dependency is passed.- Return type
None
- property name: str
Returns name of the variable.
- Setter
sets
_name- Return type
str
- property needs_update: bool
Returns if an update is needed for the next value retrieval
- Return type
bool
- property value: Any
Returns the value of the attribute. If
ActiveVariable.needs_updateis true, it callsActiveVariable._update()first and then changesActiveVariable._needs_updateto False before returning the value.- Return type
Any