GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
EventsContextAnalyzer.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 #ifndef EventsContextAnalyzer_H
7 #define EventsContextAnalyzer_H
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <vector>
12 #include "GDCore/IDE/Events/ArbitraryEventsWorker.h"
13 #include "GDCore/String.h"
14 namespace gd {
15 class BaseEvent;
16 class Platform;
17 class ObjectsContainer;
18 class ObjectsContainersList;
19 class Project;
20 class Layout;
21 class EventsList;
22 class ParameterMetadata;
23 class Expression;
24 } // namespace gd
25 
26 namespace gd {
27 
31 class GD_CORE_API EventsContext {
32  public:
33  EventsContext(){};
34  virtual ~EventsContext(){};
35 
36  void AddObjectName(const gd::ProjectScopedContainers& projectScopedContainers,
37  const gd::String& objectOrGroupName);
38  void AddBehaviorName(const gd::ProjectScopedContainers& projectScopedContainers,
39  const gd::String& objectOrGroupName,
40  const gd::String& behaviorName);
41 
45  const std::set<gd::String>& GetReferencedObjectOrGroupNames() {
46  return referencedObjectOrGroupNames;
47  }
48 
53  const std::set<gd::String>& GetObjectNames() { return objectNames; }
54 
59  const std::set<gd::String>& GetBehaviorNamesOfObjectOrGroup(const gd::String& objectOrGroupName) {
60  return objectOrGroupBehaviorNames[objectOrGroupName];
61  }
62 
63  private:
64  std::set<gd::String> referencedObjectOrGroupNames;
65  std::set<gd::String> objectNames;
66  std::map<gd::String, std::set<gd::String>> objectOrGroupBehaviorNames;
67 };
68 
75  public:
76  EventsContextAnalyzer(const gd::Platform& platform_)
77  : platform(platform_) {};
78  virtual ~EventsContextAnalyzer(){};
79 
83  const EventsContext& GetEventsContext() { return context; }
84 
85  static void AnalyzeParameter(const gd::Platform& platform,
86  const gd::ProjectScopedContainers& projectScopedContainers,
87  const gd::ParameterMetadata& metadata,
88  const gd::Expression& parameter,
89  EventsContext& context,
90  const gd::String& lastObjectName);
91 
92  private:
93  virtual bool DoVisitInstruction(gd::Instruction& instruction,
94  bool isCondition);
95 
96  const gd::Platform& platform;
97  EventsContext context;
98 };
99 
100 } // namespace gd
101 
102 #endif // EventsContextAnalyzer_H
An events worker that will know about the context (the objects container). Useful for workers working...
Definition: ArbitraryEventsWorker.h:113
Analyze events to list all the objects being used in them.
Definition: EventsContextAnalyzer.h:74
const EventsContext & GetEventsContext()
Definition: EventsContextAnalyzer.h:83
Store the results of a search done by EventsContextAnalyzer.
Definition: EventsContextAnalyzer.h:31
const std::set< gd::String > & GetObjectNames()
Get objects referenced in the events, without groups (all groups have been "expanded" to the real obj...
Definition: EventsContextAnalyzer.h:53
const std::set< gd::String > & GetReferencedObjectOrGroupNames()
Get object or group names being referenced in the events.
Definition: EventsContextAnalyzer.h:45
const std::set< gd::String > & GetBehaviorNamesOfObjectOrGroup(const gd::String &objectOrGroupName)
Get behaviors referenced in the events for the given object (or group) name.
Definition: EventsContextAnalyzer.h:59
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
Holds references to variables, objects, properties and other containers.
Definition: ProjectScopedContainers.h:30
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24