A Memorizable object that keeps a list of other Memorizable objects and frequently tells them to memorize simulation data. The memorize method is meant to be called after each simulation time step, as is done in AdvanceStrategy.advance.

This is an example of Composite design pattern: it is a tree structure where every node on the tree defines the memorize method and calls that method on its sub-nodes.

The base of the tree structure is usually SimRunner. You can add a Memorizable directly to SimRunner using MemoList.addMemo. Or you can add a Memorizable to one of the branches of the tree, such as a LabCanvas contained in the SimRunner, or a SimView contained in the LabCanvas.

In a typical simulation, a graph is periodically updated because SimRunner.callback causes the AdvanceStrategy to both advance the simulation and also call memorize on each LabCanvas. The memorize of the LabCanvas calls memorize on each SimView, which in turn calls memorize on any Memorizable objects contained in the SimView, such as a GraphLine.

interface MemoList {
    addMemo(memorizable): void;
    getMemos(): Memorizable[];
    memorize(): void;
    removeMemo(memorizable): void;
    toStringShort(): string;
}

Hierarchy (view full)

Implemented by

Methods

  • Adds an object to the list of Memorizable objects. These object's memorize methods will be called from this object's memorize method.

    Parameters

    • memorizable: Memorizable

      object to add to the list of Memorizable objects

    Returns void

    Throws

    if called during the memorize method.

  • Memorize the current simulation data, or do some other function that should happen regularly after each simulation time step.

    Returns void

  • Removes an object from the list of Memorizable objects.

    Parameters

    • memorizable: Memorizable

      object to remove from the list of Memorizable objects

    Returns void

    Throws

    if called during the memorize method.

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc