GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
EventMetadata.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 #if defined(GD_IDE_ONLY)
8 #ifndef EVENTMETADATA_H
9 #define EVENTMETADATA_H
10 #include <functional>
11 #include <memory>
12 #include <vector>
13 #include "GDCore/String.h"
14 namespace gd {
15 class EventsList;
16 class BaseEvent;
17 class EventsCodeGenerator;
18 class EventsCodeGenerationContext;
19 }
20 
21 namespace gd {
22 
29 class GD_CORE_API EventMetadata {
30  public:
35  std::function<gd::String(gd::BaseEvent& event,
36  gd::EventsCodeGenerator& codeGenerator,
38  function) {
39  hasCustomCodeGenerator = true;
40  codeGeneration = function;
41  return *this;
42  }
43 
48  std::function<void(gd::BaseEvent& event,
49  gd::EventsCodeGenerator& codeGenerator,
50  gd::EventsList& eventList,
51  std::size_t indexOfTheEventInThisList)> function) {
52  preprocessing = function;
53  return *this;
54  }
55 
59  void ClearCodeGenerationAndPreprocessing();
60 
65  bool HasCustomCodeGenerator() const { return hasCustomCodeGenerator; }
66 
67  EventMetadata(const gd::String& name_,
68  const gd::String& fullname_,
69  const gd::String& description_,
70  const gd::String& group_,
71  const gd::String& smallicon_,
72  std::shared_ptr<gd::BaseEvent> instance);
73 
74  EventMetadata(){};
75  virtual ~EventMetadata(){};
76 
77  const gd::String& GetFullName() const { return fullname; }
78  const gd::String& GetDescription() const { return description; }
79  const gd::String& GetGroup() const { return group; }
80 
81  gd::String fullname;
82  gd::String description;
83  gd::String group;
84 
85  std::shared_ptr<gd::BaseEvent> instance;
86  bool hasCustomCodeGenerator = false;
87  std::function<gd::String(gd::BaseEvent& event,
88  gd::EventsCodeGenerator& codeGenerator,
90  codeGeneration;
91  std::function<void(gd::BaseEvent& event,
92  gd::EventsCodeGenerator& codeGenerator,
93  gd::EventsList& eventList,
94  std::size_t indexOfTheEventInThisList)>
95  preprocessing;
96 };
97 
98 } // namespace gd
99 
100 #endif // EVENTMETADATA_H
101 #endif
Base class defining an event.
Definition: Event.h:43
Describe an event provided by an extension of a platform.
Definition: EventMetadata.h:29
bool HasCustomCodeGenerator() const
Return true if SetCodeGenerator was called to set a function to call to generate the event code.
Definition: EventMetadata.h:65
EventMetadata & SetCodeGenerator(std::function< gd::String(gd::BaseEvent &event, gd::EventsCodeGenerator &codeGenerator, gd::EventsCodeGenerationContext &context)> function)
Set the code generator used when generating code from events.
Definition: EventMetadata.h:34
EventMetadata & SetPreprocessing(std::function< void(gd::BaseEvent &event, gd::EventsCodeGenerator &codeGenerator, gd::EventsList &eventList, std::size_t indexOfTheEventInThisList)> function)
Set the code to preprocess the event.
Definition: EventMetadata.h:47
Used to manage the context when generating code for events.
Definition: EventsCodeGenerationContext.h:27
Internal class used to generate code from events.
Definition: EventsCodeGenerator.h:41
A list of events.
Definition: EventsList.h:32
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24