GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ForEachEvent.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 FOREACHEVENT_H
8 #define FOREACHEVENT_H
9 #include <vector>
10 
11 #include "GDCore/Events/Event.h"
12 #include "GDCore/Events/EventsList.h"
13 #include "GDCore/Project/VariablesContainer.h"
14 namespace gd {
15 class Instruction;
16 class Project;
17 class Layout;
18 }
19 
20 namespace gd {
21 
28 class GD_CORE_API ForEachEvent : public gd::BaseEvent {
29  public:
30  ForEachEvent();
31  virtual ~ForEachEvent(){};
32  virtual gd::ForEachEvent* Clone() const { return new ForEachEvent(*this); }
33 
34  virtual bool IsExecutable() const { return true; }
35 
36  virtual bool CanHaveSubEvents() const { return true; }
37  virtual const gd::EventsList& GetSubEvents() const { return events; };
38  virtual gd::EventsList& GetSubEvents() { return events; };
39 
40  virtual bool CanHaveVariables() const { return true; }
41  virtual const gd::VariablesContainer& GetVariables() const {
42  return variables;
43  };
44  virtual gd::VariablesContainer& GetVariables() { return variables; };
45 
46  const gd::InstructionsList& GetConditions() const { return conditions; };
47  gd::InstructionsList& GetConditions() { return conditions; };
48 
49  const gd::InstructionsList& GetActions() const { return actions; };
50  gd::InstructionsList& GetActions() { return actions; };
51 
52  virtual gd::InstructionsList* GetInstructionList(const gd::String& label) override;
53  virtual const gd::InstructionsList* GetInstructionList(const gd::String& label) const override;
54 
55  const gd::String& GetObjectToPick() const {
56  return objectsToPick.GetPlainString();
57  };
58  void SetObjectToPick(gd::String objectsToPick_) {
59  objectsToPick = gd::Expression(objectsToPick_);
60  };
61 
62  const gd::String& GetLoopIndexVariableName() const { return loopIndexVariableName; }
63  void SetLoopIndexVariableName(const gd::String& name) { loopIndexVariableName = name; }
64 
65  const gd::String& GetOrderBy() const {
66  return orderBy.GetPlainString();
67  };
68  void SetOrderBy(gd::String orderBy_) {
69  orderBy = gd::Expression(orderBy_);
70  };
71  const gd::Expression& GetOrderByExpression() const { return orderBy; };
72 
73  const gd::String& GetOrder() const { return order; }
74  void SetOrder(const gd::String& order_) { order = order_; }
75 
76  const gd::String& GetLimit() const {
77  return limit.GetPlainString();
78  };
79  void SetLimit(gd::String limit_) {
80  limit = gd::Expression(limit_);
81  };
82  const gd::Expression& GetLimitExpression() const { return limit; };
83 
84  virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
85  const;
86  virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
87  virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
88  GetAllExpressionsWithMetadata() const;
89 
90  virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
91  virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
92  virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
93  GetAllExpressionsWithMetadata();
94 
95  virtual void SerializeTo(SerializerElement& element) const;
96  virtual void UnserializeFrom(gd::Project& project,
97  const SerializerElement& element);
98 
99  private:
100  gd::Expression objectsToPick;
101  gd::InstructionsList conditions;
102  gd::InstructionsList actions;
103  gd::EventsList events;
104  VariablesContainer variables;
105  gd::String loopIndexVariableName;
106  gd::Expression orderBy;
107  gd::String order;
108  gd::Expression limit;
109 };
110 
111 } // namespace gd
112 
113 #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 object of a list.
Definition: ForEachEvent.h:28
virtual gd::EventsList & GetSubEvents()
Definition: ForEachEvent.h:38
virtual bool IsExecutable() const
Definition: ForEachEvent.h:34
virtual bool CanHaveVariables() const
Definition: ForEachEvent.h:40
virtual const gd::EventsList & GetSubEvents() const
Definition: ForEachEvent.h:37
virtual gd::ForEachEvent * Clone() const
Definition: ForEachEvent.h:32
virtual const gd::VariablesContainer & GetVariables() const
Definition: ForEachEvent.h:41
virtual gd::VariablesContainer & GetVariables()
Definition: ForEachEvent.h:44
virtual bool CanHaveSubEvents() const
Definition: ForEachEvent.h:36
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