tmxlite 1.0.0
lightweight parse for Tiled maps
LayerGroup.hpp
1/*********************************************************************
2Grant Gangi 2019 - 2022
3
4tmxlite - Zlib license.
5
6This software is provided 'as-is', without any express or
7implied warranty. In no event will the authors be held
8liable for any damages arising from the use of this software.
9
10Permission is granted to anyone to use this software for any purpose,
11including commercial applications, and to alter it and redistribute
12it freely, subject to the following restrictions:
13
141. The origin of this software must not be misrepresented;
15you must not claim that you wrote the original software.
16If you use this software in a product, an acknowledgment
17in the product documentation would be appreciated but
18is not required.
19
202. Altered source versions must be plainly marked as such,
21and must not be misrepresented as being the original software.
22
233. This notice may not be removed or altered from any
24source distribution.
25*********************************************************************/
26
27#pragma once
28
29#include <tmxlite/Config.hpp>
30#include <tmxlite/Layer.hpp>
31#include <tmxlite/Types.hpp>
32
33#include <vector>
34
35namespace tmx
36{
42 class TMXLITE_EXPORT_API LayerGroup final : public Layer
43 {
44 public:
45
46 LayerGroup(const std::string& workDir, const Vector2u& tileCount);
47 ~LayerGroup() = default;
48 LayerGroup(const LayerGroup&) = delete;
49 const LayerGroup& operator = (const LayerGroup&) = delete;
50 LayerGroup(LayerGroup&&) = default;
51 LayerGroup& operator = (LayerGroup&&) = default;
52
53
54 Type getType() const override { return Layer::Type::Group; }
55 void parse(const pugi::xml_node&, Map*) override;
56
63 const std::vector<Layer::Ptr>& getLayers() const { return m_layers; }
64
65 private:
66
67 std::vector<Layer::Ptr> m_layers;
68
69 std::string m_workingDir;
70 Vector2u m_tileCount;
71 };
72
73 template <>
74 inline LayerGroup& Layer::getLayerAs<LayerGroup>()
75 {
76 assert(getType() == Type::Group);
77 return *static_cast<LayerGroup*>(this);
78 }
79
80 template <>
81 inline const LayerGroup& Layer::getLayerAs<LayerGroup>() const
82 {
83 assert(getType() == Type::Group);
84 return *static_cast<const LayerGroup*>(this);
85 }
86}
Layer groups are used to organize the layers of the map in a hierarchy. They can contain all other la...
Definition LayerGroup.hpp:43
const std::vector< Layer::Ptr > & getLayers() const
Returns a reference to the vector containing the layer data. Layers are pointer-to-baseclass,...
Definition LayerGroup.hpp:63
void parse(const pugi::xml_node &, Map *) override
Attempts to parse the specific node layer type.
Type getType() const override
Returns a Type value representing the concrete type. Use this when deciding which conrete layer type ...
Definition LayerGroup.hpp:54
Represents a layer of a tmx format tile map. This is an abstract base class from which all layer type...
Definition Layer.hpp:56
T & getLayerAs()
Use this to get a reference to the concrete layer type which this layer points to....
Type
Layer type as returned by getType() Tile: this layer is a TileLayer type Object: This layer is an Obj...
Definition Layer.hpp:71
virtual Type getType() const =0
Returns a Type value representing the concrete type. Use this when deciding which conrete layer type ...
Parser for TMX format tile maps. This class can be used to parse the XML format tile maps created wit...
Definition Map.hpp:94