00001 #ifndef GSUBREADER_H 00002 #define GSUBREADER_H 00003 00004 #include "gfeature.h" 00005 //#include "GReaderState.h" 00006 00007 class InvalieInputFeature : public exception { 00008 }; 00009 00010 class Gsubreader; 00011 class GReaderState { 00012 public: 00014 virtual void processInput(Gsubreader *r, Gfeature *f) { } 00015 //static GReaderState* instance(); 00016 00017 protected: 00020 void changeState(Gsubreader* r, GReaderState *s); 00021 GReaderState() { } 00022 }; 00023 00024 class GReaderStateS : public GReaderState { 00025 public: 00026 static GReaderStateS* instance(); 00027 virtual void processInput(Gsubreader* r, Gfeature* f); 00028 00029 protected: 00030 GReaderStateS() { } 00031 static GReaderStateS* solo; 00032 }; 00033 00034 class GReaderStateM : public GReaderState { 00035 public: 00036 static GReaderStateM* instance(); 00037 virtual void processInput(Gsubreader* r, Gfeature* f); 00038 00039 protected: 00040 GReaderStateM() { } 00041 static GReaderStateM* solo; 00042 }; 00043 00044 class GReaderStateC : public GReaderState { 00045 public: 00046 static GReaderStateC* instance(); 00049 virtual void processInput(Gsubreader* r, Gfeature* f); 00050 00051 protected: 00052 GReaderStateC() { } 00053 static GReaderStateC* solo; 00054 }; 00055 00057 /* 00058 class GReaderStateG : public GReaderState { 00059 public: 00060 static GReaderStateG* instance(); 00061 virtual void processInput(Gsubreader* r, Gfeature* f); 00062 00063 protected: 00064 GReaderStateG() { } 00065 static GReaderStateG* solo; 00066 }; 00067 00068 class GReaderStateError : public GReaderState { 00069 }; 00070 */ 00071 00072 //class GReaderState; 00073 00078 class Gsubreader { 00079 public: 00081 Gsubreader() : genes(), current(GReaderStateS::instance()), 00082 transcript(), cds() { } 00083 ~Gsubreader(); 00090 string read(const string &file); 00091 int numberOfGenes() const { return genes.size(); } 00092 const vector<Genefeature*>& getGenes() const { return genes; } 00093 void clear(); 00094 00095 protected: 00096 friend class GReaderState; 00097 friend class GReaderStateS; 00098 friend class GReaderStateM; 00099 friend class GReaderStateC; 00100 void processInput(Gfeature *gf) { 00101 current->processInput(this, gf); } 00102 void changeState(GReaderState *s) { current=s; } 00103 vector<Genefeature*> genes; 00107 GReaderState *current; 00109 vector<Gfeature*> transcript; 00110 vector<Gfeature*> cds; 00111 }; 00112 00113 #endif
1.5.6