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

A list of events. More...

#include <EventsList.h>

Public Member Functions

 EventsList (const EventsList &)
 
EventsListoperator= (const EventsList &rhs)
 
gd::BaseEventInsertEvent (const gd::BaseEvent &event, size_t position=(size_t) -1)
 Insert the specified event to the list. More...
 
void InsertEvent (std::shared_ptr< gd::BaseEvent > event, size_t position=(size_t) -1)
 Insert the specified event to the list. More...
 
gd::BaseEventInsertNewEvent (gd::Project &project, const gd::String &eventType, size_t position=(size_t) -1)
 Insert a new event to the list. More...
 
void InsertEvents (const EventsList &otherEvents, size_t begin, size_t end, size_t position=(size_t) -1)
 Copy events from another list.
 
size_t GetEventsCount () const
 Return the number of events.
 
std::shared_ptr< BaseEventGetEventSmartPtr (size_t index)
 Return the smart pointer to the event at position index in the events list.
 
std::shared_ptr< const BaseEventGetEventSmartPtr (size_t index) const
 Return the smart pointer to the event at position index in the events list.
 
gd::BaseEventGetEvent (size_t index)
 Return a reference to the event at position index in the events list.
 
const gd::BaseEventGetEvent (size_t index) const
 Return a reference to the event at position index in the events list.
 
void RemoveEvent (const gd::BaseEvent &event)
 Remove the specified event.
 
void RemoveEvent (size_t index)
 Remove the event at the specified index in the list.
 
bool IsEmpty () const
 Return true if there isn't any event in the list.
 
void Clear ()
 Clear the list of events.
 
Utilities

Utility methods

bool Contains (const gd::BaseEvent &eventToSearch, bool recursive=true) const
 
bool MoveEventToAnotherEventsList (const gd::BaseEvent &eventToMove, gd::EventsList &newEventsList, std::size_t newPosition)
 
std::vector API compatibility

These functions ensure that the class can be used just like a std::vector.

size_t size () const
 Alias for GetEventsCount() More...
 
gd::BaseEventoperator[] (size_t index)
 Alias for GetEvent() More...
 
const gd::BaseEventoperator[] (size_t index) const
 Alias for GetEvent() More...
 
Saving and loading

Members functions related to saving and loading the events list.

void SerializeTo (SerializerElement &element) const
 Serialize the events to the specified element. More...
 
void UnserializeFrom (gd::Project &project, const SerializerElement &element)
 Load the events from the specified element. More...
 

Detailed Description

A list of events.

See also
BaseEvent

Member Function Documentation

◆ Contains()

bool gd::EventsList::Contains ( const gd::BaseEvent eventToSearch,
bool  recursive = true 
) const

Return true if the specified event exists in the list.

Parameters
eventThe event to searched for
recursiveSet it to false to prevent sub events to be inspected.

◆ InsertEvent() [1/2]

gd::BaseEvent & gd::EventsList::InsertEvent ( const gd::BaseEvent event,
size_t  position = (size_t)-1 
)

Insert the specified event to the list.

Note
The event passed by parameter is copied.
Parameters
eventThe event that must be copied and inserted into the list
positionInsertion position. If the position is invalid, the object is inserted at the end of the objects list.
Returns
A reference to the event in the list

◆ InsertEvent() [2/2]

void gd::EventsList::InsertEvent ( std::shared_ptr< gd::BaseEvent event,
size_t  position = (size_t)-1 
)

Insert the specified event to the list.

Note
The event passed by parameter is not copied.
Parameters
eventThe smart pointer to the event that must be inserted into the list
positionInsertion position. If the position is invalid, the object is inserted at the end of the objects list.

◆ InsertNewEvent()

gd::BaseEvent & gd::EventsList::InsertNewEvent ( gd::Project project,
const gd::String eventType,
size_t  position = (size_t)-1 
)

Insert a new event to the list.

Note
The event is created using the project current platform.
Parameters
projectThe project the events list belongs to.
eventTypeThe type of the event
positionInsertion position. If the position is invalid, the object is inserted at the end of the objects list.

◆ MoveEventToAnotherEventsList()

bool gd::EventsList::MoveEventToAnotherEventsList ( const gd::BaseEvent eventToMove,
gd::EventsList newEventsList,
std::size_t  newPosition 
)

Move the specified event, that must be in the events list, to another events list without invalidating the event (i.e: without destroying/cloning it) in memory.

Warning
newEventsList is supposed not to be contained inside the event (you should not try to move an event inside one of its children/grand children events).
Parameters
eventToMoveThe event to be moved
newEventsListThe new events list
newPositionThe position in the new events list
Returns
true if the move was made, false otherwise (for example, if eventToMove is not found in the list)

◆ operator[]() [1/2]

gd::BaseEvent& gd::EventsList::operator[] ( size_t  index)
inline

Alias for GetEvent()

See also
EventsList::GetEvent.

◆ operator[]() [2/2]

const gd::BaseEvent& gd::EventsList::operator[] ( size_t  index) const
inline

Alias for GetEvent()

See also
EventsList::GetEvent.

◆ SerializeTo()

void gd::EventsList::SerializeTo ( SerializerElement element) const

Serialize the events to the specified element.

See also
EventsListSerialization

◆ size()

size_t gd::EventsList::size ( ) const
inline

◆ UnserializeFrom()

void gd::EventsList::UnserializeFrom ( gd::Project project,
const SerializerElement element 
)

Load the events from the specified element.

See also
EventsListSerialization

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