00001 00018 #ifndef NODELIST_H 00019 #define NODELIST_H 00020 00021 #include <vector> 00022 #include <iostream> 00023 #include <iomanip> 00024 #include <string> 00025 #include <time.h> 00026 #include <stdexcept> 00027 #include <fstream> 00028 #include <algorithm> 00029 #include <functional> 00030 #include "Node.h" 00031 #include "lib/StringUtils.h" 00032 00033 void ipause(); 00034 00039 class NodeItem { 00040 public: 00041 //default constructor 00042 NodeItem(); 00043 //copy constructor 00044 NodeItem(const NodeItem &); 00045 //destructor 00046 ~NodeItem(); 00048 NodeItem & operator = (const NodeItem &); 00049 void setName(string n); 00050 void setNode(const Node &); 00051 void setNode(const InputNode &); 00052 void setNode(const OutputNode &); 00053 void setNode(const BooleanNode &); 00054 void setNode(const DelayNode &); 00055 void setNode(const SustainNode &); 00056 bool removeNode(); 00058 string getName() const {return name;}; 00059 Node & getNode(); 00060 bool hasNode() const; 00061 protected: 00062 string name; 00063 private: 00064 Node *node; 00065 }; 00066 00067 00072 class NodeList { 00073 public: 00074 NodeList(); 00075 friend istream &operator >>(istream &in, NodeList &nl); 00076 void visPrint(ostream &out, NodeList &nl); 00077 void bitsPrint(NodeList &nl); 00078 int find(string n); 00079 int add(NodeItem &i); 00080 void reset(void); 00081 void clear(void); 00083 Node &getNode(int i) {return nodes[i].getNode();}; 00085 NodeItem &getNodeItem(int i) { return nodes[i];} 00087 Node &getInputNode(int i) {return inputs[i].getNode();}; 00089 string getName(int i) {return nodes[i].getName();}; 00091 NodeList &setRunTime(int r) {runTime = r+1; return *this;}; 00093 int getRunTime() {return runTime;}; 00095 string getRunName() {return runName;}; 00097 NodeList &setTransient(int r) {transient = r; return *this;}; 00099 int getTransient() {return transient;}; 00101 NodeList &setWindow( int w) { window = w; return *this;}; 00103 NodeList &setScalar( int s) { scalar = s; return *this;}; 00105 int getWindow(void) {return window;}; 00107 int getScalar(void) {return scalar;}; 00108 int getNextAnalPt( void ); 00109 void sortAnalPts( void ); 00110 NodeList &printNames(ostream &out); 00111 void printNodes(ostream &out); 00112 void printInputs(ostream &out); 00113 vector<NodeItem> outputs; 00114 vector<NodeItem> outCalc; 00115 int inOutCalc( int ); 00116 void inOutInit(void); 00117 vector<int> inOutIndex; 00118 int getNodeIndex( string ); 00119 vector <float> avg; // Gong added in 11/11/05 to compute the average value for each Boolean node 00120 vector < vector<bool> > bits; 00122 int outCalcSize() {return static_cast<int>(outCalc.size());} 00124 int getNumOfInputs() {return inputs.size();} 00126 int outputSize() {return static_cast<int>(outputs.size());}; 00128 int ptsSize() { return analPts.size(); };//rename this more appropriately 00129 void printAnalPts( void ); 00130 void setMutants( void ); 00132 void setRunName( const string & str ) { runName = str; }; 00133 void setRunDir( const string & str ) { RUNDIR = str;}; 00134 string getRunDir( void ){return RUNDIR;}; 00135 bool readParams(istream &, InputNode &, bool , NodeList & nl ); 00136 void calcAvg( void ); 00137 void printAvg( ostream &); 00138 void calcCurrAvg( void ); 00139 void printAvgSep( const string & ); 00140 void printDosages( ostream & ); 00141 void printBits( ostream & ); 00142 void printInputBits( ostream & ); 00143 void initBits( bool); 00144 void initInputBits( ); 00146 void setNoisyInputs(void) { noisyInputs = true; }; 00148 bool isNoisyInputs(void) { return noisyInputs; }; 00149 void addAnalPt( const int & ); 00150 vector<int> dosageRec; 00151 vector<int> analPts; 00152 vector<int> banalPts; 00153 int avgPeriod; 00155 int nodeSize() {return static_cast<int>(nodes.size());}; 00156 int getNodeAvg(string, int); 00157 void setOutputAll(bool b){outputAll=b;}; 00158 string getInputNames(int); 00159 string getOutNames(int); 00160 void setInputs(string , int); 00161 int getOutLevels(int); 00162 bool isBool(string); 00163 void readBools(string); 00164 void setSimnum(int i){simNumber = i;}; 00165 int getSimnum(void){return simNumber;}; 00166 protected: 00167 vector < vector<bool> > inputBits; 00168 void addOutput(NodeItem &i); 00169 void addInput(NodeItem &i); 00170 void addOutCalc(NodeItem &i);// Gong added to compute the average 00171 void addNode(NodeItem &i); 00172 void addMutant( Mutant & ); 00173 vector<Mutant> mutants;//tracks mutant nodes 00174 vector<NodeItem> nodes;//tracks all nodes 00175 vector<NodeItem> inputs;//tracks input nodes 00176 int runTime; 00177 string RUNDIR; 00178 string runName; 00179 int transient; 00180 int window; 00181 int scalar; 00182 bool noisyInputs; 00183 bool outputAll; 00184 int simNumber; 00185 00186 }; 00187 #endif