00001 /* 00002 * observable.hh 00003 * 00004 * Created on: May 26, 2009 00005 * Author: msneddon 00006 */ 00007 00008 #ifndef OBSERVABLE_HH_ 00009 #define OBSERVABLE_HH_ 00010 00011 #include "NFcore.hh" 00012 00013 namespace NFcore 00014 { 00015 00016 class ReactionClass; 00017 class Molecule; 00018 class TemplateMolecule; 00019 class Complex; 00020 00021 00023 00031 class Observable 00032 { 00033 public: 00034 00035 // /*! 00036 // Constructor that creates a basic Observable which monitors the 00037 // given TemplateMolecule and can be referenced via the alias name 00038 // */ 00039 // Observable(string aliasName, TemplateMolecule * templateMolecule); 00040 // 00041 // /*! 00042 // Deconstructor that doesn't do too much. It doesn't free the memory 00043 // associated with the TemplateMolecule because the MoleculeType class 00044 // handles that. 00045 // */ 00046 // ~Observable(); 00047 // 00048 // 00049 // bool isObservable(Molecule * m) const; 00050 // void add(); 00051 // void subtract(); 00052 // 00053 // 00054 // void clear() { count=0; }; 00055 // void straightAdd() {count++;}; 00056 // 00057 // /* methods used to get observable information */ 00058 // unsigned long int getCount() const {return (unsigned long int) count;}; 00059 // string getAliasName() const { return aliasName; }; 00060 // 00061 // void addReferenceToMyself(mu::Parser * p); 00062 // void addReferenceToMyself(string referenceName, mu::Parser * p); 00063 // 00064 // 00065 // void addDependentRxn(ReactionClass *r); 00066 // 00067 // TemplateMolecule * getTemplateMolecule() const { return templateMolecule; }; 00068 00069 00070 00072 00073 Observable(string name); 00074 virtual ~Observable(); 00075 00076 virtual Observable * clone()=0; 00077 00078 00079 00080 void add(); 00081 void straightAdd(); 00082 void subtract(); 00083 void straightSubtract(); 00084 void clear() { count=0; }; 00085 00086 int getCount() const { return (int)count; }; 00087 string getName() const { return obsName; }; 00088 int getType() const { return type; }; 00089 00090 void getTemplateMoleculeList(int &n_templates, TemplateMolecule **&tmList); 00091 00092 void addReferenceToMyself(mu::Parser *p); 00093 void addReferenceToMyself(string referenceName, mu::Parser *p); 00094 void addDependentRxn(ReactionClass *r); 00095 00096 virtual int isObservable(Molecule *m) const = 0; 00097 virtual int isObservable(Complex *c) const = 0; 00098 00099 00100 //Indentifiers 00101 static const int NO_RELATION = -1; 00102 static const int EQUALS = 0; 00103 static const int NOT_EQUALS = 1; 00104 static const int GREATER_THAN = 2; 00105 static const int LESS_THAN = 3; 00106 static const int GREATOR_OR_EQUAL_TO = 4; 00107 static const int LESS_THAN_OR_EQUAL_TO = 5; 00108 00109 00110 static const int NO_TYPE = 0; 00111 static const int MOLECULES = 1; 00112 static const int SPECIES = 2; 00113 00114 00115 protected: 00116 //string obsName; /* The name that will be output for this observable */ 00117 //TemplateMolecule * templateMolecule; /* The template molecule which represents what we want to observe */ 00118 //double count; /* the number of molecules that match this observable, its a double so that functions can use it (as a reference) */ 00119 00120 //vector <ReactionClass *> dependentRxns;/* signifies that some reaction's propensity depends on this observable */ 00121 //vector <ReactionClass *>::iterator rxnIter; 00122 00123 00125 string obsName; 00126 int type; 00127 double count; 00128 00129 00130 int n_templates; 00131 TemplateMolecule ** templateMolecules; 00132 00133 int n_dependentRxns; 00134 ReactionClass ** dependentRxns; 00135 00136 }; 00137 00138 00139 class MoleculesObservable : public Observable 00140 { 00141 public: 00142 MoleculesObservable(string name, TemplateMolecule *tm); 00143 MoleculesObservable(string name, vector <TemplateMolecule *> &tmList); 00144 00145 virtual ~MoleculesObservable(); 00146 00147 virtual Observable * clone(); 00148 00149 virtual int isObservable(Molecule *m) const; 00150 virtual int isObservable(Complex *c) const; 00151 00152 00153 protected: 00154 00155 00156 00157 }; 00158 00159 00160 class SpeciesObservable : public Observable 00161 { 00162 public: 00163 SpeciesObservable(string name, vector <TemplateMolecule *> &tmList, vector <string> &stochRelation, vector <int> &stochQuantity); 00164 00165 virtual ~SpeciesObservable(); 00166 00167 virtual Observable * clone(); 00168 00169 virtual int isObservable(Molecule *m) const; 00170 virtual int isObservable(Complex *c) const; 00171 00172 protected: 00173 00174 // information for processing stochiometric observables 00175 int *relation; 00176 int *quantity; 00177 00178 00179 00180 00181 00182 }; 00183 00184 00185 00186 } 00187 00188 00189 00190 #endif /* OBSERVABLE_HH_ */