GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ForEachChildVariableEvent.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 #ifndef FOREACHCHILDVARIABLEEVENT_H
8 #define FOREACHCHILDVARIABLEEVENT_H
9 #include "GDCore/Events/Event.h"
10 #include "GDCore/Events/EventsList.h"
11 #include "GDCore/Events/Expression.h"
12 #include "GDCore/Project/VariablesContainer.h"
13 namespace gd {
14 class Instruction;
15 class Project;
16 class Layout;
17 } // namespace gd
18 
19 namespace gd {
20 
24 class GD_CORE_API ForEachChildVariableEvent : public gd::BaseEvent {
25  public:
27  virtual ~ForEachChildVariableEvent(){};
29  return new ForEachChildVariableEvent(*this);
30  }
31 
32  virtual bool IsExecutable() const { return true; }
33 
34  virtual bool CanHaveSubEvents() const { return true; }
35  virtual const gd::EventsList& GetSubEvents() const { return events; };
36  virtual gd::EventsList& GetSubEvents() { return events; };
37 
38  virtual bool CanHaveVariables() const { return true; }
39  virtual const gd::VariablesContainer& GetVariables() const {
40  return variables;
41  };
42  virtual gd::VariablesContainer& GetVariables() { return variables; };
43 
44  const gd::InstructionsList& GetConditions() const { return conditions; };
45  gd::InstructionsList& GetConditions() { return conditions; };
46 
47  const gd::InstructionsList& GetActions() const { return actions; };
48  gd::InstructionsList& GetActions() { return actions; };
49 
55  const gd::String& GetIterableVariableName() const { return iterableVariableName.GetPlainString(); };
56 
62  void SetIterableVariableName(gd::String newName) { iterableVariableName = newName; };
63 
70  const gd::String& GetValueIteratorVariableName() const { return valueIteratorVariableName.GetPlainString(); };
71 
78  void SetValueIteratorVariableName(gd::String newName) { valueIteratorVariableName = newName; };
79 
86  const gd::String& GetKeyIteratorVariableName() const { return keyIteratorVariableName.GetPlainString(); };
87 
94  void SetKeyIteratorVariableName(gd::String newName) { keyIteratorVariableName = newName; };
95 
96  const gd::String& GetLoopIndexVariableName() const { return loopIndexVariableName; }
97  void SetLoopIndexVariableName(const gd::String& name) { loopIndexVariableName = name; }
98 
99  virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
100  const;
101  virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
102 
103  virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
104  virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
105 
106  virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
107  GetAllExpressionsWithMetadata() const;
108  virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
109  GetAllExpressionsWithMetadata();
110 
111  virtual void SerializeTo(SerializerElement& element) const;
112  virtual void UnserializeFrom(gd::Project& project,
113  const SerializerElement& element);
114 
115  private:
116  gd::Expression valueIteratorVariableName;
117  gd::Expression keyIteratorVariableName;
118  gd::Expression iterableVariableName;
119  gd::InstructionsList conditions;
120  gd::InstructionsList actions;
121  gd::EventsList events;
122  VariablesContainer variables;
123  gd::String loopIndexVariableName;
124 };
125 
126 } // namespace gd
127 
128 #endif // FOREACHEVENT_H
Base class defining an event.
Definition: Event.h:43
A list of events.
Definition: EventsList.h:32
Class representing an expression used as a parameter of a gd::Instruction. This class is nothing more...
Definition: Expression.h:30
Event repeated for each every child of a structure variable.
Definition: ForEachChildVariableEvent.h:24
virtual bool CanHaveSubEvents() const
Definition: ForEachChildVariableEvent.h:34
const gd::String & GetKeyIteratorVariableName() const
Get the key iterator variable attached to the event.
Definition: ForEachChildVariableEvent.h:86
virtual bool CanHaveVariables() const
Definition: ForEachChildVariableEvent.h:38
const gd::String & GetIterableVariableName() const
Get the iterable variable name attached to the event.
Definition: ForEachChildVariableEvent.h:55
virtual gd::ForEachChildVariableEvent * Clone() const
Definition: ForEachChildVariableEvent.h:28
void SetKeyIteratorVariableName(gd::String newName)
Set the key iterator variable attached to the event.
Definition: ForEachChildVariableEvent.h:94
void SetValueIteratorVariableName(gd::String newName)
Set the value iterator variable attached to the event.
Definition: ForEachChildVariableEvent.h:78
virtual const gd::EventsList & GetSubEvents() const
Definition: ForEachChildVariableEvent.h:35
const gd::String & GetValueIteratorVariableName() const
Get the value iterator variable attached to the event.
Definition: ForEachChildVariableEvent.h:70
virtual bool IsExecutable() const
Definition: ForEachChildVariableEvent.h:32
virtual gd::EventsList & GetSubEvents()
Definition: ForEachChildVariableEvent.h:36
void SetIterableVariableName(gd::String newName)
Set the iterable variable name attached to the event.
Definition: ForEachChildVariableEvent.h:62
virtual const gd::VariablesContainer & GetVariables() const
Definition: ForEachChildVariableEvent.h:39
virtual gd::VariablesContainer & GetVariables()
Definition: ForEachChildVariableEvent.h:42
Definition: InstructionsList.h:25
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
String represents an UTF8 encoded string.
Definition: String.h:33
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:28
Definition: CommonTools.h:24