00001 #ifndef _MODEL_H_NOU_ 00002 #define _MODEL_H_NOU_ 00003 00004 #include <string> 00005 #include <vector> 00006 #include <CL/cl.h> 00007 #include "cellspace.h" 00008 00009 using namespace std; 00010 00011 class Machine; 00019 class Model 00020 { 00021 private: 00022 cl_program program; 00023 vector<CellSpace*> patterns; 00024 public: 00025 Model(Machine *parent); 00026 virtual ~Model(); 00027 Machine* getParent(){ return parent; } 00028 void addChild(CellSpace *child); 00029 void removeChild(CellSpace *child); 00036 virtual void run(CellSpace *pattern, int which, int iteration = 1) = 0; 00040 virtual int getCellSize() = 0; 00045 virtual void loadSource() = 0; 00052 virtual void renderToTexture(CellSpace *pattern, int which, cl_mem tex) = 0; 00053 protected: 00054 cl_int build(string source, string options); 00055 cl_kernel kernel, render_kernel; 00056 Machine *parent; 00057 }; 00065 class SynchronousModel : public Model 00066 { 00067 public: 00068 SynchronousModel(Machine *parent, string model_definition); 00069 int getCellSize(){ return sizeof(int)*2; } 00070 void loadSource(); 00071 void run(CellSpace *pattern, int which, int iteration = 1); 00072 virtual void renderToTexture(CellSpace *pattern, int which, cl_mem tex); 00073 private: 00074 string source; 00075 }; 00076 00077 #endif // _MODEL_H_NOU_