Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Olympe::Operand Struct Reference

One side of a ConditionPreset comparison expression. More...

#include <Operand.h>

Public Member Functions

 Operand ()
 Default: Variable mode, empty string.
 
std::string GetDisplayString () const
 Returns a human-readable display string.
 
bool IsPin () const
 Returns true when mode == Pin.
 
bool IsVariable () const
 Returns true when mode == Variable.
 
bool IsConst () const
 Returns true when mode == Const.
 
nlohmann::json ToJson () const
 Serializes this Operand to a JSON object.
 

Static Public Member Functions

static Operand CreateVariable (const std::string &variableID)
 Factory — creates a Variable-mode operand.
 
static Operand CreateConst (double constVal)
 Factory — creates a Const-mode operand.
 
static Operand CreatePin (const std::string &pinLabel)
 Factory — creates a Pin-mode operand.
 
static Operand FromJson (const nlohmann::json &data)
 Deserializes an Operand from a JSON object.
 

Public Attributes

OperandMode mode
 Discriminator tag.
 
std::string stringValue
 Variable ID or Pin label (mode == Variable|Pin)
 
double constValue
 Literal constant (mode == Const)
 

Detailed Description

One side of a ConditionPreset comparison expression.

Only one of stringValue / constValue is meaningful depending on mode:

Definition at line 45 of file Operand.h.

Constructor & Destructor Documentation

◆ Operand()

Olympe::Operand::Operand ( )

Default: Variable mode, empty string.

Definition at line 21 of file Operand.cpp.

Member Function Documentation

◆ CreateConst()

Operand Olympe::Operand::CreateConst ( double  constVal)
static

◆ CreatePin()

Operand Olympe::Operand::CreatePin ( const std::string &  pinLabel)
static

Factory — creates a Pin-mode operand.

Parameters
pinLabelPin label shown in the UI (e.g. "Pin:1").

Definition at line 53 of file Operand.cpp.

References constValue, GetComponentTypeID_Static(), mode, Olympe::Pin, and stringValue.

Referenced by Olympe::ConditionPresetEditDialog::RenderOperandSelector(), Olympe::ConditionPresetEditDialog::SetLeftMode(), Olympe::ConditionPresetEditDialog::SetLeftPin(), Olympe::ConditionPresetEditDialog::SetRightMode(), and Olympe::ConditionPresetEditDialog::SetRightPin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateVariable()

Operand Olympe::Operand::CreateVariable ( const std::string &  variableID)
static

◆ FromJson()

Operand Olympe::Operand::FromJson ( const nlohmann::json data)
static

Deserializes an Operand from a JSON object.

Parameters
dataJSON object (must contain "mode" and "value" keys).

Definition at line 149 of file Operand.cpp.

References Olympe::Const, constValue, GetComponentTypeID_Static(), mode, Olympe::Pin, stringValue, and Olympe::Variable.

Referenced by Olympe::ConditionPreset::FromJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDisplayString()

std::string Olympe::Operand::GetDisplayString ( ) const

Returns a human-readable display string.

Examples: "[mHealth]", "[2]", "[Pin:1]"

Definition at line 66 of file Operand.cpp.

References Olympe::Const, constValue, GetComponentTypeID_Static(), mode, Olympe::Pin, stringValue, and Olympe::Variable.

Referenced by Olympe::ConditionPreset::GetPreview().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsConst()

bool Olympe::Operand::IsConst ( ) const

Returns true when mode == Const.

Definition at line 114 of file Operand.cpp.

References Olympe::Const, and mode.

◆ IsPin()

bool Olympe::Operand::IsPin ( ) const

Returns true when mode == Pin.

Definition at line 104 of file Operand.cpp.

References mode, and Olympe::Pin.

Referenced by Olympe::ConditionPreset::GetPinNeeds(), Olympe::ConditionPreset::NeedsLeftPin(), and Olympe::ConditionPreset::NeedsRightPin().

+ Here is the caller graph for this function:

◆ IsVariable()

bool Olympe::Operand::IsVariable ( ) const

Returns true when mode == Variable.

Definition at line 109 of file Operand.cpp.

References mode, and Olympe::Variable.

◆ ToJson()

nlohmann::json Olympe::Operand::ToJson ( ) const

Serializes this Operand to a JSON object.

Definition at line 123 of file Operand.cpp.

References Olympe::Const, constValue, GetComponentTypeID_Static(), mode, Olympe::Pin, stringValue, and Olympe::Variable.

Referenced by Olympe::ConditionPreset::ToJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ constValue

double Olympe::Operand::constValue

Literal constant (mode == Const)

Definition at line 48 of file Operand.h.

Referenced by CreateConst(), CreatePin(), CreateVariable(), FromJson(), GetDisplayString(), and ToJson().

◆ mode

OperandMode Olympe::Operand::mode

Discriminator tag.

Definition at line 46 of file Operand.h.

Referenced by CreateConst(), CreatePin(), CreateVariable(), FromJson(), GetDisplayString(), IsConst(), IsPin(), IsVariable(), and ToJson().

◆ stringValue

std::string Olympe::Operand::stringValue

Variable ID or Pin label (mode == Variable|Pin)

Definition at line 47 of file Operand.h.

Referenced by Olympe::NodeConditionsPanel::AddCondition(), CreateConst(), CreatePin(), CreateVariable(), FromJson(), GetDisplayString(), and ToJson().


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