Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
Olympe::TaskValue Class Reference

C++14-compliant type-safe value container for task parameters. More...

#include <TaskGraphTypes.h>

+ Collaboration diagram for Olympe::TaskValue:

Classes

union  PodData
 

Public Member Functions

 TaskValue ()
 Default constructor: creates a value of type VariableType::None.
 
 TaskValue (bool v)
 Construct from bool.
 
 TaskValue (int v)
 Construct from int.
 
 TaskValue (float v)
 Construct from float.
 
 TaskValue (const ::Vector &v)
 Construct from Vector.
 
 TaskValue (EntityID v)
 Construct from EntityID.
 
 TaskValue (const std::string &v)
 Construct from std::string.
 
bool AsBool () const
 Returns the bool value.
 
int AsInt () const
 Returns the int value.
 
float AsFloat () const
 Returns the float value.
 
::Vector AsVector () const
 Returns the Vector value.
 
EntityID AsEntityID () const
 Returns the EntityID value.
 
std::string AsString () const
 Returns the string value.
 
VariableType GetType () const
 Returns the VariableType tag of the stored value.
 
bool IsNone () const
 Returns true if the value has not been set (type == None).
 
std::string to_string () const
 Converts the stored value to a string representation.
 

Private Attributes

union Olympe::TaskValue::PodData m_data
 
::Vector m_vectorValue
 
std::string m_stringValue
 
VariableType m_type
 

Detailed Description

C++14-compliant type-safe value container for task parameters.

Stores one value of type: bool, int, float, Vector, EntityID, or std::string. POD types share a union; non-POD types (Vector, std::string) are stored as separate members.

Throws std::runtime_error on type mismatch when calling typed getters.

Definition at line 181 of file TaskGraphTypes.h.

Constructor & Destructor Documentation

◆ TaskValue() [1/7]

Olympe::TaskValue::TaskValue ( )

Default constructor: creates a value of type VariableType::None.

Definition at line 22 of file TaskGraphTypes.cpp.

References Olympe::TaskValue::PodData::entityValue, and m_data.

◆ TaskValue() [2/7]

Olympe::TaskValue::TaskValue ( bool  v)
explicit

Construct from bool.

Parameters
vBoolean value.

Definition at line 30 of file TaskGraphTypes.cpp.

References Olympe::TaskValue::PodData::boolValue, GetComponentTypeID_Static(), and m_data.

+ Here is the call graph for this function:

◆ TaskValue() [3/7]

Olympe::TaskValue::TaskValue ( int  v)
explicit

Construct from int.

Parameters
vInteger value.

Definition at line 38 of file TaskGraphTypes.cpp.

References GetComponentTypeID_Static(), Olympe::TaskValue::PodData::intValue, and m_data.

+ Here is the call graph for this function:

◆ TaskValue() [4/7]

Olympe::TaskValue::TaskValue ( float  v)
explicit

Construct from float.

Parameters
vFloat value.

Definition at line 46 of file TaskGraphTypes.cpp.

References Olympe::TaskValue::PodData::floatValue, GetComponentTypeID_Static(), and m_data.

+ Here is the call graph for this function:

◆ TaskValue() [5/7]

Olympe::TaskValue::TaskValue ( const ::Vector v)
explicit

Construct from Vector.

Parameters
vVector value (2D or 3D via z component).

Definition at line 54 of file TaskGraphTypes.cpp.

References Olympe::TaskValue::PodData::entityValue, and m_data.

◆ TaskValue() [6/7]

Olympe::TaskValue::TaskValue ( EntityID  v)
explicit

Construct from EntityID.

Parameters
vEntity identifier.

Definition at line 62 of file TaskGraphTypes.cpp.

References Olympe::TaskValue::PodData::entityValue, GetComponentTypeID_Static(), and m_data.

+ Here is the call graph for this function:

◆ TaskValue() [7/7]

Olympe::TaskValue::TaskValue ( const std::string &  v)
explicit

Construct from std::string.

Parameters
vString value.

Definition at line 70 of file TaskGraphTypes.cpp.

References Olympe::TaskValue::PodData::entityValue, and m_data.

Member Function Documentation

◆ AsBool()

bool Olympe::TaskValue::AsBool ( ) const

◆ AsEntityID()

EntityID Olympe::TaskValue::AsEntityID ( ) const

Returns the EntityID value.

Exceptions
std::runtime_errorif the stored type is not EntityID.

Definition at line 118 of file TaskGraphTypes.cpp.

References Olympe::EntityID, Olympe::TaskValue::PodData::entityValue, m_data, and m_type.

Referenced by Olympe::Task_Attack::ExecuteWithContext(), Olympe::EntityBlackboard::ExportGlobalsToJson(), and Olympe::VisualScriptEditorPanel::RenderGlobalVariablesPanel().

+ Here is the caller graph for this function:

◆ AsFloat()

float Olympe::TaskValue::AsFloat ( ) const

◆ AsInt()

int Olympe::TaskValue::AsInt ( ) const

◆ AsString()

std::string Olympe::TaskValue::AsString ( ) const

◆ AsVector()

Vector Olympe::TaskValue::AsVector ( ) const

Returns the Vector value.

Exceptions
std::runtime_errorif the stored type is not Vector.

Definition at line 109 of file TaskGraphTypes.cpp.

References m_type, m_vectorValue, and Olympe::Vector.

Referenced by Olympe::ConditionEvaluator::CompareValues(), Olympe::Task_Flee::ExecuteWithContext(), Olympe::Task_GotoPosition::ExecuteWithContext(), Olympe::EntityBlackboard::ExportGlobalsToJson(), and Olympe::VisualScriptEditorPanel::RenderConstValueInput().

+ Here is the caller graph for this function:

◆ GetType()

VariableType Olympe::TaskValue::GetType ( ) const

◆ IsNone()

bool Olympe::TaskValue::IsNone ( ) const

◆ to_string()

std::string Olympe::TaskValue::to_string ( ) const

Converts the stored value to a string representation.

Never returns an empty string — falls back to "0" for None or empty values. This prevents JSON builder failures when serializing uninitialized entries.

Returns
String representation of the value.

Definition at line 154 of file TaskGraphTypes.cpp.

References Olympe::Bool, Olympe::TaskValue::PodData::boolValue, Olympe::EntityID, Olympe::TaskValue::PodData::entityValue, Olympe::Float, Olympe::TaskValue::PodData::floatValue, GetComponentTypeID_Static(), Olympe::Int, Olympe::TaskValue::PodData::intValue, m_data, m_stringValue, m_type, Olympe::None, Olympe::String, and SYSTEM_LOG.

Referenced by Olympe::VisualScriptEditorPanel::FormatTaskParameters(), and Olympe::VisualScriptEditorPanel::RunGraphSimulation().

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

Member Data Documentation

◆ m_data

union Olympe::TaskValue::PodData Olympe::TaskValue::m_data
private

◆ m_stringValue

std::string Olympe::TaskValue::m_stringValue
private

Definition at line 306 of file TaskGraphTypes.h.

Referenced by AsString(), and to_string().

◆ m_type

VariableType Olympe::TaskValue::m_type
private

◆ m_vectorValue

::Vector Olympe::TaskValue::m_vectorValue
private

Definition at line 305 of file TaskGraphTypes.h.

Referenced by AsVector().


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