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.IDHierarchicalCreatableClasses
Methods
-
__init__(id, opts) → {interfaces.IDHierarchicalCreatable}
-
Default initializer for an IDHierarchicalCreatable
Parameters:
Name Type Description idstring The ID of this instance optsObject Options for this instance Properties
Name Type Description parentsIterable Parents of this IDHierarchicalCreatable that will be looped and passed into this.register_parent childrenIterable Children of this IDHierarchicalCreatable that will be looped and passed into this.register_child Returns:
interfaces.IDHierarchicalCreatable - this -
_register(related, opts, regopts) → {interfaces.IDHierarchicalCreatable}
-
Default register for an IDHierarchicalCreatable
Parameters:
Name Type Description relatedObject | * The ID of this instance optsObject Options for this instance Properties
Name Type Description parentsIterable Parents of this IDHierarchicalCreatable that will be looped and passed into this.register_parent childrenIterable Children of this IDHierarchicalCreatable that will be looped and passed into this.register_child regoptsObject Registration options for this instance. Properties
Name Type Attributes Default Description safetyboolean <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_errfunction 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_errfunction Called when safety is enabled and type mismatch encountered. See regopts.T. Returns:
interfaces.IDHierarchicalCreatable - this -
generic_prop_search(id, opts, dive) → {string|Array.<string>}
-
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 idstring The target: ID of the property you are searching for. optsObject Options to use during the generic search. Properties
Name Type Description store_fObject | 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. propstring | * Property containing related objects (i.e., parents/children) to traverse through. add_selfboolean Whether to include this.id if an object was found in a related object in this[opts.prop]. diveboolean 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 parentObject | * A "child" in the hierarchy of this object. Returns:
interfaces.IDHierarchicalCreatable - this -
abstract register_parent(parent) → {interfaces.IDHierarchicalCreatable}
-
Registers a parent IDHierarchicalCreatable. Must be overriden.
Parameters:
Name Type Description parentObject | * A "parent" in the hierarchy of this object. Returns:
interfaces.IDHierarchicalCreatable - this