Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
RollingStockFileReader.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
31#include <filesystem>
32
33namespace trax{
34
36 struct TrainScene;
37
39 class FileReader{
40 public:
41 FileReader( std::filesystem::path basePath = std::filesystem::path{} ) noexcept;
42
43 inline bool operator()( std::filesystem::path filePath ){
44 return Read( filePath );
45 }
46
51 virtual bool Read( std::filesystem::path filePath ) = 0;
52
53 protected:
54 inline std::filesystem::path GetBasePath() const noexcept{
55 return m_BasePath;
56 }
57
58 bool MakeValidPath( std::filesystem::path& path ) const noexcept;
59 private:
60 std::filesystem::path m_BasePath;
61 };
62
63
64 class RollingStockFileReader_Base : public FileReader{
65 public:
66 RollingStockFileReader_Base( RollingStockParser& parser, std::filesystem::path basePath = std::filesystem::path{} ) noexcept;
67
68 protected:
69 RollingStockParser& m_Parser;
70
71 };
72
73 class RollingStockFileReader : public RollingStockFileReader_Base{
74 public:
75 RollingStockFileReader( RollingStockParser& parser, std::filesystem::path basePath = std::filesystem::path{} ) noexcept;
76
77 bool Read( std::filesystem::path filePath ) override;
78 };
79
80} // namespace trax
81
virtual bool Read(std::filesystem::path filePath)=0
Reads an object from a file.
bool Read(std::filesystem::path filePath) override
Reads an object from a file.
Definition RailRunnerParser.h:50
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17