MTCT
Design Automation and Optimization for ETCS Railway Networks
Loading...
Searching...
No Matches
cda_rail::StationList Class Reference

Container and persistence API for named stations. More...

#include <Station.hpp>

Public Member Functions

 StationList ()=default
 Creates an empty station list.
 StationList (std::filesystem::path const &p, Network const &network)
 Loads stations from stations.json in the given directory.
 StationList (std::string const &path, Network const &network)
 Constructs a station list from a string path.
 StationList (char const *const path, Network const &network)
 Convenience overload forwarding to the filesystem path constructor.
 StationList (const StationList &other)
 Copy constructor that performs a deep copy of all stations.
StationList & operator= (const StationList &other)
 Copy assignment operator that performs a deep copy of all stations.
 StationList (StationList &&) noexcept=default
 Move constructor.
StationList & operator= (StationList &&) noexcept=default
 Move assignment operator.
auto begin () const
 Read-only iterator to the first station entry.
auto end () const
 Read-only iterator past the last station entry.
auto cbegin () const
 Obtains a const iterator to the first station.
auto cend () const
 Read-only iterator past the last station entry (explicit const).
size_t size () const
 Retrieves the number of stations.
bool has_station (const std::string &name) const
 Checks whether a station with the given name exists.
Station const & get_station (const std::string &name) const
 Retrieves a station by name.
std::unordered_set< std::string > get_station_names () const
 Returns the set of all station names.
bool is_fully_in_station (std::string const &station_name, cda_rail::index_set const &edges) const
 Checks whether all given edges belong to a named station.
void add_empty_station (std::string const &name)
 Adds a new station without tracks.
void add_track_to_station (const std::string &name, size_t track)
 Adds a track index to an existing station.
void add_track_to_station (const std::string &name, cda_rail::Network::EdgeInput const &edge, const Network &network)
 Adds a track to a station by resolving an edge specification.
void export_stations (const std::filesystem::path &p, const Network &network) const
 Exports all stations to stations.json in the target directory.
void export_stations (std::string const &path, const Network &network) const
 Convenience overload forwarding to the filesystem path export.
void export_stations (char const *const path, const Network &network) const
 Writes all stations to the specified directory.
void update_after_discretization (const std::vector< std::pair< size_t, cda_rail::index_set > > &new_edges)
 Updates station tracks after network discretization.
void update_after_discretization (const std::vector< std::pair< size_t, cda_rail::index_vector > > &new_edges)
 Updates station tracks after network discretization.
std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > get_stop_tracks (const std::string &name, double tr_len, const Network &network, const cda_rail::index_set &edges_to_consider={}) const
 Computes possible stop tracks for a named station.

Static Public Member Functions

static StationList import_stations (const std::string &path, const Network &network)
 Imports stations from a directory path string.
static StationList import_stations (const char *path, const Network &network)
 Imports stations from a C-string path.
static StationList import_stations (const std::filesystem::path &p, const Network &network)
 Imports stations from a filesystem path.

Friends

class Timetable

Detailed Description

Container and persistence API for named stations.

StationList owns all stations and provides lookup, mutation, import/export, and helper operations.

Constructor & Destructor Documentation

◆ StationList() [1/6]

cda_rail::StationList::StationList ( )
default

Creates an empty station list.

◆ StationList() [2/6]

cda_rail::StationList::StationList ( std::filesystem::path const & p,
Network const & network )

Loads stations from stations.json in the given directory.

Parameters
pDirectory containing stations.json.
networkNetwork used to resolve edge endpoints from stored vertex names.
Exceptions
exceptions::ImportExceptionIf p does not exist or is not a directory.

◆ StationList() [3/6]

cda_rail::StationList::StationList ( std::string const & path,
Network const & network )
inline

Constructs a station list from a string path.

Loads stations from stations.json located in the given directory.

Parameters
pathDirectory containing stations.json.
networkNetwork used to resolve edge endpoints.
Exceptions
exceptions::ImportExceptionIf path does not exist or is not a directory.

◆ StationList() [4/6]

cda_rail::StationList::StationList ( char const *const path,
Network const & network )
inline

Convenience overload forwarding to the filesystem path constructor.

Parameters
pathDirectory containing stations.json.
networkNetwork used to resolve edge endpoints.

◆ StationList() [5/6]

cda_rail::StationList::StationList ( const StationList & other)
inline

Copy constructor that performs a deep copy of all stations.

Parameters
otherThe StationList to copy from.

◆ StationList() [6/6]

cda_rail::StationList::StationList ( StationList && )
defaultnoexcept

Move constructor.

Member Function Documentation

◆ add_empty_station()

void cda_rail::StationList::add_empty_station ( std::string const & name)

Adds a new station without tracks.

Parameters
nameName of the station to create.
Exceptions
exceptions::ConsistencyExceptionIf a station with name already exists.

◆ add_track_to_station() [1/2]

void cda_rail::StationList::add_track_to_station ( const std::string & name,
cda_rail::Network::EdgeInput const & edge,
const Network & network )
inline

Adds a track to a station by resolving an edge specification.

Parameters
nameStation name.
edgeEdge specification to resolve and add.
networkNetwork used to resolve the edge specification.
Exceptions
exceptions::StationNotExistentExceptionif the station does not exist.
exceptions::EdgeNotExistentExceptionif the resolved edge does not exist in the network.

◆ add_track_to_station() [2/2]

void cda_rail::StationList::add_track_to_station ( const std::string & name,
size_t track )

Adds a track index to an existing station.

If the track already belongs to the station, the call has no effect.

Parameters
nameStation name.
trackTrack edge index.
Exceptions
exceptions::StationNotExistentExceptionIf name is unknown.

◆ begin()

auto cda_rail::StationList::begin ( ) const
inlinenodiscard

Read-only iterator to the first station entry.

◆ cbegin()

auto cda_rail::StationList::cbegin ( ) const
inlinenodiscard

Obtains a const iterator to the first station.

Returns
A const iterator to the beginning of the stations collection.

◆ cend()

auto cda_rail::StationList::cend ( ) const
inlinenodiscard

Read-only iterator past the last station entry (explicit const).

◆ end()

auto cda_rail::StationList::end ( ) const
inlinenodiscard

Read-only iterator past the last station entry.

◆ export_stations() [1/3]

void cda_rail::StationList::export_stations ( char const *const path,
const Network & network ) const
inline

Writes all stations to the specified directory.

Parameters
pathA C-string representing the target directory.
networkNetwork used to resolve edge endpoint names.
Exceptions
exceptions::ExportExceptionIf the directory cannot be created.

◆ export_stations() [2/3]

void cda_rail::StationList::export_stations ( const std::filesystem::path & p,
const Network & network ) const

Exports all stations to stations.json in the target directory.

Edge endpoints are written using vertex names from network.

Parameters
pTarget directory.
networkNetwork used to resolve edge endpoint names.
Exceptions
exceptions::ExportExceptionIf the target directory cannot be created.

◆ export_stations() [3/3]

void cda_rail::StationList::export_stations ( std::string const & path,
const Network & network ) const
inline

Convenience overload forwarding to the filesystem path export.

Parameters
pathTarget directory.
networkNetwork used to resolve edge endpoint names.

◆ get_station()

const cda_rail::Station & cda_rail::StationList::get_station ( const std::string & name) const
nodiscard

Retrieves a station by name.

Parameters
nameStation name.
Returns
Immutable reference to the requested station.
Exceptions
exceptions::StationNotExistentExceptionIf no station with name exists.

◆ get_station_names()

std::unordered_set< std::string > cda_rail::StationList::get_station_names ( ) const
nodiscard

Returns the set of all station names.

Returns
Unordered set containing each station name exactly once.

◆ get_stop_tracks()

std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > cda_rail::StationList::get_stop_tracks ( const std::string & name,
double tr_len,
const Network & network,
const cda_rail::index_set & edges_to_consider = {} ) const
inlinenodiscard

Computes possible stop tracks for a named station.

Parameters
nameStation name.
tr_lenTrain length.
networkNetwork containing the station edges.
edges_to_considerOptional candidate edges to filter the result. If empty, all station edges are considered.
Returns
Vector of pairs, where each pair contains a stop edge index and the set of valid in-station paths ending on that edge.
Exceptions
exceptions::StationNotExistentExceptionIf name is unknown.

◆ has_station()

bool cda_rail::StationList::has_station ( const std::string & name) const
inlinenodiscard

Checks whether a station with the given name exists.

Parameters
nameStation name.
Returns
true if present; otherwise false.

◆ import_stations() [1/3]

StationList cda_rail::StationList::import_stations ( const char * path,
const Network & network )
inlinestaticnodiscard

Imports stations from a C-string path.

Parameters
pathDirectory containing stations.json.
networkNetwork used to resolve edge endpoints.
Returns
StationList loaded from the specified directory.
Exceptions
exceptions::ImportExceptionif path does not exist or is not a directory.

◆ import_stations() [2/3]

StationList cda_rail::StationList::import_stations ( const std::filesystem::path & p,
const Network & network )
inlinestaticnodiscard

Imports stations from a filesystem path.

Parameters
pDirectory containing stations.json.
networkNetwork used to resolve edge endpoints.
Returns
Imported station list.
Exceptions
exceptions::ImportExceptionIf the directory does not exist or is not a directory.

◆ import_stations() [3/3]

StationList cda_rail::StationList::import_stations ( const std::string & path,
const Network & network )
inlinestaticnodiscard

Imports stations from a directory path string.

Parameters
pathDirectory containing stations.json.
networkNetwork used to resolve edge endpoints.
Returns
A StationList containing the imported stations.

◆ is_fully_in_station()

bool cda_rail::StationList::is_fully_in_station ( std::string const & station_name,
cda_rail::index_set const & edges ) const
nodiscard

Checks whether all given edges belong to a named station.

Parameters
station_nameStation to check.
edgesEdge indices to validate.
Returns
true if all edges are part of the station; otherwise false.
Exceptions
exceptions::StationNotExistentExceptionIf station_name is unknown.

◆ operator=() [1/2]

StationList & cda_rail::StationList::operator= ( const StationList & other)
inline

Copy assignment operator that performs a deep copy of all stations.

Parameters
otherThe StationList to copy from.
Returns
Reference to this StationList.

◆ operator=() [2/2]

StationList & cda_rail::StationList::operator= ( StationList && )
defaultnoexcept

Move assignment operator.

◆ size()

size_t cda_rail::StationList::size ( ) const
inlinenodiscard

Retrieves the number of stations.

Returns
size_t The number of stations.

◆ update_after_discretization() [1/2]

void cda_rail::StationList::update_after_discretization ( const std::vector< std::pair< size_t, cda_rail::index_set > > & new_edges)

Updates station tracks after network discretization.

For each pair (old_edge, replacement_edges), every occurrence of old_edge in a station is replaced by all edges in replacement_edges.

Parameters
new_edgesMapping from original edge index to replacement edge set.

◆ update_after_discretization() [2/2]

void cda_rail::StationList::update_after_discretization ( const std::vector< std::pair< size_t, cda_rail::index_vector > > & new_edges)

Updates station tracks after network discretization.

For each pair (old_edge, replacement_edges), every occurrence of old_edge in a station is replaced by all edges in replacement_edges.

Parameters
new_edgesMapping from original edge index to replacement edge vector.

◆ Timetable

friend class Timetable
friend

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