Dynamical system model
Loading...
Searching...
No Matches
dsm::Node< Id, Size > Class Template Reference

The Node class represents a node in the network. More...

#include <Node.hpp>

Inheritance diagram for dsm::Node< Id, Size >:
dsm::NodeConcept< Id, Size > dsm::TrafficLight< Id, Size, Delay >

Public Member Functions

 Node (Id id)
 Construct a new Node object.
 
 Node (Id id, std::pair< double, double > coords)
 Construct a new Node object.
 
void setCapacity (Size capacity) override
 Set the node's capacity.
 
void addAgent (double angle, Id agentId)
 Put an agent in the node.
 
void addAgent (Id agentId)
 Put an agent in the node.
 
void removeAgent (Id agentId)
 Removes an agent from the node.
 
void setStreetPriorities (std::set< Id > streetPriorities)
 Set the node streets with priority.
 
void addStreetPriority (Id streetId)
 Add a street to the node street priorities.
 
bool isFull () const override
 Returns true if the node is full.
 
virtual const std::set< Id > & streetPriorities () const
 Get the node's street priorities.
 
std::multimap< int16_t, Id > agents () const
 Get the node's agent ids.
 
Size agentCounter ()
 Returns the number of agents that have passed through the node.
 
virtual bool isIntersection () const noexcept override final
 
- Public Member Functions inherited from dsm::NodeConcept< Id, Size >
 NodeConcept (Id id)
 Construct a new Node object with capacity 1.
 
 NodeConcept (Id id, std::pair< double, double > coords)
 Construct a new Node object with capacity 1.
 
void setId (Id id)
 Set the node's id.
 
void setCoords (std::pair< double, double > coords)
 Set the node's coordinates.
 
Id id () const
 Get the node's id.
 
const std::optional< std::pair< double, double > > & coords () const
 Get the node's coordinates.
 
Size capacity () const
 Get the node's capacity.
 
virtual bool isTrafficLight () const noexcept
 
virtual bool isRoundabout () const noexcept
 

Protected Attributes

std::multimap< int16_t, Id > m_agents
 
std::set< Id > m_streetPriorities
 
Size m_agentCounter
 
- Protected Attributes inherited from dsm::NodeConcept< Id, Size >
Id m_id
 
std::optional< std::pair< double, double > > m_coords
 
Size m_capacity
 

Detailed Description

template<typename Id, typename Size>
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
class dsm::Node< Id, Size >

The Node class represents a node in the network.

Template Parameters
IdThe type of the node's id. It must be an unsigned integral type.

Constructor & Destructor Documentation

◆ Node() [1/2]

template<typename Id , typename Size >
dsm::Node< Id, Size >::Node ( Id id)
inlineexplicit

Construct a new Node object.

Parameters
idThe node's id

◆ Node() [2/2]

template<typename Id , typename Size >
dsm::Node< Id, Size >::Node ( Id id,
std::pair< double, double > coords )
inline

Construct a new Node object.

Parameters
idThe node's id
coordsA std::pair containing the node's coordinates

Member Function Documentation

◆ addAgent() [1/2]

template<typename Id , typename Size >
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
void dsm::Node< Id, Size >::addAgent ( double angle,
Id agentId )

Put an agent in the node.

Parameters
agentA std::pair containing the agent's angle difference and id

The agent's angle difference is used to order the agents in the node. The agent with the smallest angle difference is the first one to be removed from the node.

Exceptions
std::runtime_errorif the node is full

◆ addAgent() [2/2]

template<typename Id , typename Size >
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
void dsm::Node< Id, Size >::addAgent ( Id agentId)

Put an agent in the node.

Parameters
agentIdThe agent's id

The agent's angle difference is used to order the agents in the node. The agent with the smallest angle difference is the first one to be removed from the node.

Exceptions
std::runtime_errorif the node is full

◆ addStreetPriority()

template<typename Id , typename Size >
void dsm::Node< Id, Size >::addStreetPriority ( Id streetId)
inline

Add a street to the node street priorities.

Parameters
streetIdThe street's id

◆ agentCounter()

template<typename Id , typename Size >
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
Size dsm::Node< Id, Size >::agentCounter ( )

Returns the number of agents that have passed through the node.

Returns
Size The number of agents that have passed through the node

This function returns the number of agents that have passed through the node since the last time this function was called. It also resets the counter.

◆ agents()

template<typename Id , typename Size >
std::multimap< int16_t, Id > dsm::Node< Id, Size >::agents ( ) const
inline

Get the node's agent ids.

Returns
std::set<Id> A std::set containing the node's agent ids

◆ isFull()

template<typename Id , typename Size >
bool dsm::Node< Id, Size >::isFull ( ) const
inlineoverridevirtual

Returns true if the node is full.

Returns
bool True if the node is full

Implements dsm::NodeConcept< Id, Size >.

◆ isIntersection()

template<typename Id , typename Size >
virtual bool dsm::Node< Id, Size >::isIntersection ( ) const
inlinefinaloverridevirtualnoexcept

Reimplemented from dsm::NodeConcept< Id, Size >.

◆ removeAgent()

template<typename Id , typename Size >
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
void dsm::Node< Id, Size >::removeAgent ( Id agentId)

Removes an agent from the node.

Parameters
agentIdThe agent's id

◆ setCapacity()

template<typename Id , typename Size >
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
void dsm::Node< Id, Size >::setCapacity ( Size capacity)
overridevirtual

Set the node's capacity.

Parameters
capacityThe node's capacity
Exceptions
std::runtime_errorif the capacity is smaller than the current queue size

Reimplemented from dsm::NodeConcept< Id, Size >.

◆ setStreetPriorities()

template<typename Id , typename Size >
void dsm::Node< Id, Size >::setStreetPriorities ( std::set< Id > streetPriorities)
inline

Set the node streets with priority.

Parameters
streetPrioritiesA std::set containing the node's street priorities

◆ streetPriorities()

template<typename Id , typename Size >
virtual const std::set< Id > & dsm::Node< Id, Size >::streetPriorities ( ) const
inlinevirtual

Get the node's street priorities.

This function returns a std::set containing the node's street priorities. If a street has priority, it means that the agents that are on that street have priority over the agents that are on the other streets.

Returns
std::set<Id> A std::set containing the node's street priorities

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