MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / CompareVariables

Method CompareVariables

lib/macro/macro-condition-variable.cpp:69–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69bool MacroConditionVariable::CompareVariables()
70{
71 auto var1 = _variable.lock();
72 auto var2 = _variable2.lock();
73 if (!var1 || !var2) {
74 return false;
75 }
76
77 auto val1 = var1->DoubleValue();
78 auto val2 = var2->DoubleValue();
79 bool validNumbers = val1.has_value() && val2.has_value();
80
81 switch (_type) {
82 case MacroConditionVariable::Condition::EQUALS_VARIABLE:
83 return var1->Value() == var2->Value() ||
84 (validNumbers && val1 == val2);
85 case MacroConditionVariable::Condition::LESS_THAN_VARIABLE:
86 return validNumbers && val1 < val2;
87 case MacroConditionVariable::Condition::GREATER_THAN_VARIABLE:
88 return validNumbers && val1 > val2;
89 default:
90 blog(LOG_WARNING,
91 "Unexpected call of %s with condition type %d", __func__,
92 static_cast<int>(_type));
93 }
94
95 return false;
96}
97
98bool MacroConditionVariable::CheckCondition()
99{

Callers

nothing calls this directly

Calls 2

DoubleValueMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected