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 tracker, the main interface between an object and the signal system. More...
#include <signals.hpp>
Public Member Functions | |
SignalTracker () | |
Constructs a new SignalTracker object. | |
SignalTracker (const SignalTracker &other) | |
Constructs a new SignalTracker. | |
SignalTracker & | operator= (const SignalTracker &other) |
Copy assignment operator. | |
SignalTracker (SignalTracker &&other) | |
Moves resources from another SignalTracker into this one, invalidating them from the other. | |
SignalTracker & | operator= (SignalTracker &&other) |
Moves resources from another SignalTracker into this one, destroying this tracker's resources in the process. | |
void | connect (const std::string &theirSignal, const std::string &ourObserver, SignalTracker &other) |
Method that connects one of this objects SignalObservers to another tracker's Signal. | |
Private Member Functions | |
template<typename ... TArgs> | |
std::shared_ptr< Signal_< TArgs... > > | declareSignal (const std::string &signalName) |
Declares a Signal owned by this tracker, and returns a reference to it. | |
template<typename ... TArgs> | |
std::shared_ptr< SignalObserver_< TArgs... > > | declareSignalObserver (const std::string &observerName, std::function< void(TArgs...)> callbackFunction) |
Declares a SignalObserver owned by this tracker, returns a reference to it. | |
void | garbageCollection () |
A method which removes any signals and observers sitting on this object which were destroyed at some point. | |
Private Attributes | |
std::unordered_map< std::string, std::weak_ptr< ISignalObserver > > | mObservers {} |
A list of weak references to this object's SignalObservers, along with their names. | |
std::unordered_map< std::string, std::weak_ptr< ISignal > > | mSignals {} |
A list of weak references to this object's Signals, along with their names. | |
Friends | |
class | ISignal |
class | IObserver |
template<typename ... TArgs> | |
class | SignalObserver |
template<typename ... TArgs> | |
class | Signal |
A signal tracker, the main interface between an object and the signal system.
Connections in JSON scene descriptions may appear as follows:
SignalTracker::SignalTracker | ( | const SignalTracker & | other | ) |
Constructs a new SignalTracker.
other | The object being copied from. |
SignalTracker::SignalTracker | ( | SignalTracker && | other | ) |
Moves resources from another SignalTracker into this one, invalidating them from the other.
other | The tracker whose resources are being claimed. |
void SignalTracker::connect | ( | const std::string & | theirSignal, |
const std::string & | ourObserver, | ||
SignalTracker & | other ) |
Method that connects one of this objects SignalObservers to another tracker's Signal.
theirSignal | The Signal a SignalObserver for this object is being connected to. |
ourObserver | Our SignalObserver. |
other | The SignalTracker owning the Signal our SignalObserver is trying to subscribe to. |
|
inlineprivate |
Declares a Signal owned by this tracker, and returns a reference to it.
TArgs | A list of types of data sent by this object when the declared signal is emitted. |
signalName | The name of the signal being declared. |
|
inlineprivate |
Declares a SignalObserver owned by this tracker, returns a reference to it.
TArgs | A list of types of data received by this object when a Signal it is subscribed to is emitted. |
observerName | The name of the SignalObserver owned by this object. |
callbackFunction | A reference to the function to be called by this observer when a Signal is received by it. |
SignalTracker & SignalTracker::operator= | ( | const SignalTracker & | other | ) |
Copy assignment operator.
other | The signal tracker being copied from. |
SignalTracker & SignalTracker::operator= | ( | SignalTracker && | other | ) |
Moves resources from another SignalTracker into this one, destroying this tracker's resources in the process.
other | The tracker whose resources are being stolen. |