Ttable.h

Go to the documentation of this file.
00001 #ifndef TTABLE_H
00002 #define TTABLE_H
00003 
00004 #include <iostream>
00005 #include <stdlib.h>
00006 #include <iomanip>
00007 #include <string>
00008 #include <math.h>
00009 #include <list>
00010 #include <vector>
00011 
00012 using namespace std;
00013 
00014 /*struct Input
00015 {
00016     string iname;
00017     int iid;
00018 };*/
00019 
00024 class Ttable
00025 {
00026     friend class Mutator;
00027 
00031     friend ostream &operator<<( ostream & os, const Ttable & n )
00032     {
00033         return os << n.nodeName << " - " << n.nodeID << " init: " << n.initVal << " table: " << n.COLS << " by " << n.ROWS << endl;
00034     }
00035 
00036         public:
00038         Ttable( const string & aname, const vector<string> & inNodes)
00039         {
00040                 COLS = 0;
00041                 ROWS = 0;
00042                 nodeName = aname;
00043                 for( unsigned int i = 0; i < inNodes.size(); ++i )
00044                         inputs.push_back(inNodes[i]);
00045         }
00046     //Ttable( const string &, const vector & );
00047     //Ttable( );
00049     ~Ttable( )
00050     {
00051         /*   for( int i = 0; i < ROWS; ++i)   //When uncommented gives the following error:
00052              free(table[i]);                // *** glibc detected *** double free or corruption (fasttop): 0x09b24c48 ***
00053         //   Aborted
00054 
00055         free(table);*/
00056     }
00058         int getNumOfInputs( void )
00059         {       return inputs.size();   }
00061     int nrows( void )
00062     {  return ROWS; }
00064     int ncols( void )
00065     {  return COLS; }
00066         //returns the name
00067     string get_name(void)
00068     {  return nodeName; }
00069     /*void set( const string & n, const int & i, const int & _init )
00070     {
00071         nodeName = n;
00072         nodeID = i;
00073         init = _init;
00074     }*/
00076         vector<string> getInputs( void )
00077         { return inputs; }
00078     bool table_init( const int & );
00079     void print_table( void );
00080     /*void new_input( const Input & n )
00081     {
00082         inputs.push_back(n);
00083     }*/
00084     void print_inputs( void );      
00086     int get_id( void )
00087     {   return nodeID;  }
00089     int get_init( void )
00090     {   return initVal; }
00091     //void build( );
00092     void build( const int &, const vector<string> & );
00093     void replaceInputs( const vector<string> & );
00094         void decToBin( const int &, string & );
00095         bool getVal( const int &, const int &);
00096         void setVal( const int &, const int &, const bool &);
00097     private:
00098     int COLS;
00099     int ROWS;
00100     //int init;
00101     string nodeName;
00102     int nodeID;
00103     bool **table;
00104     vector<string> inputs;
00105         bool initVal;
00106 };
00107 #endif

Generated on Fri May 7 00:40:41 2010 for ChemChains by  doxygen 1.6.1