Subject(3I)

πŸ’– Subject(3I) β€” the InterViews Reference Manual page, but make it cute πŸ’–

okay bestie, sit down, hydrate, because we're talking about Subject from the InterViews Reference Manual, and honestly? she's a whole social coordinator. πŸŽ€


✨ NAME ✨

Subject β€” an object with views πŸ¦‹


🌸 SYNOPSIS 🌸

#include <InterViews/subject.h>

πŸ’… DESCRIPTION πŸ’…

So a subject is an object that has one or more views that it wants to notify when it changes. That's the whole job. That's the vibe. She changes, everybody who's watching her hears about it. πŸ“£

If you ever need to walk through the views of a subject explicitly, there's the SubjectIteractor class for that. (Yes, that's how it's spelled in the source, bestie, we do not fix it. 😌)

Now here's the lore: because subjects get shared, Subject is a subclass of Resource. And because multiple inheritance is a possibility β€” and in that scenario you only want a single copy of resource information hanging around, no duplicates, no drama β€” Resource is a virtual base class. πŸ’€ That's just how it has to be. periodt.


πŸ‘‘ PUBLIC OPERATIONS πŸ‘‘

🌈 the enum 🌈

enum UpdateHint {
    attaching, detaching, setting, changing
}

This type enumerates the possible hints you get when a subject is notifying a view that it has changed. Let's break it down, one by one, no skips:

  • attaching β€” this hint means a view has attached to the subject. new bestie acquired 🫢
  • detaching β€” this one means the subject is being deleted, and the view should consider itself detached. it's giving farewell tour 😭
  • setting β€” the subject's value has been set, though possibly to the same value as it already has. so like... she said the same thing again. still counts as an announcement.
  • changing β€” the value is set to something different than it was previously. an actual plot twist. πŸ”₯

🌟 the operations 🌟

  • virtual void attach(View*) β€” add a view to the subject's list. welcome to the group chat, babes πŸ’–
  • virtual void detach(View*) β€” remove a view from the subject's list. we hate to see you go πŸ¦‹
  • virtual void notify(UpdateHint = changing) β€” notify all the views of a subject that it has been updated. default hint is changing, fyi. she's shouting it from the rooftops πŸ“’
  • virtual boolean viewed_by(View*) β€” returns whether a given view is on the subject's list of views. a little vibe check, if you will. ✨

πŸŽ€ the backward-compatibility corner (iykyk) πŸŽ€

heads up bestie: every single one of these exists solely for backward compatibility, and every single one of them will be removed in a future version. do not build your whole personality around them. πŸ™ˆ
  • virtual void Attach(Interactor*) β€” equivalent to attach. legacy. will be removed in a future version.
  • virtual void Detach(Interactor*) β€” equivalent to detach. legacy. will be removed in a future version.
  • virtual void Notify() β€” equivalent to notify(changing). legacy. will be removed in a future version.
  • boolean IsView(Interactor*) β€” equivalent to viewed_by. legacy. will be removed in a future version.

πŸ¦‹ SUBJECTITERATOR OPERATIONS πŸ¦‹

A subject iterator can be used to iterate through the views in a subject. she's your little tour guide through the list. 🧚

  • SubjectIterator(Subject*) β€” create a subject iterator for the given subject. > ⚠️ the iterator is only valid as long as the subject exists. once the subject dips, so does your iterator. no cap.
  • virtual void init() β€” reset the iteration to start at the beginning of the list. this operation is called by the constructor, so it already happens for you, slay. ⭐
  • virtual boolean more() β€” return whether there are more views in the list. are we there yet? are we there yet? 😭
  • virtual View* cur() β€” return the current view. the main character of this exact moment. πŸ‘‘
  • virtual void remove() β€” remove the current view from the list. πŸ’€
  • virtual void next() β€” move the iteration to the next view in the list. onward! ✨

🌈 SEE ALSO 🌈

  • View(3I)

that's the whole page, bestie, and you ate it. πŸ’…βœ¨ the InterViews manual, dated 29 June 1989, brought to you by InterViews itself β€” mwah, sending you a little kiss and a Subject(3I) reference card, go forth and notify your views. πŸŽ€πŸ«ΆπŸ’–