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

The Roundabout class represents a roundabout node in the network. More...

#include <Node.hpp>

Inheritance diagram for dsm::Roundabout< Id, Size >:
dsm::NodeConcept< Id, Size >

Public Member Functions

 Roundabout (Id id)
 Construct a new Roundabout object.
 
 Roundabout (Id id, std::pair< double, double > coords)
 Construct a new Roundabout object.
 
 Roundabout (const NodeConcept< Id, Size > &node)
 Construct a new Roundabout object.
 
void enqueue (Id agentId)
 Put an agent in the node.
 
Id dequeue ()
 Removes the first agent from the node.
 
const dsm::queue< Id > & agents () const
 Get the node's queue.
 
bool isFull () const override
 Returns true if the node is full.
 
bool isRoundabout () const noexcept override
 Returns true if the node is a roundabout.
 
- 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.
 
virtual void setCapacity (Size capacity)
 Set the node's capacity.
 
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 isIntersection () const noexcept
 
virtual bool isTrafficLight () const noexcept
 

Protected Attributes

dsm::queue< Id > m_agents
 
- 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::Roundabout< Id, Size >

The Roundabout class represents a roundabout node in the network.

Template Parameters
IdThe type of the node's id
SizeThe type of the node's capacity

Constructor & Destructor Documentation

◆ Roundabout() [1/3]

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

Construct a new Roundabout object.

Parameters
idThe node's id

◆ Roundabout() [2/3]

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

Construct a new Roundabout object.

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

◆ Roundabout() [3/3]

template<typename Id , typename Size >
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
dsm::Roundabout< Id, Size >::Roundabout ( const NodeConcept< Id, Size > & node)

Construct a new Roundabout object.

Parameters
nodeA Node object

Member Function Documentation

◆ agents()

template<typename Id , typename Size >
const dsm::queue< Id > & dsm::Roundabout< Id, Size >::agents ( ) const
inline

Get the node's queue.

Returns
dsm::queue<Id> The node's queue

◆ dequeue()

template<typename Id , typename Size >
requires (std::unsigned_integral<Id> && std::unsigned_integral<Size>)
Id dsm::Roundabout< Id, Size >::dequeue ( )

Removes the first agent from the node.

Returns
Id The agent's id

◆ enqueue()

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

Put an agent in the node.

Parameters
agentIdThe agent's id
Exceptions
std::runtime_errorif the node is full

◆ isFull()

template<typename Id , typename Size >
bool dsm::Roundabout< 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 >.

◆ isRoundabout()

template<typename Id , typename Size >
bool dsm::Roundabout< Id, Size >::isRoundabout ( ) const
inlineoverridevirtualnoexcept

Returns true if the node is a roundabout.

Returns
bool True if the node is a roundabout

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


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