Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
RailRunnerParser.h
1// trax track library
2// AD 2024
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8//
9// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
10// Copyright (c) 2019 Marc-Michael Horstmann
11//
12// Permission is hereby granted to any person obtaining a copy of this software
13// and associated source code (the "Software"), to use, view, and study the
14// Software for personal or internal business purposes, subject to the following
15// conditions:
16//
17// 1. Redistribution, modification, sublicensing, or commercial use of the
18// Software is NOT permitted without prior written consent from the copyright
19// holder.
20//
21// 2. The Software is provided "AS IS", without warranty of any kind, express
22// or implied.
23//
24// 3. All copies of the Software must retain this license notice.
25//
26// For further information, please contact: horstmann.marc@trendverlag.de
27
28#pragma once
29
30#include "trax/Parser.h"
31
32#include "trax/rigid/Geom.h"
33#include "trax/rigid/trains/RailRunner.h"
34
35#include <filesystem>
36#include <string>
37
38namespace trax{
39
40 struct Bogie;
41 struct Fleet;
42 struct Material;
43 struct RollingStock;
44 struct TrackJointLimits;
45 struct Train;
46 struct WheelFrameLimits;
47 struct Wheelset;
48
49
50 class RollingStockParser : public virtual Parser{
51 public:
52 virtual bool RollingStockStart() noexcept(false) { return true; }
53
54
55 virtual bool BogieStart(
56 IDType /*id*/,
57 const std::string& /*name*/,
58 const std::string& /*model*/ ) noexcept(false) { return true; }
59
60 virtual void BogieFrame(
61 const spat::Frame<dim::Length,dim::One>& /*frame*/ ) noexcept{}
62
63 virtual bool GeomStart(
64 const std::string& /*name*/,
65 Geom::Filters /*filter*/,
66 GeomType /*type*/,
67 Mass /*mass*/ ) noexcept(false) { return true; }
68
69 virtual void Material(
70 const Material& /*material*/ ) noexcept {}
71
72 virtual void GeomEnd(
73 const std::string& /*name*/,
74 Geom::Filters /*filter*/,
75 GeomType /*type*/,
76 Mass /*mass*/ ) noexcept(false) {}
77
78 virtual void Coupling(
79 RailRunner::EndType /*end*/,
80 Length /*bufferLength*/,
81 Force /*maxForce*/,
82 IDType /*typeID*/,
83 const spat::Frame<dim::Length,dim::One>& /*frame*/ ) noexcept(false) {}
84
85 virtual void Swivel(
86 RailRunner::EndType /*slot*/,
87 IDType /*childID*/,
88 const spat::Frame<dim::Length,dim::One>& /*frame*/ ) noexcept(false) {}
89
90 virtual void BogieEnd(
91 const std::string& /*sndGroup*/ ) noexcept {}
92
93
94 virtual bool WheelFrameStart(
95 IDType /*id*/,
96 const std::string& /*name*/,
97 const std::string& /*model*/ ) noexcept(false) { return true; }
98
99 virtual bool TractionForceCharacteristicStart() noexcept(false) { return true; }
100
101 virtual void SpeedStep(
102 Velocity /*velocity*/,
103 One /*value*/ ) noexcept {}
104
105 virtual void TractionForceCharacteristicEnd() noexcept(false) {}
106
107 virtual void TrackJointLimits(
108 const TrackJointLimits& /*trackJointLimits*/ ) noexcept {}
109
110 virtual void Wheelset(
111 const Wheelset& /*wheelset*/ ) noexcept {}
112
113 virtual bool TrackLocation(
114 const TrackLocationRef& /*trackLocation*/ ) noexcept(false) { return true; }
115
116 virtual void Anchor(
117 const spat::Frame<dim::Length,dim::One>& /*anchor*/ ) noexcept {}
118
119 virtual void WheelFrameEnd(
120 const std::string& /*sndGroup*/ ) noexcept {}
121
122
123 virtual void RollingStockEnd() noexcept(false) {}
124 };
125
126
127 class TrainParser : public virtual Parser{
128 public:
129
130 virtual bool TrainStart(
131 IDType /*id*/,
132 const std::string& /*name*/,
133 const std::string& /*reference*/,
134 Velocity /*travel_velocity*/,
135 Velocity /*velocity*/,
136 One /*trainThrust*/,
137 One /*trainBrake*/,
138 int32_t /*credit*/ ) noexcept(false) {
139 return true;
140 }
141
142 virtual void TrackLocation(
143 const TrackLocationRef& /*trackLocation*/ ) noexcept(false) {}
144
145 virtual RollingStockParser* AxisArrangementStart(
146 const std::string& /*name*/,
147 const std::string& /*reference*/ ) noexcept(false){
148 return nullptr;
149 }
150
151 virtual void AxisArrangementEnd(
152 Orientation /*orientation*/ ) noexcept(false){}
153
154 virtual RollingStockParser* RollingStockStart(
155 const std::string& /*name*/,
156 const std::string& /*reference*/ ) noexcept(false){
157 return nullptr;
158 }
159
160 virtual void RollingStockEnd(
161 Orientation /*orientation*/ ) noexcept(false){}
162
163 virtual void TrainEnd(
164 trax::Orientation /*orientation*/,
165 bool /*automatic*/,
166 bool /*couplingNorthActivated*/,
167 bool /*couplingSouthActivated*/ ) noexcept(false) {}
168 };
169
170
171 class FleetParser : public virtual TrainParser{
172 public:
173 virtual bool FleetStart(
174 IDType /*id*/ ) noexcept(false) {
175 return true;
176 }
177
178 virtual void FleetEnd() noexcept(false) {}
179 };
180
181
182 void dclspc ParseRollingStock( std::basic_istream<char>& stream, RollingStockParser& callback ) noexcept(false);
183
184 void dclspc ParseRollingStock( const std::filesystem::path& filePath, RollingStockParser& callback ) noexcept(false);
185
186 void dclspc ParseRollingStock( const Bogie& rollingStock, RollingStockParser& callback ) noexcept(false);
187
188 void dclspc ParseTrain( const unsigned char* bufferStart, const unsigned char* bufferEnd, TrainParser& callback ) noexcept(false);
189
190 void dclspc ParseTrain( std::basic_istream<char>& stream, TrainParser& callback ) noexcept(false);
191
192 void dclspc ParseTrain( const std::filesystem::path& filePath, TrainParser& callback ) noexcept(false);
193
194 void dclspc ParseTrain( const Train& train, TrainParser& callback ) noexcept(false);
195
196 bool dclspc ParseFleet( std::basic_istream<char>& stream, FleetParser& callback ) noexcept(false);
197
198 bool dclspc ParseFleet( const std::filesystem::path& filePath, FleetParser& callback ) noexcept(false);
199
200 bool dclspc ParseFleet( const Fleet& fleet, FleetParser& callback ) noexcept(false);
201
202}
Definition RailRunnerParser.h:171
Definition RailRunnerParser.h:50
Definition RailRunnerParser.h:127
Value< Dimension< 1, 0, -1 > > Velocity
Velocity.
Definition DimensionedValues.h:331
Value< Dimension< 0, 0, 0 > > One
Dimensionless value.
Definition DimensionedValues.h:319
Value< Dimension< 1, 0, 0 > > Length
Length.
Definition DimensionedValues.h:324
Value< Dimension< 0, 1, 0 > > Mass
Mass.
Definition DimensionedValues.h:327
Value< Dimension< 1, 1, -2 > > Force
Force.
Definition DimensionedValues.h:333
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
GeomType
Type of a geom.
Definition GeomType.h:33
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
A Bogie is a RailRunner that can be attached to another Bogie by a swivel and can be coupled to anoth...
Definition Bogie.h:67
A Fleet holds Trains and (topmost) Bogies via their common interface RailRunner.
Definition Fleet.h:48
Filters
Filter flags that will serve in fast collision testing.
Definition Geom.h:110
Type used for IDs in the trax library.
Definition IDType.h:43
Definition Material.h:34
Provides two values for orientation.
Definition Orientation.h:37
EndType
Types of the RailRunner's end's.
Definition RailRunner.h:351
A RollingStock is a RailRunner that manages one or more connected Bogies.
Definition RollingStock.h:45
The maximum forces and spatial deviations of a WheelFrame used by physics calculations.
Definition TrackJointLimits.h:38
A track location, referencing the track by id.
Definition TrackLocation.h:102
A Train is a collection of TrainComponents that are coupled in a row.
Definition Train.h:43
Describing data of a wheelset.
Definition Wheelset.h:40