diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2011-05-12 00:54:19 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2011-05-12 00:54:19 +0200 |
commit | 9f56ff279316b1d82d5639e47d587a37dbd6b0c8 (patch) | |
tree | 2cf3213ec048bde596606e530dd255016d1d39c4 /glcdskin | |
parent | b6ca1969785782cf4d6e58f78563804e6812b3e6 (diff) | |
download | graphlcd-base-9f56ff279316b1d82d5639e47d587a37dbd6b0c8.tar.gz graphlcd-base-9f56ff279316b1d82d5639e47d587a37dbd6b0c8.tar.bz2 |
variable values that represent functions are now evaluated at run time
Diffstat (limited to 'glcdskin')
-rw-r--r-- | glcdskin/variable.c | 13 | ||||
-rw-r--r-- | glcdskin/variable.h | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/glcdskin/variable.c b/glcdskin/variable.c index b07773a..3bd6e29 100644 --- a/glcdskin/variable.c +++ b/glcdskin/variable.c @@ -11,6 +11,7 @@ cSkinVariable::cSkinVariable(cSkin * Parent) : mSkin(Parent), mValue(0), mCondition(NULL), + mFunction(NULL), mDummyDisplay(mSkin), mDummyObject(&mDummyDisplay) { @@ -20,14 +21,16 @@ bool cSkinVariable::ParseValue(const std::string & Text) { if (isalpha(Text[0]) || Text[0] == '#') { - cSkinFunction * func = new cSkinFunction(&mDummyObject); - if (func->Parse(Text)) + delete mFunction; + mFunction = new cSkinFunction(&mDummyObject); + if (mFunction->Parse(Text)) { - mValue = func->Evaluate(); - delete func; + //mValue = func->Evaluate(); + //delete func; return true; } - delete func; + delete mFunction; + mFunction = NULL; } else if (Text[0] == '\'') { diff --git a/glcdskin/variable.h b/glcdskin/variable.h index 449f6b0..fdeebbc 100644 --- a/glcdskin/variable.h +++ b/glcdskin/variable.h @@ -18,6 +18,7 @@ #include "display.h" #include "object.h" +#include "function.h" namespace GLCD { @@ -34,6 +35,7 @@ private: std::string mId; cType mValue; cSkinFunction * mCondition; + cSkinFunction * mFunction; cSkinDisplay mDummyDisplay; cSkinObject mDummyObject; @@ -45,7 +47,8 @@ public: cSkin * Skin(void) const { return mSkin; } const std::string & Id(void) const { return mId; } - const cType & Value(void) const { return mValue; } +// const cType & Value(void) const { return mValue; } + const cType & Value(void) { if (mFunction != NULL) { mValue = mFunction->Evaluate(); } return mValue; } ; cSkinFunction * Condition(void) const { return mCondition; } }; |