transfns(3U)

πŸ’« transfns β€” it's giving transfer function subclasses πŸ’«

okay bestie, welcome to transfns(3U) from the InterViews Reference Manual, and no cap this one is lowkey the blueprint for how state variables talk to each other in Unidraw. 🫢


✨ NAME ✨

TF_2Port, TF_Direct β€” transfer function subclasses, periodt.


πŸŽ€ SYNOPSIS πŸŽ€

#include <Unidraw/transfns.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

so the TransferFunct abstract base class is literally the main character that defines the transfer function protocol. iconic. and the library predefines two subclasses for you:

  • TF_2Port β€” a subclass that acts as an abstract base class for transfer functions that have two sets of state variables: input''</cyan> and <cyan>output''. the output variables are always dependent on the input variables. that's the whole vibe, iykyk.
  • TF_Direct β€” a subclass of TF_2Port that defines a one-to-one assignment relationship between an input and an output state variable. simple, clean, slay.

πŸ’… TF_2PORT PUBLIC OPERATIONS πŸ’…

  • void Evaluate(Path* = nil) β€” okay so first Evaluate carries out information transfer between dependent state variables by calling the Transfer operation (more on that below πŸ‘‡). then it iterates through its output state variables, and the ones that have changed (according to the ChangedOutput operation, also below) get Transmit called on the connector they're bound to. good news: subclasses don't need to redefine this operation if they implement Transfer and ChangedOutput appropriately. you're welcome. πŸ’–
  • virtual StateVar* GetInput(int index) virtual StateVar* GetOutput(int index) virtual void SetInput(StateVar*, int index) virtual void SetOutput(StateVar*, int index) β€” retrieve and assign the TF_2Port's input and output state variables, identified serially. by default these operations do nothing 😭 β€” subclasses must allocate the storage they require. no storage, no service.
  • virtual int Inputs() virtual int Outputs() β€” return the number of input and output state variables. these operations return zero by default. yeah. zero. it's giving empty nest.

🌸 TF_2PORT PROTECTED OPERATIONS 🌸

  • TF_2Port() β€” the constructor is protected to prevent instantiation. so don't even try to instantiate it directly, bestie, it's not for you like that. 🚫
  • virtual void Transfer() β€” enforce the subclass-specific dependencies between the TF_2Port's state variables. this operation does nothing by default.
  • virtual boolean ChangedOutput(int index = 0) β€” return whether the output state variable with the given index has changed its value since the last call to Transfer. subclasses redefine this operation according to the semantics of their Transfer operation. the way that's so customisable of them ✨

🌈 TF_DIRECT PUBLIC OPERATIONS 🌈

  • TF_Direct(StateVar* input = nil, StateVar* output = nil) β€” instantiate a new object, optionally specifying the input state variable and its dependent output state variable. cute, right?
  • virtual StateVar* GetInput(int index = 0) virtual StateVar* GetOutput(int index = 0) virtual void SetInput(StateVar*, int index = 0) virtual void SetOutput(StateVar*, int index = 0) β€” retrieve and assign the TF_Direct's input and output state variables. specifying an index greater than zero does nothing, since TF_Direct defines a dependency between one input and one output state variable. one in, one out. monogamy. πŸ’œ
  • virtual int Inputs() virtual int Outputs() β€” return the number of input and output state variables. these operations return zero by default.
  • virtual int Inputs() virtual int Outputs() β€” these operations return 1.
not me listing Inputs and Outputs twice because the page does πŸ™ˆ both entries are here, exactly as written, so you're not missing a single crumb. πŸ“

⭐ TF_DIRECT PROTECTED OPERATIONS ⭐

  • virtual void Transfer() β€” assign the input state variable to the output state variable, setting a flag indicating that the output value has changed. flag raised, glow up complete. 🚩✨
  • virtual boolean ChangedOutput(int index = 0) β€” return the status of the flag set by Transfer. the flag is reset as a side-effect of this operation. so reading it is a one-time deal, no cap β€” peek once and it's gone. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

  • TransferFunct(3U)

and that's the whole page, bestie, we ate and left no crumbs. πŸ’…πŸŒˆ

this was transfns(3U) from Unidraw, dated 6 August 1990 β€” yeah, she's vintage, and she's still serving. πŸŽ€ mwah, go implement Transfer and ChangedOutput properly, love u, bye πŸ«ΆπŸ’–