interfaces.IDHierarchicalCreatable

A dependencies creatable that has an ID as well as an identifiable hierarchy/encapsulation tree in relation to instances of the same classes. This means, instances of IDHierarchicalCreatables can have parents and children, along with the ability to search up and down the "family tree." Classes that implement this interface must have 'generic_prop_search', '_register', 'register_parent', and 'register_child' methods. For specific details please see interfaces.IDHierarchicalCreatable
Implements:
See:

Classes

IDHierarchicalCreatable

Methods

__init__(id, opts) → {interfaces.IDHierarchicalCreatable}

Default initializer for an IDHierarchicalCreatable
Parameters:
Name Type Description
id string The ID of this instance
opts Object Options for this instance
Properties
Name Type Description
parents Iterable Parents of this IDHierarchicalCreatable that will be looped and passed into this.register_parent
children Iterable Children of this IDHierarchicalCreatable that will be looped and passed into this.register_child
Implements:

_register(related, opts, regopts) → {interfaces.IDHierarchicalCreatable}

Default register for an IDHierarchicalCreatable
Parameters:
Name Type Description
related Object | * The ID of this instance
opts Object Options for this instance
Properties
Name Type Description
parents Iterable Parents of this IDHierarchicalCreatable that will be looped and passed into this.register_parent
children Iterable Children of this IDHierarchicalCreatable that will be looped and passed into this.register_child
regopts Object Registration options for this instance.
Properties
Name Type Attributes Default Description
safety boolean <optional>
false Whether to run safety checks during registration.
T * <optional>
IDHierarchicalCreatable The type to check input related object against when safety is enabled.
augment_related_err function Called when safety is enabled and unable to add this instance to the related object (backreference). For example, if this instance is the child, this is called if trying to register this instance to a parent fails.
related_err function Called when safety is enabled and type mismatch encountered. See regopts.T.
These generic search methods only return the id of the overall storage, given the id of the user. This is because once you know what prop exactly you are searching for, you can just map the result and get the result that way. This method will cause a Stack Size Exceeded error if misused when diving into circular references.
Parameters:
Name Type Description
id string The target: ID of the property you are searching for.
opts Object Options to use during the generic search.
Properties
Name Type Description
store_f Object | function Either a storage object to look in or a function that returns such a storage object, given the object being searched through at the time.
prop string | * Property containing related objects (i.e., parents/children) to traverse through.
add_self boolean Whether to include this.id if an object was found in a related object in this[opts.prop].
dive boolean Whether to continue diving through the full tree or return the id of the first related object where the object was found.
Returns:
string | Array.<string> - The results of the search: ids of this/related objects where the target was found.

abstract register_child(parent) → {interfaces.IDHierarchicalCreatable}

Registers a child IDHierarchicalCreatable. Must be overriden.
Parameters:
Name Type Description
parent Object | * A "child" in the hierarchy of this object.

abstract register_parent(parent) → {interfaces.IDHierarchicalCreatable}

Registers a parent IDHierarchicalCreatable. Must be overriden.
Parameters:
Name Type Description
parent Object | * A "parent" in the hierarchy of this object.