GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
EventsVariableReplacer.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 #pragma once
7 
8 #include <map>
9 #include <memory>
10 #include <unordered_map>
11 #include <unordered_set>
12 #include <vector>
13 
14 #include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
15 #include "GDCore/String.h"
16 
17 namespace gd {
18 class BaseEvent;
19 class VariablesContainer;
20 class EventsList;
21 class Platform;
22 struct VariablesRenamingChangesetNode;
23 } // namespace gd
24 
25 namespace gd {
26 
33 class GD_CORE_API EventsVariableReplacer
35  public:
37  const gd::Platform &platform_,
38  const VariablesRenamingChangesetNode &variablesRenamingChangesetRoot_,
39  const std::unordered_set<gd::String> &removedVariableNames_,
40  const gd::VariablesContainer &targetVariablesContainer_)
41  : platform(platform_),
42  variablesRenamingChangesetRoot(variablesRenamingChangesetRoot_),
43  removedVariableNames(removedVariableNames_),
44  targetVariablesContainer(targetVariablesContainer_),
45  targetGroupName("") {};
47  const gd::Platform &platform_,
48  const VariablesRenamingChangesetNode &variablesRenamingChangesetRoot_,
49  const std::unordered_set<gd::String> &removedVariableNames_,
50  const gd::String &targetGroupName_)
51  : platform(platform_),
52  variablesRenamingChangesetRoot(variablesRenamingChangesetRoot_),
53  removedVariableNames(removedVariableNames_),
54  targetVariablesContainer(nullVariablesContainer),
55  targetGroupName(targetGroupName_) {};
56  virtual ~EventsVariableReplacer();
57 
58  private:
59  bool DoVisitInstruction(gd::Instruction &instruction,
60  bool isCondition) override;
61  bool DoVisitEventExpression(gd::Expression &expression,
62  const gd::ParameterMetadata &metadata) override;
63 
64  const gd::VariablesContainer *FindForcedVariablesContainerIfAny(
65  const gd::String &type, const gd::String &lastObjectName);
66 
67  const gd::Platform &platform;
68  const gd::VariablesContainer &targetVariablesContainer;
74  const gd::String targetGroupName;
75  const VariablesRenamingChangesetNode &variablesRenamingChangesetRoot;
76  const std::unordered_set<gd::String> &removedVariableNames;
77 
78  static VariablesContainer nullVariablesContainer;
79 };
80 
81 } // namespace gd
An events worker that will know about the context (the objects container). Useful for workers working...
Definition: ArbitraryEventsWorker.h:136
Replace in expressions and in parameters of actions or conditions, references to the name of a variab...
Definition: EventsVariableReplacer.h:34
Class representing an expression used as a parameter of a gd::Instruction. This class is nothing more...
Definition: Expression.h:30
An instruction is a member of an event: It can be a condition or an action.
Definition: Instruction.h:30
Describe a parameter of an instruction (action, condition) or of an expression: type,...
Definition: ParameterMetadata.h:27
Base class for implementing a platform.
Definition: Platform.h:42
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
Definition: WholeProjectRefactorer.h:40