symbrim.core.registry.Registry

class symbrim.core.registry.Registry(*args: object, **kwargs: dict[str, object])

Bases: Singleton

Registry to keep track of all existing model and connection types in SymBRiM.

Attributes

connections

Return the registered connections.

load_groups

Return the registered load groups.

models

Return the registered models.

Methods

__init__

activate

Activate the instance of the class.

deactivate

Deactivate the instance of the class.

get_from_property

Return all models or connections that could be used as property.

get_from_requirement

Return all models or connections that satisfy the given requirement.

get_matching_load_groups

Return all load groups that could be applied to the given object.

register_connection

Register a new type in the registry.

register_load_group

Register a new load group in the registry.

register_model

Register a new type in the registry.

__init__() None
__weakref__

list of weak references to the object (if defined)

activate() None

Activate the instance of the class.

property connections: frozenset[type]

Return the registered connections.

deactivate() None

Deactivate the instance of the class.

get_from_property(obj: ModelBase | ConnectionBase, prop: str, drop_abstract: bool = True) list[type]

Return all models or connections that could be used as property.

Parameters:
  • obj (ModelBase | ConnectionBase) – The object to get the property from.

  • prop (str) – The name of the property.

  • drop_abstract (bool, optional) – Whether to drop abstract classes, by default True.

Returns:

All models or connections that could be used as property.

Return type:

list[type]

get_from_requirement(requirement: ConnectionRequirement | ModelRequirement, drop_abstract: bool = True) list[type]

Return all models or connections that satisfy the given requirement.

Parameters:
Returns:

All models or connections that satisfy the given requirement.

Return type:

list[type]

get_matching_load_groups(obj: ConnectionBase | ModelBase, drop_abstract: bool = True) list[type]

Return all load groups that could be applied to the given object.

Parameters:
  • obj (ConnectionBase | ModelBase) – The object to get the load groups from.

  • drop_abstract (bool, optional) – Whether to drop abstract classes, by default True.

Returns:

All load groups that could be applied to the given object.

Return type:

list[type]

property load_groups: frozenset[type]

Return the registered load groups.

property models: frozenset[type]

Return the registered models.

register_connection(conn: type) None

Register a new type in the registry.

register_load_group(group: type) None

Register a new load group in the registry.

register_model(model: type) None

Register a new type in the registry.