NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
netsignal.h
Go to the documentation of this file.
1
18#ifndef NeTrainSim_NetSignal_h
19#define NeTrainSim_NetSignal_h
20
21#include <memory>
22#include <string>
23#include <iostream>
24#include <map>
25
26class NetLink; // Forward declaration of NetLink class
27class NetNode; // Forward declaration of NetNode class
28
29using namespace std;
30
35class NetSignal : public std::enable_shared_from_this<NetSignal> {
36private:
37 static unsigned int NumberOfSignalsInSimulator;
39public:
40 int userID;
41 int id;
42 bool isGreen;
45 std::weak_ptr<NetLink> link;
46 std::weak_ptr<NetNode> previousNode;
47 std::weak_ptr<NetNode> currentNode;
54 NetSignal(int signalID, std::shared_ptr<NetLink> hostingLink);
55
63 NetSignal(int signalID, std::shared_ptr<NetLink> hostingLink,
64 std::shared_ptr<NetNode> previousLinkNode, std::shared_ptr<NetNode> currentLinkNode);
65
70 static unsigned int getNumberOfSignalsInSimulator();
71
78 friend ostream& operator<<(ostream& ostr, const NetSignal& signal);
79};
80
81#endif // NeTrainSim_NetSignal_h
The NetNode class represents a network node in a simulation.
Definition netnode.h:35
The NetSignal class represents a network signal in a simulation.
Definition netsignal.h:35
std::weak_ptr< NetNode > previousNode
The previous node connected to the signal.
Definition netsignal.h:46
double proximityToActivate
The proximity at which the signal activates.
Definition netsignal.h:43
std::weak_ptr< NetNode > currentNode
The current node connected to the signal.
Definition netsignal.h:47
int userID
The user identifier of the signal.
Definition netsignal.h:40
std::weak_ptr< NetLink > link
The link associated with the signal.
Definition netsignal.h:45
int id
The identifier of the signal.
Definition netsignal.h:41
static unsigned int getNumberOfSignalsInSimulator()
Gets the number of signals in the simulator.
Definition netsignal.cpp:42
bool isGreen
Indicates whether the signal is green.
Definition netsignal.h:42
friend ostream & operator<<(ostream &ostr, const NetSignal &signal)
Overloaded ostream operator for printing the NetSignal object.
Definition netsignal.cpp:48