JaffarPlus
High-performance best-first search optimizer for tool-assisted speedruns
Loading...
Searching...
No Matches
jaffarPlus::_vCondition< T > Class Template Reference

Concrete, type-specialized condition over operands of type T. More...

#include <condition.hpp>

Inheritance diagram for jaffarPlus::_vCondition< T >:
[legend]

Public Types

enum  operator_t {
  op_equal , op_not_equal , op_greater , op_greater_or_equal ,
  op_less , op_less_or_equal , op_bit_true , op_bit_false ,
  op_modulo_zero , op_modulo_non_zero
}
 The comparison operator applied between the condition's two operands. More...
 

Public Member Functions

 _vCondition (const operator_t opType, Property *property1, Property *property2, T immediate1, T immediate2)
 Builds a typed condition from its operands.
 
bool evaluate () const
 Evaluates the comparison using the operands' current values.
 

Static Public Member Functions

static operator_t getOperatorType (const std::string &operation)
 Maps a configuration operator string to its operator_t value.
 

Protected Attributes

const operator_t _opType
 The comparison operator selected for this condition.
 

Static Private Member Functions

static bool _opEqual (const T a, const T b)
 Returns a == b.
 
static bool _opNotEqual (const T a, const T b)
 Returns a != b.
 
static bool _opGreater (const T a, const T b)
 Returns a > b.
 
static bool _opGreaterOrEqual (const T a, const T b)
 Returns a >= b.
 
static bool _opLess (const T a, const T b)
 Returns a < b.
 
static bool _opLessOrEqual (const T a, const T b)
 Returns a <= b.
 
static bool _opBitTrue (const T a, const T b)
 Returns true if the bit of a at index b is set.
 
static bool _opBitFalse (const T a, const T b)
 Returns true if the bit of a at index b is clear.
 
static bool _opModuloZero (const T a, const T b)
 Returns true if a % b == 0.
 
static bool _opModuloNonZero (const T a, const T b)
 Returns true if a % b != 0.
 

Private Attributes

bool(* _opFcPtr )(const T, const T)
 Resolved operator implementation, selected once at construction from _opType.
 
Property *const _property1
 First operand as a property, or nullptr to use _immediate1.
 
Property *const _property2
 Second operand as a property, or nullptr to use _immediate2.
 
const T _immediate1
 First operand's immediate value (used when _property1 is null).
 
const T _immediate2
 Second operand's immediate value (used when _property2 is null).
 

Detailed Description

template<typename T>
class jaffarPlus::_vCondition< T >

Concrete, type-specialized condition over operands of type T.

Each operand is either a Property (read live on every evaluation) or a fixed immediate value. When a property pointer is non-null it overrides the corresponding immediate. The operator is resolved once at construction to a function pointer to keep evaluate branch-free.

Template Parameters
TThe numeric type the operands are compared as.

Definition at line 92 of file condition.hpp.

Member Enumeration Documentation

◆ operator_t

The comparison operator applied between the condition's two operands.

Enumerator
op_equal 

operand1 == operand2 (config operator "==")

op_not_equal 

operand1 != operand2 (config operator "!=")

op_greater 

operand1 > operand2 (config operator ">")

op_greater_or_equal 

operand1 >= operand2 (config operator ">=")

op_less 

operand1 < operand2 (config operator "<")

op_less_or_equal 

operand1 <= operand2 (config operator "<=")

op_bit_true 

the bit of operand1 at index operand2 is set (config operator "BitTrue")

op_bit_false 

the bit of operand1 at index operand2 is clear (config operator "BitFalse")

op_modulo_zero 

operand1 % operand2 == 0 (config operator "%0")

op_modulo_non_zero 

operand1 % operand2 != 0 (config operator "%N")

Definition at line 26 of file condition.hpp.

Constructor & Destructor Documentation

◆ _vCondition()

template<typename T >
jaffarPlus::_vCondition< T >::_vCondition ( const operator_t  opType,
Property property1,
Property property2,
immediate1,
immediate2 
)
inline

Builds a typed condition from its operands.

Parameters
opTypeThe comparison operator to apply.
property1First operand as a property, or nullptr to use immediate1.
property2Second operand as a property, or nullptr to use immediate2.
immediate1First operand's immediate value, used when property1 is nullptr.
immediate2Second operand's immediate value, used when property2 is nullptr.

Definition at line 103 of file condition.hpp.

Member Function Documentation

◆ _opBitFalse()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opBitFalse ( const T  a,
const T  b 
)
inlinestaticprivate

Returns true if the bit of a at index b is clear.

Definition at line 154 of file condition.hpp.

◆ _opBitTrue()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opBitTrue ( const T  a,
const T  b 
)
inlinestaticprivate

Returns true if the bit of a at index b is set.

Definition at line 152 of file condition.hpp.

◆ _opEqual()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opEqual ( const T  a,
const T  b 
)
inlinestaticprivate

Returns a == b.

Definition at line 140 of file condition.hpp.

◆ _opGreater()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opGreater ( const T  a,
const T  b 
)
inlinestaticprivate

Returns a > b.

Definition at line 144 of file condition.hpp.

◆ _opGreaterOrEqual()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opGreaterOrEqual ( const T  a,
const T  b 
)
inlinestaticprivate

Returns a >= b.

Definition at line 146 of file condition.hpp.

◆ _opLess()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opLess ( const T  a,
const T  b 
)
inlinestaticprivate

Returns a < b.

Definition at line 148 of file condition.hpp.

◆ _opLessOrEqual()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opLessOrEqual ( const T  a,
const T  b 
)
inlinestaticprivate

Returns a <= b.

Definition at line 150 of file condition.hpp.

◆ _opModuloNonZero()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opModuloNonZero ( const T  a,
const T  b 
)
inlinestaticprivate

Returns true if a % b != 0.

Definition at line 158 of file condition.hpp.

◆ _opModuloZero()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opModuloZero ( const T  a,
const T  b 
)
inlinestaticprivate

Returns true if a % b == 0.

Definition at line 156 of file condition.hpp.

◆ _opNotEqual()

template<typename T >
static bool jaffarPlus::_vCondition< T >::_opNotEqual ( const T  a,
const T  b 
)
inlinestaticprivate

Returns a != b.

Definition at line 142 of file condition.hpp.

◆ evaluate()

template<typename T >
bool jaffarPlus::_vCondition< T >::evaluate ( ) const
inlinevirtual

Evaluates the comparison using the operands' current values.

For each operand, the live property value is used when a property was supplied; otherwise the immediate value is used.

Returns
The result of applying the resolved operator to the two operands.

Implements jaffarPlus::Condition.

Definition at line 129 of file condition.hpp.

◆ getOperatorType()

static operator_t jaffarPlus::Condition::getOperatorType ( const std::string &  operation)
inlinestaticinherited

Maps a configuration operator string to its operator_t value.

Parameters
operationThe operator token from the config (e.g. "==", ">=", "BitTrue", "%0").
Returns
The matching operator enum value.
Exceptions
Alogic error if the token is not a recognized operator.

Definition at line 59 of file condition.hpp.

Member Data Documentation

◆ _immediate1

template<typename T >
const T jaffarPlus::_vCondition< T >::_immediate1
private

First operand's immediate value (used when _property1 is null).

Definition at line 165 of file condition.hpp.

◆ _immediate2

template<typename T >
const T jaffarPlus::_vCondition< T >::_immediate2
private

Second operand's immediate value (used when _property2 is null).

Definition at line 166 of file condition.hpp.

◆ _opFcPtr

template<typename T >
bool(* jaffarPlus::_vCondition< T >::_opFcPtr) (const T, const T)
private

Resolved operator implementation, selected once at construction from _opType.

Definition at line 161 of file condition.hpp.

◆ _opType

const operator_t jaffarPlus::Condition::_opType
protectedinherited

The comparison operator selected for this condition.

Definition at line 79 of file condition.hpp.

◆ _property1

template<typename T >
Property* const jaffarPlus::_vCondition< T >::_property1
private

First operand as a property, or nullptr to use _immediate1.

Definition at line 163 of file condition.hpp.

◆ _property2

template<typename T >
Property* const jaffarPlus::_vCondition< T >::_property2
private

Second operand as a property, or nullptr to use _immediate2.

Definition at line 164 of file condition.hpp.


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