StateVar(3U)

πŸ’– StateVar β€” the state variable subject base class πŸ’–

okay so bestie, welcome to StateVar(3U), straight out of the InterViews Reference Manual ✨ this one's a little abstract (literally), but it's the backbone of how Unidraw does state, so let's get into it 🫢


✨ NAME ✨

StateVar β€” state variable subject base class πŸ‘‘


🌸 SYNOPSIS 🌸

#include <Unidraw/statevar.h>

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so StateVar is the base class for state variable subjects. State variables are the standard way to represent and access state that can be modified by the user or through dataflow πŸ’«

Here's the vibe: state variable subjects store the state, and state variable views give you a graphical interface for examining and potentially modifying the state in their subject πŸ‘€ so the subject holds the facts, the view is the main character that shows them off.

The StateVar class defines the protocol for state variable subjects. And here's the important part, no cap: it's an abstract class, so you literally cannot instantiate it. Not me trying to new StateVar and getting humbled 😭 it's giving "blueprint only."


πŸ’… PUBLIC OPERATIONS πŸ’…

  • Connector* GetBinding() β€” returns the connector that the state variable is bound to, which is what makes dataflow work πŸ”₯ Data flows through connected connectors with bound state variables: the library automatically assigns one bound state variable's state to another's. The direction of that assignment depends on the participating connectors. Wanna know how to bind state variables to connectors and how to specify the direction of flow? See Connector(3U) for the details, iykyk.
  • virtual void Attach(StateVarView*)
  • virtual void Detach(StateVarView*) β€” Attach associates the subject with a view, represented by an instance of a StateVarView subclass πŸ’ž Detach dissociates a previously attached view. Heads up though: these operations do not ensure that the argument is an appropriate view of the subject. They're trusting like that πŸ™ˆ
  • virtual void Notify() β€” Notify iterates through the views, calling each one's Update operation to tell the view that the subject has potentially changed πŸ“£ Notify is usually called by the subject's state-modifying operations. It's basically the group chat ping of the class.
  • virtual StateVar& operator = (StateVar&) β€” the assignment operation should be redefined to carry out subclass-specific assignment semantics ✍️ Typically this operator calls the parent classes' assignment operator and then does some additional assignments of its own. This operator is used during dataflow to transfer state variable values. slay.
  • virtual StateVar* Copy() β€” returns a copy of the state variable πŸ“‹ Subclasses should redefine this operation to return an instance of their type. no shortcuts, bestie.
  • virtual void Read(istream&)
  • virtual void Write(ostream&) β€” read and write the state variable's contents to a stream, to support catalog operations πŸ“š Read and Write typically call first the corresponding operations defined by their parent class, and then they read or write their class-specific state. Note: you must ensure that the objects are read in the same order they are written. order matters fr fr, don't play with that πŸ’€
  • virtual ClassId GetClassId()
  • virtual boolean IsA(ClassId) β€” GetClassId returns the unique class identifier for the StateVar subclass, while IsA returns whether the instance is of a class or subclass corresponding to the given identifier πŸ” IsA typically checks the given identifier against the instance's own (as defined by its GetClassId operation) and, failing that, calls its parent classes' IsA operation. And listen: all subclasses must redefine GetClassId and IsA to ensure that their identifiers are unique and that instances are written and read properly. non-negotiable πŸŽ€

πŸŽ€ PROTECTED OPERATIONS πŸŽ€

  • StateVar() β€” the constructor is protected to prevent instantiation 🚫 it's giving "you shall not pass," but make it C++.

🌈 SEE ALSO 🌈

Catalog(3U), Connector(3U), Creator(3U), StateVarView(3U), classes(3U), istream(3C++), ostream(3C++)


reminder bestie: abstract class, so no instantiating. use a subclass or this whole thing stays a vibe and not an object πŸ’œ

and that's the whole page, periodt πŸ’– this was StateVar(3U) from the Unidraw manual, version dated 6 August 1990 β€” iconic behavior from 1990 ngl, go off 🫢✨