Skip to content

hololinked.core.thing.ThingMeta

Bases: ParameterizedMetaclass

Metaclass for Thing, implements a __post_init__() call and instantiation of a registry for properties', actions' and events' descriptor objects. Accessing properties, actions and events at the class level returns the descriptor object through the DescriptorRegistry implementation. Accessing properties, actions and events at instance level return their values (for example - the value of Property foo being '5'). At instance level, the descriptors can be accessed through the descriptors property of the DescriptorRegistry. Currently __post_init__(), which is run after the user's __init__() method, properties that can be loaded from a database are loaded and written.

UML Diagram

Source code in hololinked\core\meta.py
class ThingMeta(ParameterizedMetaclass):
    """
    Metaclass for `Thing`, implements a `__post_init__()` call and instantiation of a registry for properties', actions'
    and events' descriptor objects. 
    Accessing properties, actions and events at the class level returns the descriptor object through the `DescriptorRegistry`
    implementation. Accessing properties, actions and events at instance level return their values (for example -
    the value of Property `foo` being '5'). At instance level, the descriptors can be accessed through the `descriptors` 
    property of the `DescriptorRegistry`.
    Currently `__post_init__()`, which is run after the user's `__init__()` method, properties that can be 
    loaded from a database are loaded and written. 	

    [UML Diagram](http://localhost:8000/UML/PDF/Thing.pdf)
    """
    def __init__(mcs, name, bases, dict_):
        super().__init__(name, bases, dict_)
        mcs._create_actions_registry()
        mcs._create_events_registry()

    def __call__(mcls, *args, **kwargs):
        instance = super().__call__(*args, **kwargs)
        instance.__post_init__()
        return instance

    def _create_param_container(cls, cls_members: dict) -> None:
        """
        creates `PropertiesRegistry` instead of `param`'s own `Parameters` 
        as the default container for descriptors. All properties have definitions 
        copied from `param`.
        """
        cls._param_container = PropertiesRegistry(cls, cls_members)

    def _create_actions_registry(cls) -> None:
        """
        creates `Actions` instead of `param`'s own `Parameters` 
        as the default container for descriptors. All actions have definitions 
        copied from `param`.
        """
        cls._actions_registry = ActionsRegistry(cls)

    def _create_events_registry(cls) -> None:
        """
        creates `Events` instead of `param`'s own `Parameters` 
        as the default container for descriptors. All events have definitions 
        copied from `param`.
        """
        cls._events_registry = EventsRegistry(cls)

    @property
    def properties(cls) -> "PropertiesRegistry":
        """
        Container object for Property descriptors. Returns `PropertiesRegistry` instance instead of `param`'s own 
        `Parameters` instance. 
        """
        return cls._param_container

    @property
    def actions(cls) -> "ActionsRegistry":
        """Container object for Action descriptors"""
        return cls._actions_registry

    @property
    def events(cls) -> "EventsRegistry":
        """Container object for Event descriptors"""
        return cls._events_registry

Attributes

actions property

actions: ActionsRegistry

Container object for Action descriptors

events property

events: EventsRegistry

Container object for Event descriptors

properties property

properties: PropertiesRegistry

Container object for Property descriptors. Returns PropertiesRegistry instance instead of param's own Parameters instance.