mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] Change calculation store model to be a buffer ring
Change-Id: Ic444456288e68dcf7b78705880b9507de0a95a2d
This commit is contained in:
@@ -4,13 +4,28 @@
|
||||
namespace Calculation {
|
||||
|
||||
Calculation::Calculation() :
|
||||
m_text(""),
|
||||
m_expression(nullptr),
|
||||
m_layout(nullptr),
|
||||
m_evaluation(Float(0.0f))
|
||||
m_evaluation(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
Calculation & Calculation::operator= (const Calculation & other) {
|
||||
strlcpy(m_text, other.m_text, sizeof(m_text));
|
||||
if (m_expression != nullptr) {
|
||||
delete m_expression;
|
||||
}
|
||||
m_expression = Expression::parse(m_text);
|
||||
if (m_layout != nullptr) {
|
||||
delete m_layout;
|
||||
}
|
||||
if (m_expression) {
|
||||
m_layout = m_expression->createLayout();
|
||||
}
|
||||
m_evaluation = other.m_evaluation;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Calculation::setContent(const char * c, Context * context) {
|
||||
strlcpy(m_text, c, sizeof(m_text));
|
||||
if (m_expression != nullptr) {
|
||||
@@ -45,8 +60,15 @@ ExpressionLayout * Calculation::layout() {
|
||||
return m_layout;
|
||||
}
|
||||
|
||||
Float * Calculation::evaluation() {
|
||||
return &m_evaluation;
|
||||
float Calculation::evaluation() {
|
||||
return m_evaluation;
|
||||
}
|
||||
|
||||
bool Calculation::isEmpty() {
|
||||
if (m_expression == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user