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

An instruction is a member of an event: It can be a condition or an action. More...

#include <Instruction.h>

Public Member Functions

 Instruction (gd::String type_="")
 Default constructor. More...
 
 Instruction (gd::String type_, const std::vector< gd::Expression > &parameters_, bool inverted=false)
 Constructor. More...
 
const gd::StringGetType () const
 Return the type of the instruction. More...
 
void SetType (const gd::String &newType)
 Change the instruction type. More...
 
bool IsInverted () const
 Return true if the condition is inverted. More...
 
void SetInverted (bool inverted_)
 Set if the instruction is inverted or not. More...
 
bool IsAwaited () const
 Return true if the async instruction should be awaited. This is not relevant if the instruction is not optionally asynchronous. More...
 
void SetAwaited (bool awaited)
 Set if the async instruction is to be awaited or not. This is not relevant if the instruction is not optionally asynchronous. More...
 
std::size_t GetParametersCount () const
 Return the number of parameters of the instruction.
 
void SetParametersCount (std::size_t size)
 Change the number of parameter of the instruction. More...
 
const gd::ExpressionGetParameter (std::size_t index) const
 Get the value of a parameter. More...
 
gd::ExpressionGetParameter (std::size_t index)
 Get the value of a parameter. More...
 
void SetParameter (std::size_t nb, const gd::Expression &val)
 
void AddParameter (const gd::Expression &val)
 
const std::vector< gd::Expression > & GetParameters () const
 Get a reference to the std::vector containing the parameters. More...
 
void SetParameters (const std::vector< gd::Expression > &val)
 Replace all the parameters by new ones. More...
 
const gd::InstructionsListGetSubInstructions () const
 Return a reference to the vector containing sub instructions.
 
gd::InstructionsListGetSubInstructions ()
 Return a reference to the vector containing sub instructions.
 
std::weak_ptr< InstructionGetOriginalInstruction ()
 Return the original instruction this instruction was copied from. More...
 

Friends

std::shared_ptr< InstructionCloneRememberingOriginalElement (std::shared_ptr< Instruction > instruction)
 

Detailed Description

An instruction is a member of an event: It can be a condition or an action.

An instruction has a type, which define what it does, and some parameters. It can also be set as inverted (when the instruction is a condition) and it can have sub instructions. This class does nothing particular except storing these data.

See also
gd::BaseEvent

Constructor & Destructor Documentation

◆ Instruction() [1/2]

gd::Instruction::Instruction ( gd::String  type_ = "")

Default constructor.

Parameters
typeThe type of the instruction

◆ Instruction() [2/2]

gd::Instruction::Instruction ( gd::String  type_,
const std::vector< gd::Expression > &  parameters_,
bool  inverted = false 
)

Constructor.

Parameters
typeThe type of the instruction
parametersA vector containing the parameters of the instruction
invertedtrue to set the instruction as inverted (used for condition instructions).

Member Function Documentation

◆ AddParameter()

void gd::Instruction::AddParameter ( const gd::Expression val)

Add a parameter at the end

Parameters
valThe new value of the parameter

◆ GetOriginalInstruction()

std::weak_ptr<Instruction> gd::Instruction::GetOriginalInstruction ( )
inline

Return the original instruction this instruction was copied from.

Useful to get reference to the original instruction in memory during code generation, to ensure stable unique identifiers.

◆ GetParameter() [1/2]

gd::Expression & gd::Instruction::GetParameter ( std::size_t  index)

Get the value of a parameter.

Return an empty expression if the parameter requested does not exists.

Returns
The current value of the parameter.

◆ GetParameter() [2/2]

const gd::Expression & gd::Instruction::GetParameter ( std::size_t  index) const

Get the value of a parameter.

Return an empty expression if the parameter requested does not exists.

Returns
The current value of the parameter.

◆ GetParameters()

const std::vector<gd::Expression>& gd::Instruction::GetParameters ( ) const
inline

Get a reference to the std::vector containing the parameters.

Returns
A std::vector containing the parameters

◆ GetType()

const gd::String& gd::Instruction::GetType ( ) const
inline

Return the type of the instruction.

Returns
The type of the instruction

◆ IsAwaited()

bool gd::Instruction::IsAwaited ( ) const
inline

Return true if the async instruction should be awaited. This is not relevant if the instruction is not optionally asynchronous.

Returns
true if the instruction is to be awaited

◆ IsInverted()

bool gd::Instruction::IsInverted ( ) const
inline

Return true if the condition is inverted.

Returns
true if the condition is inverted

◆ SetAwaited()

void gd::Instruction::SetAwaited ( bool  awaited)
inline

Set if the async instruction is to be awaited or not. This is not relevant if the instruction is not optionally asynchronous.

Parameters
invertedtrue if the instruction must be awaited

◆ SetInverted()

void gd::Instruction::SetInverted ( bool  inverted_)
inline

Set if the instruction is inverted or not.

Parameters
invertedtrue if the condition must be set as inverted

◆ SetParameter()

void gd::Instruction::SetParameter ( std::size_t  nb,
const gd::Expression val 
)

Change the specified parameter

Parameters
nbThe parameter number
valThe new value of the parameter

◆ SetParameters()

void gd::Instruction::SetParameters ( const std::vector< gd::Expression > &  val)
inline

Replace all the parameters by new ones.

Parameters
valA vector containing the new parameters.

◆ SetParametersCount()

void gd::Instruction::SetParametersCount ( std::size_t  size)

Change the number of parameter of the instruction.

If the new size if larger than the previous, new blank parameters are added.

◆ SetType()

void gd::Instruction::SetType ( const gd::String newType)
inline

Change the instruction type.

Parameters
valThe new type of the instruction

Friends And Related Function Documentation

◆ CloneRememberingOriginalElement

std::shared_ptr<Instruction> CloneRememberingOriginalElement ( std::shared_ptr< Instruction instruction)
friend

Clone the given instruction, returning an instruction for which GetOriginalInstruction() returns the originally copied instruction.


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