orrery.models.GlobalModelRegistry#
- class GlobalModelRegistry[source]#
Bases:
ModelRegistry
A ModelRegistry where Models can be added with an additional identifying prefix, allowing multiple Models of the same name to be added. An example use might be an application which has multiple windows open, where each window has its own set of Models (which might be stored in a ModelRegistry). The prefix allows you to distinguish Models for different windows while still maintaining a single global list of Models
Methods
Add observer to listen to invalidated callback of the specified Model
Add a model to this registry with the specified name
Add observer to listen to changed callback of the specified Model
Return the model in this registry with the specified name
Return a Model containing a list of current model names
Return dictionary of registered model names to models
Register models contained in another registry with this registry
Remove previously added invalidated observer
Remove previously added value changed observer
- add_invalidated_observer(name, callback, **kwargs)#
Add observer to listen to invalidated callback of the specified Model
- add_model(name, model=None, prefix=None)[source]#
Add a model to this registry with the specified name
- Parameters:
name – Name used to reference the model in the registry
prefix – Optional prefix which to be added to the model name
model – The Model to add. If a model is not specified, a new ValueModel will be created
- Returns:
the Model that was added to the registry
- add_observer(name, callback, prefix=None, **kwargs)[source]#
Add observer to listen to changed callback of the specified Model
- get_model(name, prefix=None)[source]#
Return the model in this registry with the specified name
- Return type:
- register_all(registry, prefix=None)[source]#
Register models contained in another registry with this registry
- Parameters:
registry – Registry containing the source models
prefix – Optional prefix which will be added to each model name when they are added to this registry
- remove_invalidated_observer(name, callback_id)#
Remove previously added invalidated observer