GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
EffectsContainer.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 #ifndef GDCORE_EFFECTS_CONTAINER_H
7 #define GDCORE_EFFECTS_CONTAINER_H
8 #include <memory>
9 #include <vector>
10 #include <algorithm>
11 
12 #include "GDCore/String.h"
13 
14 namespace gd {
15 class Effect;
16 }
17 namespace gd {
18 class SerializerElement;
19 }
20 
21 namespace gd {
22 
29 class GD_CORE_API EffectsContainer {
30  public:
32  EffectsContainer(const EffectsContainer& other);
33  virtual ~EffectsContainer(){};
34 
35  EffectsContainer& operator=(const EffectsContainer& rhs);
39  bool HasEffectNamed(const gd::String& name) const;
40 
44  Effect& GetEffect(const gd::String& name);
45 
49  const Effect& GetEffect(const gd::String& name) const;
50 
54  Effect& GetEffect(std::size_t index);
55 
59  const Effect& GetEffect(std::size_t index) const;
60 
64  std::size_t GetEffectPosition(const gd::String& name) const;
65 
69  std::size_t GetEffectsCount() const;
70 
74  gd::Effect& InsertNewEffect(const gd::String& name, std::size_t position);
75 
86  void InsertEffect(const Effect& theEffect, std::size_t position);
87 
91  void RemoveEffect(const gd::String& name);
92 
96  void MoveEffect(std::size_t oldIndex, std::size_t newIndex);
97 
101  void SwapEffects(std::size_t firstEffectIndex, std::size_t secondEffectIndex);
102 
106  void SerializeTo(SerializerElement& element) const;
107 
111  void UnserializeFrom(const SerializerElement& element);
112 
116  inline void Clear() { effects.clear(); }
117 
118  private:
119  std::vector<std::shared_ptr<gd::Effect>> effects;
120  static Effect badEffect;
121  void Init(const EffectsContainer& other);
122 };
123 } // namespace gd
124 
125 #endif
Represents an effect that can be applied on a layer.
Definition: Effect.h:22
Contains effects applied to an entity on screen (i.e: a Layer or an Object).
Definition: EffectsContainer.h:29
void Clear()
Clear all effects of the container.
Definition: EffectsContainer.h:116
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:31
Definition: CommonTools.h:24