00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MARSYAS_EXPR_H
00020 #define MARSYAS_EXPR_H
00021
00022 #include <string>
00023
00024 namespace Marsyas
00025 {
00038 class ExNode;
00044 class Expr;
00045 class Ex {
00046 std::string init_; std::string expr_;
00047 public:
00048 Ex(std::string e) { init_=""; expr_=e; };
00049 Ex(std::string i, std::string e) { init_=i; expr_=e; };
00050 void parse(Expr* e, ExNode*& init, ExNode*& expr);
00051 };
00062 class Rp : public Ex {
00063 public:
00064 Rp(std::string e) : Ex(e,"") {};
00065 Rp(std::string e, std::string r) : Ex(e,r) {};
00066 };
00078 class ExFile {
00079 std::string iex_, ex_, rp_, rr_;
00080 bool file_read_;
00081 void read(std::string fname);
00082 void store(int pos, std::string data);
00083 public:
00084 ExFile(std::string n) { file_read_=false; read(n); }
00085 Ex getEx() { return Ex(iex_,ex_); }
00086 Rp getRp() { return Rp(rp_,rr_); }
00087 };
00088
00093 class ExRecord;
00094 class MarSystem;
00095 class Scheduler;
00096 class TmTimer;
00097 class Expr {
00098 friend class Ex;
00099 bool initialized_;
00100 ExRecord* symbol_table_;
00101 ExNode* init_expr_; ExNode* expr_;
00102 ExNode* rept_; ExNode* rate_;
00103
00104 MarSystem* marsym_; Scheduler* sched_; TmTimer* timer_;
00105
00106 void set(MarSystem* m, Ex& e, Rp& r);
00107
00108 public:
00109 Expr();
00110 Expr(MarSystem* msym, Ex e);
00111 Expr(MarSystem* msym, Ex e, Rp r);
00112 Expr(MarSystem* msym, ExFile e);
00113
00114 virtual ~Expr();
00115
00116 virtual void eval();
00117 virtual bool repeat();
00118 std::string repeat_interval();
00119 bool has_rate() { return rate_!=NULL; }
00120
00121 void setScheduler(Scheduler* v);
00122 void setTimer(TmTimer* t);
00123 void post();
00124 };
00125
00126 }
00127
00128 #endif
00129