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  const gd::String& GetObjectToPick() const {
53  return objectsToPick.GetPlainString();
54  };
55  void SetObjectToPick(gd::String objectsToPick_) {
56  objectsToPick = gd::Expression(objectsToPick_);
57  };
58 
59  const gd::String& GetLoopIndexVariableName() const { return loopIndexVariableName; }
60  void SetLoopIndexVariableName(const gd::String& name) { loopIndexVariableName = name; }
61 
62  const gd::String& GetOrderBy() const {
63  return orderBy.GetPlainString();
64  };
65  void SetOrderBy(gd::String orderBy_) {
66  orderBy = gd::Expression(orderBy_);
67  };
68  const gd::Expression& GetOrderByExpression() const { return orderBy; };
69 
70  const gd::String& GetOrder() const { return order; }
71  void SetOrder(const gd::String& order_) { order = order_; }
72 
73  const gd::String& GetLimit() const {
74  return limit.GetPlainString();
75  };
76  void SetLimit(gd::String limit_) {
77  limit = gd::Expression(limit_);
78  };
79  const gd::Expression& GetLimitExpression() const { return limit; };
80 
81  virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
82  const;
83  virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
84  virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
85  GetAllExpressionsWithMetadata() const;
86 
87  virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
88  virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
89  virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
90  GetAllExpressionsWithMetadata();
91 
92  virtual void SerializeTo(SerializerElement& element) const;
93  virtual void UnserializeFrom(gd::Project& project,
94  const SerializerElement& element);
95 
96  private:
97  gd::Expression objectsToPick;
98  gd::InstructionsList conditions;
99  gd::InstructionsList actions;
100  gd::EventsList events;
101  VariablesContainer variables;
102  gd::String loopIndexVariableName;
103  gd::Expression orderBy;
104  gd::String order;
105  gd::Expression limit;
106 };
107 
108 } // namespace gd
109 
110 #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: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