NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
NetSignal Class Reference

The NetSignal class represents a network signal in a simulation. More...

#include <netsignal.h>

Inheritance diagram for NetSignal:

Public Member Functions

 NetSignal (int signalID, std::shared_ptr< NetLink > hostingLink)
 Constructor.
 
 NetSignal (int signalID, std::shared_ptr< NetLink > hostingLink, std::shared_ptr< NetNode > previousLinkNode, std::shared_ptr< NetNode > currentLinkNode)
 Constructor.
 

Static Public Member Functions

static unsigned int getNumberOfSignalsInSimulator ()
 Gets the number of signals in the simulator.
 

Public Attributes

int userID
 The user identifier of the signal.
 
int id
 The identifier of the signal.
 
bool isGreen
 Indicates whether the signal is green.
 
double proximityToActivate
 The proximity at which the signal activates.
 
std::weak_ptr< NetLinklink
 The link associated with the signal.
 
std::weak_ptr< NetNodepreviousNode
 The previous node connected to the signal.
 
std::weak_ptr< NetNodecurrentNode
 The current node connected to the signal.
 

Friends

ostream & operator<< (ostream &ostr, const NetSignal &signal)
 Overloaded ostream operator for printing the NetSignal object.
 

Detailed Description

The NetSignal class represents a network signal in a simulation.

Constructor & Destructor Documentation

◆ NetSignal() [1/2]

NetSignal::NetSignal ( int  signalID,
std::shared_ptr< NetLink hostingLink 
)

Constructor.

Parameters
signalIDThe identifier of the signal.
hostingLinkThe link hosting the signal.

◆ NetSignal() [2/2]

NetSignal::NetSignal ( int  signalID,
std::shared_ptr< NetLink hostingLink,
std::shared_ptr< NetNode previousLinkNode,
std::shared_ptr< NetNode currentLinkNode 
)

Constructor.

Parameters
signalIDThe identifier of the signal.
hostingLinkThe link hosting the signal.
previousLinkNodeThe previous node connected to the signal.
currentLinkNodeThe current node connected to the signal.

Member Function Documentation

◆ getNumberOfSignalsInSimulator()

unsigned int NetSignal::getNumberOfSignalsInSimulator ( )
static

Gets the number of signals in the simulator.

Returns
The number of signals.

Friends And Related Symbol Documentation

◆ operator<<

ostream & operator<< ( ostream &  ostr,
const NetSignal signal 
)
friend

Overloaded ostream operator for printing the NetSignal object.

Parameters
ostrThe output stream object.
signalThe NetSignal object to be printed.
Returns
The output stream object.

Member Data Documentation

◆ currentNode

std::weak_ptr<NetNode> NetSignal::currentNode

The current node connected to the signal.

◆ id

int NetSignal::id

The identifier of the signal.

◆ isGreen

bool NetSignal::isGreen

Indicates whether the signal is green.

◆ link

std::weak_ptr<NetLink> NetSignal::link

The link associated with the signal.

◆ previousNode

std::weak_ptr<NetNode> NetSignal::previousNode

The previous node connected to the signal.

◆ proximityToActivate

double NetSignal::proximityToActivate

The proximity at which the signal activates.

◆ userID

int NetSignal::userID

The user identifier of the signal.