Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::SignalTracker Class Reference

A signal tracker, the main interface between an object and the signal system. More...

#include <signals.hpp>

Inheritance diagram for ToyMaker::SignalTracker:
ToyMaker::BaseSimObjectAspect ToyMaker::SimObjectAspect< BoardLocations > ToyMaker::SimObjectAspect< PlayerCPURandom > ToyMaker::SimObjectAspect< PlayerLocal > ToyMaker::SimObjectAspect< QueryClick > ToyMaker::SimObjectAspect< RenderDebugViewer > ToyMaker::SimObjectAspect< UIButton > ToyMaker::SimObjectAspect< UIImage > ToyMaker::SimObjectAspect< UIPanel > ToyMaker::SimObjectAspect< UIText > ToyMaker::SimObjectAspect< UrController > ToyMaker::SimObjectAspect< UrLookAtBoard > ToyMaker::SimObjectAspect< UrRecords > ToyMaker::SimObjectAspect< UrSceneManager > ToyMaker::SimObjectAspect< UrSceneView > ToyMaker::SimObjectAspect< UrUINavigation > ToyMaker::SimObjectAspect< UrUIRecordsBrowser > ToyMaker::SimObjectAspect< UrUITutorialsBrowser > ToyMaker::SimObjectAspect< UrUIVersion > ToyMaker::SimObjectAspect< UrUIView > ToyMaker::SimObjectAspect< TSimObjectAspectDerived >

Public Member Functions

 SignalTracker ()
 Constructs a new SignalTracker object.
 
 SignalTracker (const SignalTracker &other)
 Constructs a new SignalTracker.
 
SignalTrackeroperator= (const SignalTracker &other)
 Copy assignment operator.
 
 SignalTracker (SignalTracker &&other)
 Moves resources from another SignalTracker into this one, invalidating them from the other.
 
SignalTrackeroperator= (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
 

Detailed Description

A signal tracker, the main interface between an object and the signal system.

Connections in JSON scene descriptions may appear as follows:

{
"from": "/viewport_UI/return/@UIButton",
"signal": "ButtonReleased",
"to": "/@UrUINavigation",
"observer": "ButtonClickedObserved"
}
Remarks
SceneNodeCores have a signal tracker member, allowing them to interface with the scene system.
See also
Signal
SignalObserver

Constructor & Destructor Documentation

◆ SignalTracker() [1/2]

SignalTracker::SignalTracker ( const SignalTracker & other)

Constructs a new SignalTracker.

Parameters
otherThe object being copied from.

◆ SignalTracker() [2/2]

SignalTracker::SignalTracker ( SignalTracker && other)

Moves resources from another SignalTracker into this one, invalidating them from the other.

Parameters
otherThe tracker whose resources are being claimed.

Member Function Documentation

◆ connect()

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.

Parameters
theirSignalThe Signal a SignalObserver for this object is being connected to.
ourObserverOur SignalObserver.
otherThe SignalTracker owning the Signal our SignalObserver is trying to subscribe to.

◆ declareSignal()

template<typename ... TArgs>
std::shared_ptr< Signal_< TArgs... > > ToyMaker::SignalTracker::declareSignal ( const std::string & signalName)
inlineprivate

Declares a Signal owned by this tracker, and returns a reference to it.

Template Parameters
TArgsA list of types of data sent by this object when the declared signal is emitted.
Parameters
signalNameThe name of the signal being declared.
Returns
std::shared_ptr<Signal_<TArgs...>> A reference to the newly constructed signal.

◆ declareSignalObserver()

template<typename ... TArgs>
std::shared_ptr< SignalObserver_< TArgs... > > ToyMaker::SignalTracker::declareSignalObserver ( const std::string & observerName,
std::function< void(TArgs...)> callbackFunction )
inlineprivate

Declares a SignalObserver owned by this tracker, returns a reference to it.

Template Parameters
TArgsA list of types of data received by this object when a Signal it is subscribed to is emitted.
Parameters
observerNameThe name of the SignalObserver owned by this object.
callbackFunctionA reference to the function to be called by this observer when a Signal is received by it.
Returns
std::shared_ptr<SignalObserver_<TArgs...>> A reference to the newly constructed SignalObserver.

◆ operator=() [1/2]

SignalTracker & SignalTracker::operator= ( const SignalTracker & other)

Copy assignment operator.

Parameters
otherThe signal tracker being copied from.
Returns
SignalTracker& The new SignalTracker.

◆ operator=() [2/2]

SignalTracker & SignalTracker::operator= ( SignalTracker && other)

Moves resources from another SignalTracker into this one, destroying this tracker's resources in the process.

Parameters
otherThe tracker whose resources are being stolen.
Returns
SignalTracker& A reference to this tracker with its properties updated.

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