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 
50  virtual gd::InstructionsList* GetInstructionList(const gd::String& label) override;
51  virtual const gd::InstructionsList* GetInstructionList(const gd::String& label) const override;
52 
58  const gd::String& GetIterableVariableName() const { return iterableVariableName.GetPlainString(); };
59 
65  void SetIterableVariableName(gd::String newName) { iterableVariableName = newName; };
66 
73  const gd::String& GetValueIteratorVariableName() const { return valueIteratorVariableName.GetPlainString(); };
74 
81  void SetValueIteratorVariableName(gd::String newName) { valueIteratorVariableName = newName; };
82 
89  const gd::String& GetKeyIteratorVariableName() const { return keyIteratorVariableName.GetPlainString(); };
90 
97  void SetKeyIteratorVariableName(gd::String newName) { keyIteratorVariableName = newName; };
98 
99  const gd::String& GetLoopIndexVariableName() const { return loopIndexVariableName; }
100  void SetLoopIndexVariableName(const gd::String& name) { loopIndexVariableName = name; }
101 
102  virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
103  const;
104  virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
105 
106  virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
107  virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
108 
109  virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
110  GetAllExpressionsWithMetadata() const;
111  virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
112  GetAllExpressionsWithMetadata();
113 
114  virtual void SerializeTo(SerializerElement& element) const;
115  virtual void UnserializeFrom(gd::Project& project,
116  const SerializerElement& element);
117 
118  private:
119  gd::Expression valueIteratorVariableName;
120  gd::Expression keyIteratorVariableName;
121  gd::Expression iterableVariableName;
122  gd::InstructionsList conditions;
123  gd::InstructionsList actions;
124  gd::EventsList events;
125  VariablesContainer variables;
126  gd::String loopIndexVariableName;
127 };
128 
129 } // namespace gd
130 
131 #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:89
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:58
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:97
void SetValueIteratorVariableName(gd::String newName)
Set the value iterator variable attached to the event.
Definition: ForEachChildVariableEvent.h:81
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:73
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:65
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:51
String represents an UTF8 encoded string.
Definition: String.h:33
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:29
Definition: CommonTools.h:24