00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __CH_Expression_h__
00028 #define __CH_Expression_h__
00029
00030 #include "CH_API.h"
00031 #include <iostream.h>
00032 #include <SYS/SYS_Types.h>
00033 #include <UT/UT_String.h>
00034 #include "CH_ExprLanguage.h"
00035
00036 class EV_FUNCTION;
00037 class UT_IStream;
00038 class EV_EXPRESSION;
00039 class PY_CompiledCode;
00040
00041 class CH_API CH_Expression
00042 {
00043 public:
00044 CH_Expression(const char *expr, CH_ExprLanguage language);
00045 ~CH_Expression();
00046
00047 void save(ostream &os, int binary, bool compiled) const;
00048 bool load(UT_IStream &is);
00049
00050 const char *getExpression() const;
00051 void setExpression(const char *expr,
00052 CH_ExprLanguage language);
00053 unsigned getExpressionFlag() const;
00054 void setExpressionFlag(int flag);
00055
00056 CH_ExprLanguage getLanguage() const;
00057 void setLanguage(CH_ExprLanguage language);
00058
00059 void unresolveLocalVars(int thread);
00060
00061 unsigned isCompiled() const;
00062 unsigned isHardwired() const;
00063
00064
00065 float evaluate(int thread);
00066
00067 void evaluateString(UT_String &result, int thread);
00068
00069 void dirtyExprCache();
00070
00071 int modified() const;
00072 int usesInValue();
00073 int usesOutValue();
00074 int usesValues();
00075 int usesSlopes();
00076 int usesAccels();
00077 int usesKnots();
00078
00079 void buildOpDependencies(void *ref_id, int thread);
00080 int changeOpRef(const char *new_fullpath,
00081 const char *old_fullpath,
00082 const char *old_cwd,
00083 const char *chan_name,
00084 const char *old_chan_name,
00085 int thread);
00086
00087 void *getSingleFunctionInstanceData(
00088 EV_FUNCTION *func, int thread, UT_String &argument);
00089
00090 int findString(const char *str, bool fullword,
00091 bool usewildcards) const;
00092 int changeString(const char *from, const char *to,
00093 bool fullword, int thread);
00094
00095 const char *getReferencePath() const;
00096 void setReferencePath(const char *path);
00097
00098 CH_Expression &operator=(const CH_Expression &from)
00099 {
00100 const char *src;
00101 if (src = from.getExpression())
00102 setExpression(src, from.getLanguage());
00103 return *this;
00104 }
00105
00106 operator const char *() const { return getExpression(); }
00107
00108
00109
00110
00111
00112 static void addExprFlags(int flags, int thread);
00113
00114
00115
00116
00117
00118 static int &exprFlags();
00119
00120
00121
00122
00123
00124
00125
00126
00127 static SYS_DEPRECATED void setTimeDependency();
00128
00129 private:
00130 void changeExpr(const char *source, int thread);
00131
00132 CH_ExprLanguage myLanguage;
00133 EV_EXPRESSION *myExpr;
00134 PY_CompiledCode *myPyExpr;
00135 UT_String myReferencePath;
00136
00137 friend ostream &operator<<(ostream &os, const CH_Expression &d)
00138 {
00139 d.save(os, 0, false);
00140 return os;
00141 }
00142 };
00143
00144 #endif