Connector(3U)

πŸ’– Connector(3U) β€” InterViews Reference Manual πŸ’–

okay bestie, so this is Connector and ConnectorView, from the InterViews Reference Manual (that's the 3U manual, iykyk). they're the base classes for connector subjects and views. let's get into it πŸ¦‹


✨ NAME ✨

Connector, ConnectorView β€” base classes for connector subjects and views. that's it, that's the vibe. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <Unidraw/Components/connector.h>

yes queen, one include, that's all you need. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

okay so Connector is an abstract base class for graphical component subjects that enforce different connectivity semantics depending on the particular connector subclass. and ConnectorView is the abstract base class for views of connector subjects. two halves of one iconic duo, fr fr. 🫢

a connector can be connected to one or more other connectors. and once they're connected? they can affect each other's position in specific ways, as defined by the semantics of the connection. like, they're linked. they're in a situationship. they move together (sometimes). ✨

connectors also participate in the propagation of state variable values during dataflow. two connected connectors with bound state variables will assign the value of one state variable to the other, and the direction of transfer depends on the connectors' transmission method. the example, bestie, is important so listen up:

if the transmission method of connector C1 with bound state variable S1 is In, and if the transmission method of connector C2 with bound state variable S2 is Out, and if C1 and C2 are connected, then S1 will be assigned the value of S2 during dataflow. πŸ’«

that's the whole tea. one goes in, one goes out, value travels.


πŸ‘‘ CONNECTOR PUBLIC OPERATIONS πŸ‘‘

these are the public ones. main character energy only.

  • virtual void Interpret(Command*)
  • virtual void Uninterpret(Command*)

so in addition to (un)interpreting the commands GraphicComp (un)interprets, connectors also (un)interpret DeleteCmd and CutCmd to sever and restore any connections to them. yes, deleting is not the end β€” Uninterpret can bring the connection back. it's giving resurrection arc. 😭

  • virtual void Connect(Connector*, CGlue* = nil);

connect this connector to the given one, optionally with a piece of CGlue interposed. and ngl, this operation allows redundant connections by default β€” so you can double-dip, no one's stopping you. πŸ™ˆ

  • virtual void Disconnect(Connector*)
  • void DisconnectAll()

disconnect the given connector from this one, if they are connected. no connection, no drama. and DisconnectAll calls Disconnect on all connected connectors until no connections remain β€” it's a full clean break, block and delete. πŸ’…

  • virtual boolean ConnectedTo(Connector*)

return whether this connector is connected to the given one. a simple yes/no. the vibe check of connectivity. βœ…

  • virtual void GetCenter(float&, float&)

return the coordinates of the connector's center, which defines its position. that's where it lives, that's its address. πŸ“

  • virtual void SetBinding(StateVar*)
  • virtual StateVar* GetBinding()

assign and return the state variable bound to the connector, if any. and heads up: only one state variable can be bound to a connector at a time. monogamy, but make it state variables. πŸ’œ

  • virtual void SetTransMethod(TransMethod)
  • virtual TransMethod GetTransMethod()

assign and return the connector's transmission method. set it, get it, that's the whole relationship. πŸ”„

  • virtual void Transmit(Path* = nil)

initiate dataflow originating from this connector, optionally based on information supplied in the given Path object. other Unidraw or application objects call this operation whenever data modifications should be propagated. it's the "go tell everyone" button. πŸ“£


🧚 CONNECTOR PROTECTED OPERATIONS 🧚

the backstage stuff. protected, so don't touch unless you're a subclass. you know the rules.

  • Connector(Graphic* = nil)

initialize the connector instance, optionally with a graphic whose center defines the connector's position. give it a graphic, it knows where it is. iconic. 🌸

  • virtual void ConnectMe(Connector*)
  • virtual void DisconnectMe(Connector*)

so here's the deal: connectors maintain a list of the connectors to which they are connected. the Connect and Disconnect operations update this connector's list, while the ConnectMe and DisconnectMe operations inform their argument to update their lists. it's mutual. it's reciprocal. it's a two-way text conversation. πŸ“±πŸ’¬

  • void Retransmit(Path*)
  • void Retransmit(Connector* peer, Path*)
  • boolean Transferable(Connector* peer)

the Transmit operation uses these operations to propagate state variable values, so let's break it down, bestie:

the first Retransmit function calls the second one on each of the connector's peers (i.e., the connectors to which it is connected) if the path records that this connector has not already been visited β€” otherwise propagation ceases. πŸ›‘ the first Retransmit also copies the path if necessary, to avoid accumulating visit information from multiple branches. no double-dipping in the visit log.

the second Retransmit calls Transferable, which returns whether the value of this connector's state variable can be transferred to the given peer's state variable, based on the two connectors' transmission methods. and if the values are transferable, then the Transferable operation carries out the assignment to the peer's state variable as a side-effect. sneaky, but make it functional. ✨

the second Retransmit also enables further propagation by evaluating the transfer function of the peer's parent and by calling the first Retransmit operation on the peer. it's a chain. it keeps going. it's giving relay race. πŸƒβ€β™€οΈ


🌈 CONNECTORVIEW PUBLIC OPERATIONS 🌈

  • Connector* GetConnector()

return the view's subject, if any. that's it. that's the operation. sometimes the simplest ones ate the most. πŸŽ€


⭐ CONNECTORVIEW PROTECTED OPERATIONS ⭐

  • ConnectorView(Connector* = nil)

the constructor takes a subject as an optional argument. and the view will attach itself to the subject if one is specified. if you pass nothing, it just vibes on its own. πŸ’«


πŸ”₯ SEE ALSO πŸ”₯

CGlue(3U), GraphicComp(3U), GraphicView(3U), Path(3U), StateVar(3U), edit(3U0, globals(3U)

go read those too, bestie, they're all connected. literally. πŸ¦‹


ngl, if you skipped to the bottom: Connector = the subject base class, ConnectorView = the view base class, connections can affect positions, and state variable values flow based on transmission methods. that's the recap, periodt. πŸ’…

and that's the whole page, bestie! πŸ’– this one's from Unidraw, dated 20 August 1990 β€” old but iconic, fr fr. stay connected, no cap. πŸ‘‘βœ¨πŸŽ€