Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
A Signal object, designed to emit signals matching some data signature to be received by all the SignalObservers subscribed to it. More...
#include <signals.hpp>
Public Member Functions | |
Signal (SignalTracker &owningTracker, const std::string &name) | |
Constructs a Signal object and associates it with its SignalTracker. | |
Signal (const Signal &other)=delete | |
Signal (Signal &&other)=delete | |
Signal & | operator= (const Signal &other)=delete |
Signal & | operator= (Signal &&other)=delete |
void | emit (TArgs...args) |
A method on the signal which causes the signal to be sent to all of its subscribers (aka SignalObservers). | |
void | resetSignal (SignalTracker &owningTracker, const std::string &name) |
Reinitializes the tracker with a new owning SignalTracker. | |
Private Member Functions | |
void | registerObserver (SignalObserver< TArgs... > &observer) |
Registers a compatible SignalObserver as a subscriber of this Signal. | |
Private Attributes | |
std::shared_ptr< Signal_< TArgs... > > | mSignal_ |
The actual object connected with this Signal's signal tracker, hidden from users of Signal. | |
Friends | |
class | SignalObserver< TArgs... > |
A Signal object, designed to emit signals matching some data signature to be received by all the SignalObservers subscribed to it.
It is essentially a wrapper over Signal_<T>
Here we see two signals declared, one that sends no data, and one that sends GameScoreData, named "ViewUpdateStarted" and "ScoreUpdated" respectively.
When a SignalObserver (with the correct signature) wishes to connect to these signals, a function call resembling the one below should be made:
Where:
signalTo
is a reference to the SignalTracker (or its subclass) owning the SignalObserver.signalFrom
is a reference to the SignalTracker (or its subclass) owning the Signal"ViewUpdateStarted"
is the name of the Signal being subscribed to."ObserveViewUpdateStarted"
is the name of the SignalObserver requesting subscription.TArgs | A list of data types this Signal is expected to send when a signal is emitted. |
ToyMaker::Signal< TArgs >::Signal | ( | SignalTracker & | owningTracker, |
const std::string & | name ) |
Constructs a Signal object and associates it with its SignalTracker.
owningTracker | The tracker responsible for advertising this signal. |
name | The name of this signal. |
void ToyMaker::Signal< TArgs >::emit | ( | TArgs... | args | ) |
A method on the signal which causes the signal to be sent to all of its subscribers (aka SignalObservers).
args | A list of values sent along with this signal. |
|
private |
Registers a compatible SignalObserver as a subscriber of this Signal.
observer | The observer requesting subscription. |
void ToyMaker::Signal< TArgs >::resetSignal | ( | SignalTracker & | owningTracker, |
const std::string & | name ) |
Reinitializes the tracker with a new owning SignalTracker.
Useful for copy and move operations on the object this signal may be a member of.
owningTracker | A reference to this Signal's new owning tracker. |
name | The (possibly new) name of this signal, per its owner. |