GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
AbstractEventsBasedEntity.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 GDCORE_ABSTRACTEVENTSBASEDENTITY_H
7 #define GDCORE_ABSTRACTEVENTSBASEDENTITY_H
8 
9 #include <vector>
10 #include "GDCore/Project/NamedPropertyDescriptor.h"
11 #include "GDCore/Project/PropertiesContainer.h"
12 #include "GDCore/Project/EventsFunctionsContainer.h"
13 #include "GDCore/String.h"
14 namespace gd {
15 class SerializerElement;
16 class Project;
17 } // namespace gd
18 
19 namespace gd {
20 
30 class GD_CORE_API AbstractEventsBasedEntity {
31  public:
33  const gd::String& _name,
34  gd::EventsFunctionsContainer::FunctionOwner functionContainerSource);
35  virtual ~AbstractEventsBasedEntity(){};
36 
42 
47  const gd::String& GetDescription() const { return description; };
48 
52  virtual AbstractEventsBasedEntity& SetDescription(const gd::String& description_) {
53  description = description_;
54  return *this;
55  }
56 
60  const gd::String& GetName() const { return name; };
61 
66  name = name_;
67  return *this;
68  }
69 
73  const gd::String& GetFullName() const { return fullName; };
74 
79  fullName = fullName_;
80  return *this;
81  }
82 
87  return eventsFunctionsContainer;
88  }
89 
95  return eventsFunctionsContainer;
96  }
97 
102  return propertyDescriptors;
103  }
104 
109  return propertyDescriptors;
110  }
111 
115  static gd::String GetPropertyActionName(const gd::String& propertyName) { return "SetProperty" + propertyName; };
116 
120  static gd::String GetPropertyConditionName(const gd::String& propertyName) { return "Property" + propertyName; };
121 
125  static gd::String GetPropertyExpressionName(const gd::String& propertyName) { return "Property" + propertyName; };
126 
130  static gd::String GetPropertyToggleActionName(const gd::String& propertyName) { return "ToggleProperty" + propertyName; };
131 
135 
138  virtual void SerializeTo(gd::SerializerElement& element) const;
139 
143  virtual void UnserializeFrom(gd::Project& project,
144  const gd::SerializerElement& element);
146 
147  private:
148  gd::String name;
149  gd::String fullName;
150  gd::String description;
151  gd::EventsFunctionsContainer eventsFunctionsContainer;
152  gd::PropertiesContainer propertyDescriptors;
153  gd::String extensionName;
154 };
155 
156 } // namespace gd
157 
158 #endif // GDCORE_ABSTRACTEVENTSBASEDENTITY_H
Represents a behavior or an object that is implemented with events.
Definition: AbstractEventsBasedEntity.h:30
static gd::String GetPropertyToggleActionName(const gd::String &propertyName)
Get the name of the action to toggle a boolean property.
Definition: AbstractEventsBasedEntity.h:130
static gd::String GetPropertyExpressionName(const gd::String &propertyName)
Get the name of the expression to get a property.
Definition: AbstractEventsBasedEntity.h:125
virtual AbstractEventsBasedEntity & SetDescription(const gd::String &description_)
Set the description of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:52
const gd::PropertiesContainer & GetPropertyDescriptors() const
Return a const reference to the list of the properties.
Definition: AbstractEventsBasedEntity.h:108
static gd::String GetPropertyActionName(const gd::String &propertyName)
Get the name of the action to change a property.
Definition: AbstractEventsBasedEntity.h:115
static gd::String GetPropertyConditionName(const gd::String &propertyName)
Get the name of the condition to compare a property.
Definition: AbstractEventsBasedEntity.h:120
gd::PropertiesContainer & GetPropertyDescriptors()
Return a reference to the list of the properties.
Definition: AbstractEventsBasedEntity.h:101
AbstractEventsBasedEntity * Clone() const
Return a pointer to a new AbstractEventsBasedEntity constructed from this one.
Definition: AbstractEventsBasedEntity.h:41
const gd::String & GetFullName() const
Get the name of the behavior or object, that is displayed in the editor.
Definition: AbstractEventsBasedEntity.h:73
const EventsFunctionsContainer & GetEventsFunctions() const
Return a const reference to the functions of the events based behavior or object.
Definition: AbstractEventsBasedEntity.h:94
AbstractEventsBasedEntity & SetName(const gd::String &name_)
Set the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:65
EventsFunctionsContainer & GetEventsFunctions()
Return a reference to the functions of the events based behavior or object.
Definition: AbstractEventsBasedEntity.h:86
const gd::String & GetDescription() const
Get the description of the behavior or object, that is displayed in the editor.
Definition: AbstractEventsBasedEntity.h:47
AbstractEventsBasedEntity & SetFullName(const gd::String &fullName_)
Set the name of the behavior or object, to be displayed in the editor.
Definition: AbstractEventsBasedEntity.h:78
const gd::String & GetName() const
Get the internal name of the behavior or object.
Definition: AbstractEventsBasedEntity.h:60
Used as a base class for classes that will own events-backed functions.
Definition: EventsFunctionsContainer.h:27
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
A container of properties, used for custom behaviors, custom objects, extensions.....
Definition: PropertiesContainer.h:17
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24