Model Railroad System
2.2.2
|
Freight Car Forwarder C++ support classes.
Freight Car Forwarder C++ support classes.
These classes implement the low-level support code for my second port of Tim O'Connor's Freight Car Forwarder system. The main class, System, implements a complete railroad system, which consists of one or more divisions with one or more stations and industries. Running over the trackage are one or more trains, pulling an assortment of cars (some loaded and some empty). The cars are of various types, suitable for various types of loads. The system class collects the data for all of these items into one big data structure and implements the various algorithms to create a freight car forwarding system using switchlists. The original system was written in QBASIC and was a mess of spaghetti code. I first recoded it as a pure Tcl/Tk application and because Tcl completely lacks a 'goto' statement, I needed to unravel every strand of 'spaghetti'. The Tcl code worked, but was somewhat slow. This C++ version puts the more computationaly intensive (mostly heavy data indexing logic) into C++, using the STL to implement the various aggregate collections of objects. These objects are indexed and crossed indexed heavily and the forwarding algorithms traverses these collections frequently. @author Robert Heller \<heller\@deepsoft.com\>