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

Functions

Vector< std::tuple< int, double, double, std::string, double, double > > readNodesFile (const std::string &fileName)
 Reads the nodes file.
 
bool writeNodesFile (Vector< std::tuple< int, double, double, std::string, double, double > > nodesRecords, std::string &filename)
 Writes the nodes file.
 
Vector< std::tuple< int, int, int, double, int, double, double, int, double, bool, string, string, double > > readLinksFile (const std::string &fileName)
 Reads the links file.
 
bool writeLinksFile (Vector< std::tuple< int, int, int, double, int, double, double, int, double, bool, string, string, double > > linksRecords, std::string &filename)
 Writes the links file.
 
Vector< std::shared_ptr< NetNode > > generateNodes (Vector< std::tuple< int, double, double, std::string, double, double > > nodesRecords)
 Generates NetNode objects from the nodes records.
 
Vector< std::shared_ptr< NetLink > > generateLinks (Vector< std::shared_ptr< NetNode > > theFileNodes, Vector< std::tuple< int, int, int, double, int, double, double, int, double, bool, string, string, double > > linksRecords)
 Generates NetLink objects from the nodes and links records.
 
std::shared_ptr< NetNodegetSimulatorNodeByUserID (Vector< std::shared_ptr< NetNode > > theFileNodes, int oldID)
 Gets the NetNode object with the given user identifier.
 

Function Documentation

◆ generateLinks()

Vector< std::shared_ptr< NetLink > > ReadWriteNetwork::generateLinks ( Vector< std::shared_ptr< NetNode > >  theFileNodes,
Vector< std::tuple< int, int, int, double, int, double, double, int, double, bool, string, string, double > >  linksRecords 
)

Generates NetLink objects from the nodes and links records.

Parameters
theFileNodesThe NetNode objects generated from the nodes records.
linksRecordsThe records of links as a vector of tuples.
Returns
The generated NetLink objects as a vector.

◆ generateNodes()

Vector< std::shared_ptr< NetNode > > ReadWriteNetwork::generateNodes ( Vector< std::tuple< int, double, double, std::string, double, double > >  nodesRecords)

Generates NetNode objects from the nodes records.

readNodesFile

Parameters
nodesRecordsThe records of nodes as a vector of tuples.
Returns
The generated NetNode objects as a vector.
Parameters
nodesRecords
Returns

◆ getSimulatorNodeByUserID()

std::shared_ptr< NetNode > ReadWriteNetwork::getSimulatorNodeByUserID ( Vector< std::shared_ptr< NetNode > >  theFileNodes,
int  oldID 
)

Gets the NetNode object with the given user identifier.

Gets simulator node by user identifier.

Parameters
theFileNodesThe NetNode objects generated from the nodes records.
oldIDThe user identifier of the NetNode to retrieve.
Returns
The NetNode object with the specified user identifier, or nullptr if not found.
Exceptions
std::runtime_errorif a runtime error occurs.
Author
Ahmed
Date
2/14/2023
Exceptions
std::runtime_errorRaised when a runtime error condition occurs.
Parameters
oldIDIdentifier for the old.
Returns
The simulator node by user identifier.

◆ readLinksFile()

Vector< std::tuple< int, int, int, double, int, double, double, int, double, bool, std::string, std::string, double > > ReadWriteNetwork::readLinksFile ( const std::string &  fileName)

Reads the links file.

Reads links file.

Parameters
fileNameThe filename of the file.
Returns
The records of links as a vector of tuples. Each tuple contains the link attributes including the IDs of the connected nodes, length, speed, etc.
Exceptions
std::runtime_errorif a runtime error occurs.
Author
Ahmed
Date
2/14/2023
Exceptions
std::runtime_errorRaised when a runtime error condition occurs.
Parameters
fileNameFilename of the file.
Returns
The links data. A vector record has the following:
  1. Link User ID
  2. Start Node User ID
  3. End Node User ID
  4. Link Length
  5. Link Max Speed (m/s)
  6. Signal User ID
  7. Link Grade
  8. Link Curvature
  9. Link Number of Directions
  10. Speed Variation Factor
  11. Is Catenary Available for this link
  12. Signal Placed At Which End Node ID
  13. The Region the link is in

◆ readNodesFile()

Vector< std::tuple< int, double, double, std::string, double, double > > ReadWriteNetwork::readNodesFile ( const std::string &  fileName)

Reads the nodes file.

Reads nodes file.

Parameters
fileNameThe filename of the file.
Returns
The records of nodes as a vector of tuples. Each tuple contains the ID, x-coordinate, y-coordinate, description, x-scale, and y-scale of a node.
Exceptions
std::runtime_errorif a runtime error occurs.
Author
Ahmed
Date
2/14/2023
Exceptions
std::runtime_errorRaised when a runtime error condition occurs.
Parameters
fileNameFilename of the file.
Returns
The tuple of IDs as a vector, x coordinates as a vector, y coordinates as a vector, description as a vector, x scale, and y scale as doubles.

◆ writeLinksFile()

bool ReadWriteNetwork::writeLinksFile ( Vector< std::tuple< int, int, int, double, int, double, double, int, double, bool, string, string, double > >  linksRecords,
std::string &  filename 
)

Writes the links file.

Parameters
linksRecordsThe records of links as a vector of tuples.
filenameThe filename of the file to write.
Returns
True if the write operation is successful, false otherwise.

◆ writeNodesFile()

bool ReadWriteNetwork::writeNodesFile ( Vector< std::tuple< int, double, double, std::string, double, double > >  nodesRecords,
std::string &  filename 
)

Writes the nodes file.

Parameters
nodesRecordsThe records of nodes as a vector of tuples.
filenameThe filename of the file to write.
Returns
True if the write operation is successful, false otherwise.