Rune Engine  Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
rune::Subject Class Reference

A subject that can be watched for signals by observers. More...

#include <subject.h>

Inheritance diagram for rune::Subject:

Public Member Functions

void subscribe (Observer &newObserver)
 Tell the subject that an observer would like to be notified of signals. More...
 
bool unsubscribe (Observer &newObserver)
 Tell the subject that an observer would no longer like to be notified of signals. More...
 

Protected Member Functions

void sendSignal (Signal)
 Send a signal to all observers. More...
 
int getNumObservers (void)
 Get the number of observers subscribed to this subject. More...
 

Protected Attributes

std::vector< Observer * > observers
 List of observers currently subscribed to this object.
 

Detailed Description

A subject that can be watched for signals by observers.

Author
Thomas Montano
Date
July 29 2020

Member Function Documentation

◆ getNumObservers()

int rune::Subject::getNumObservers ( void  )
protected

Get the number of observers subscribed to this subject.

Returns
The number of observers currently subscribed to this subject.

◆ sendSignal()

void rune::Subject::sendSignal ( Signal  signalToSend)
protected

Send a signal to all observers.

Parameters
signalToSendThe signal to be sent out to all the observers.

◆ subscribe()

void rune::Subject::subscribe ( Observer newObserver)

Tell the subject that an observer would like to be notified of signals.

Parameters
newObserverThe observer that would like to be notified of signals.
Returns
Whether or not the observer was successfully subscribed.

◆ unsubscribe()

bool rune::Subject::unsubscribe ( Observer observer)

Tell the subject that an observer would no longer like to be notified of signals.

Parameters
observerThe observer that would no longer like to be notified of signals.
Returns
Whether or not the observer was successfully subscribed.

The documentation for this class was generated from the following files: