GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
LayersContainer.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 
7 #pragma once
8 
9 #include <vector>
10 
11 #include "GDCore/Project/Layer.h"
12 #include "GDCore/Project/MemoryTrackedRegistry.h"
13 #include "GDCore/String.h"
14 
15 namespace gd {
16 
22 class GD_CORE_API LayersContainer {
23  public:
25  LayersContainer(const LayersContainer& other) : layers(other.layers) {};
26  LayersContainer& operator=(const LayersContainer& other) {
27  if (this != &other) {
28  layers = other.layers;
29  }
30  return *this;
31  }
32 
36  bool HasLayerNamed(const gd::String& name) const;
37 
41  Layer& GetLayer(const gd::String& name);
42 
46  const Layer& GetLayer(const gd::String& name) const;
47 
52  Layer& GetLayer(std::size_t index);
53 
58  const Layer& GetLayer(std::size_t index) const;
59 
63  std::size_t GetLayerPosition(const gd::String& name) const;
64 
68  std::size_t GetLayersCount() const;
69 
74  void InsertNewLayer(const gd::String& name, std::size_t position);
75 
82  void InsertLayer(const Layer& theLayer, std::size_t position);
83 
87  void RemoveLayer(const gd::String& name);
88 
92  void SwapLayers(std::size_t firstLayerIndex, std::size_t secondLayerIndex);
93 
97  void MoveLayer(std::size_t oldIndex, std::size_t newIndex);
98 
99  void Reset();
100 
104  void SerializeLayersTo(SerializerElement& element) const;
105 
109  void UnserializeLayersFrom(const SerializerElement& element);
110 
111  private:
112  static gd::Layer badLayer;
114  std::vector<gd::Layer> layers;
115  gd::MemoryTracked _memoryTracked{this, "LayersContainer"};
116 };
117 
118 } // namespace gd
Represents a layer of a layout.
Definition: Layer.h:91
Contains the layers for a scene or a custom object.
Definition: LayersContainer.h:22
A non-copyable, non-movable member object that registers/unregisters its owner with MemoryTrackedRegi...
Definition: MemoryTrackedRegistry.h:238
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24