[apps/probability] Create a class evaluate context for probability app

Change-Id: I38448ddeec25225edad1d96bf89d32d1eb86915d
This commit is contained in:
Émilie Feral
2016-12-06 11:01:16 +01:00
parent eeb17625d1
commit 620b64a583
5 changed files with 69 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
#include "evaluate_context.h"
#include <string.h>
namespace Probability {
EvaluateContext::EvaluateContext(::Context * parentContext) :
m_tValue(Float(0.0f)),
m_firstParameterValue(Float(0.0f)),
m_secondParameterValue(Float(0.0f)),
m_context(parentContext)
{
}
void EvaluateContext::setOverridenValueForSymbolT(float f) {
m_tValue = Float(f);
}
void EvaluateContext::setOverridenValueForFirstParameter(float f) {
m_firstParameterValue = Float(f);
}
void EvaluateContext::setOverridenValueForSecondParameter(float f) {
m_secondParameterValue = Float(f);
}
const Expression * EvaluateContext::expressionForSymbol(const Symbol * symbol) {
if (symbol->name() == 't') {
return &m_tValue;
}
if (symbol->name() == Symbol::SpecialSymbols::p1) {
return &m_firstParameterValue;
}
if (symbol->name() == Symbol::SpecialSymbols::p2) {
return &m_secondParameterValue;
}
return m_context->expressionForSymbol(symbol);
}
}