GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Public Member Functions | Public Attributes | List of all members

Base class defining an event. More...

#include <Event.h>

Inherited by gd::AsyncEvent, gd::CommentEvent, gd::EmptyEvent, gd::ForEachChildVariableEvent, gd::ForEachEvent, gd::GroupEvent, gd::LinkEvent, gd::RepeatEvent, gd::StandardEvent, and gd::WhileEvent.

Public Member Functions

virtual gd::BaseEventClone () const
 
Event properties

Members functions to be overridden by derived classes to expose the event properties

virtual bool IsExecutable () const
 
virtual bool CanHaveSubEvents () const
 
virtual const gd::EventsListGetSubEvents () const
 
virtual gd::EventsListGetSubEvents ()
 
bool HasSubEvents () const
 Return true if the events has sub events. More...
 
virtual std::vector< gd::InstructionsList * > GetAllConditionsVectors ()
 Return a list of all conditions of the event. More...
 
virtual std::vector< const gd::InstructionsList * > GetAllConditionsVectors () const
 
virtual std::vector< gd::InstructionsList * > GetAllActionsVectors ()
 Return a list of all actions of the event. More...
 
virtual std::vector< const gd::InstructionsList * > GetAllActionsVectors () const
 
virtual std::vector< gd::StringGetAllSearchableStrings () const
 Return a list of all strings of the event. More...
 
virtual bool ReplaceAllSearchableStrings (std::vector< gd::String > newSearchableString)
 
virtual std::vector< std::pair< gd::Expression *, gd::ParameterMetadata > > GetAllExpressionsWithMetadata ()
 Return a list of all expressions of the event, each with their associated metadata. More...
 
virtual std::vector< std::pair< const gd::Expression *, const gd::ParameterMetadata > > GetAllExpressionsWithMetadata () const
 
virtual const std::vector< gd::String > & GetSourceFileDependencies () const
 Returns the dependencies on source files of the project. More...
 
virtual const gd::StringGetAssociatedGDManagedSourceFile (gd::Project &project) const
 Returns the name of the source file associated with the event. More...
 
Code generation

Members functions used to generate code from the event

virtual gd::String GenerateEventCode (gd::EventsCodeGenerator &codeGenerator, gd::EventsCodeGenerationContext &context)
 Generate the code event: the platform provided by codeGenerator is asked for the EventMetadata associated to the event, which is then used to generate the code event. More...
 
virtual void Preprocess (gd::EventsCodeGenerator &codeGenerator, gd::EventsList &eventList, std::size_t indexOfTheEventInThisList)
 
void PreprocessAsyncActions (const gd::Platform &platform)
 
virtual bool MustBePreprocessed ()
 If MustBePreprocessed is redefined to return true, the gd::EventMetadata::preprocessing associated to the event will be called to preprocess the event. More...
 
Serialization
virtual void SerializeTo (SerializerElement &element) const
 Serialize event.
 
virtual void UnserializeFrom (gd::Project &project, const SerializerElement &element)
 Unserialize the event.
 
virtual bool AcceptVisitor (gd::EventVisitor &eventVisitor)
 
virtual void AcceptVisitor (gd::ReadOnlyEventVisitor &eventVisitor) const
 
Common properties

Common method shared by all events. ( No need for them to be overridden by derived classes ).

const gd::StringGetType () const
 Return the event type.
 
void SetType (gd::String type_)
 Change the event type.
 
void SetDisabled (bool disable=true)
 Set if the event if disabled or not.
 
bool IsDisabled () const
 True if event is disabled.
 
void SetFolded (bool fold=true)
 Set if the event must be folded (i.e: sub events must be hidden in the events editor).
 
bool IsFolded () const
 True if the event should be folded in the events editor.
 

Public Attributes

std::weak_ptr< gd::BaseEventoriginalEvent
 
signed long long totalTimeDuringLastSession
 
float percentDuringLastSession
 

Detailed Description

Base class defining an event.

Events are usually not instance of Base Event, but instance of a derived class.

Member Function Documentation

◆ CanHaveSubEvents()

virtual bool gd::BaseEvent::CanHaveSubEvents ( ) const
inlinevirtual

Derived class have to redefine this function, so as to return true, if they have sub events.

Reimplemented in gd::WhileEvent, gd::StandardEvent, gd::RepeatEvent, gd::GroupEvent, gd::ForEachEvent, gd::ForEachChildVariableEvent, and gd::AsyncEvent.

◆ Clone()

virtual gd::BaseEvent* gd::BaseEvent::Clone ( ) const
inlinevirtual

Must return a pointer to a copy of the event. A such method is needed as the IDE may want to store copies of some events and so need a way to do polymorphic copies.

Typical implementation example:

return new MyEventClass(*this);

Reimplemented in gd::LinkEvent, gd::WhileEvent, gd::StandardEvent, gd::RepeatEvent, gd::GroupEvent, gd::ForEachEvent, gd::ForEachChildVariableEvent, gd::CommentEvent, and gd::AsyncEvent.

◆ GenerateEventCode()

gd::String gd::BaseEvent::GenerateEventCode ( gd::EventsCodeGenerator codeGenerator,
gd::EventsCodeGenerationContext context 
)
virtual

Generate the code event: the platform provided by codeGenerator is asked for the EventMetadata associated to the event, which is then used to generate the code event.

Warning
Even if this method is virtual, you should never redefine it: always provide the code generation using gd::EventMetadata. This method is virtual as some platforms could have hidden events (such as profiling events) needing code generation without declaring the event as a part of an extension.
See also
gd::EventMetadata

◆ GetAllActionsVectors()

virtual std::vector<gd::InstructionsList*> gd::BaseEvent::GetAllActionsVectors ( )
inlinevirtual

Return a list of all actions of the event.

Note
Used to preprocess or search in the actions.

Reimplemented in gd::WhileEvent, gd::StandardEvent, gd::RepeatEvent, gd::ForEachEvent, gd::ForEachChildVariableEvent, and gd::AsyncEvent.

◆ GetAllConditionsVectors()

virtual std::vector<gd::InstructionsList*> gd::BaseEvent::GetAllConditionsVectors ( )
inlinevirtual

Return a list of all conditions of the event.

Note
Used to preprocess or search in the conditions.

Reimplemented in gd::WhileEvent, gd::StandardEvent, gd::RepeatEvent, gd::ForEachEvent, and gd::ForEachChildVariableEvent.

◆ GetAllExpressionsWithMetadata()

virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> > gd::BaseEvent::GetAllExpressionsWithMetadata ( )
inlinevirtual

Return a list of all expressions of the event, each with their associated metadata.

Note
Used to preprocess or search in the expressions of the event.

Reimplemented in gd::RepeatEvent, gd::ForEachEvent, and gd::ForEachChildVariableEvent.

◆ GetAllSearchableStrings()

virtual std::vector<gd::String> gd::BaseEvent::GetAllSearchableStrings ( ) const
inlinevirtual

Return a list of all strings of the event.

Note
Used to preprocess or search in the event strings.

Reimplemented in gd::GroupEvent, and gd::CommentEvent.

◆ GetAssociatedGDManagedSourceFile()

virtual const gd::String& gd::BaseEvent::GetAssociatedGDManagedSourceFile ( gd::Project project) const
inlinevirtual

Returns the name of the source file associated with the event.

Note
Default implementation returns an empty string. This is fine for most events that are not related to adding custom user source code.

◆ GetSourceFileDependencies()

virtual const std::vector<gd::String>& gd::BaseEvent::GetSourceFileDependencies ( ) const
inlinevirtual

Returns the dependencies on source files of the project.

Note
Default implementation returns an empty list of dependencies. This is fine for most events that are not related to adding custom user source code.

◆ GetSubEvents() [1/2]

virtual gd::EventsList& gd::BaseEvent::GetSubEvents ( )
inlinevirtual

◆ GetSubEvents() [2/2]

virtual const gd::EventsList& gd::BaseEvent::GetSubEvents ( ) const
inlinevirtual

◆ HasSubEvents()

bool gd::BaseEvent::HasSubEvents ( ) const

Return true if the events has sub events.

Warning
This is only applicable when CanHaveSubEvents() return true.

◆ IsExecutable()

virtual bool gd::BaseEvent::IsExecutable ( ) const
inlinevirtual

Derived class have to redefine this function, so as to return true, if they are executable.

Reimplemented in gd::LinkEvent, gd::WhileEvent, gd::StandardEvent, gd::RepeatEvent, gd::GroupEvent, gd::ForEachEvent, gd::ForEachChildVariableEvent, and gd::AsyncEvent.

◆ MustBePreprocessed()

virtual bool gd::BaseEvent::MustBePreprocessed ( )
inlinevirtual

If MustBePreprocessed is redefined to return true, the gd::EventMetadata::preprocessing associated to the event will be called to preprocess the event.

See also
gd::BaseEvent::Preprocess
gd::EventMetadata

Reimplemented in gd::LinkEvent.

◆ Preprocess()

void gd::BaseEvent::Preprocess ( gd::EventsCodeGenerator codeGenerator,
gd::EventsList eventList,
std::size_t  indexOfTheEventInThisList 
)
virtual

Called before events are compiled: the platform provided by codeGenerator is asked for the EventMetadata associated to the event, which is then used to preprocess the event.

This is only done if the event MustBePreprocessed() return true.

Warning
Be careful if you're iterating over a list of event, a call to Preprocess can remove the event from the list!
See also
gd::EventMetadata
gd::BaseEvent::MustBePreprocessed

◆ PreprocessAsyncActions()

void gd::BaseEvent::PreprocessAsyncActions ( const gd::Platform platform)

A function that turns all async member actions into an Async subevent for code generation.

Member Data Documentation

◆ originalEvent

std::weak_ptr<gd::BaseEvent> gd::BaseEvent::originalEvent

Pointer only used for profiling events, so as to remember the original event from which it has been copied.

◆ percentDuringLastSession

float gd::BaseEvent::percentDuringLastSession

Total time used by the event during the last run. Used for profiling.

◆ totalTimeDuringLastSession

signed long long gd::BaseEvent::totalTimeDuringLastSession

Total time, in microseconds, used by the event during the last run. Used for profiling.


The documentation for this class was generated from the following files: