supertux
sector_parser.hpp
1 // SuperTux
2 // Copyright (C) 2015 Ingo Ruhnke <grumbel@gmail.com>
3 // 2023 Vankata453
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef HEADER_SUPERTUX_SUPERTUX_SECTOR_PARSER_HPP
19 #define HEADER_SUPERTUX_SUPERTUX_SECTOR_PARSER_HPP
20 
21 #include <memory>
22 #include <string>
23 
24 class GameObject;
25 class Level;
26 class ReaderMapping;
27 class Sector;
28 
29 namespace Base {
30  class Sector;
31 }
32 
34 {
35 public:
36  static std::unique_ptr<Sector> from_reader(Level& level, const ReaderMapping& sector, bool editable);
37  static std::unique_ptr<Sector> from_reader_old_format(Level& level, const ReaderMapping& sector, bool editable);
38  static std::unique_ptr<Sector> from_nothing(Level& level);
39 
40 protected:
41  SectorParser(Base::Sector& sector, bool editable);
42  virtual ~SectorParser() {}
43 
44  void parse_old_format(const ReaderMapping& reader);
45  void parse(const ReaderMapping& reader);
46  void create_sector();
47 
48  std::unique_ptr<GameObject> parse_object(const std::string& name, const ReaderMapping& reader);
49 
52  virtual bool parse_object_additional(const std::string& name, const ReaderMapping& reader);
53 
54 protected:
55  Base::Sector& m_sector;
56  bool m_editable;
57 
58 private:
59  SectorParser(const SectorParser&) = delete;
60  SectorParser& operator=(const SectorParser&) = delete;
61 };
62 
63 #endif
64 
65 /* EOF */
Represents one of (potentially) multiple, separate parts of a Level.
Definition: sector.hpp:61
Definition: sector_parser.hpp:33
A base for sector classes.
Definition: sector_base.hpp:30
Represents a collection of Sectors running in a single GameSession.
Definition: level.hpp:30
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Definition: sector_base.cpp:22
Definition: reader_mapping.hpp:32