Generator.h

Go to the documentation of this file.
00001 
00018 #ifndef GENERATOR_H
00019 #define GENERATOR_H
00020 #include <iomanip>
00021 #include <iostream>
00022 #include <fstream>
00023 #include <sstream>
00024 #include <list>
00025 #include <string>
00026 #include <vector>
00027 #include <time.h>
00028 #include <stdio.h>
00029 #include <math.h>
00030 #include <stdlib.h>
00031 //#include <boost/regex.hpp>
00032 #include "../../lib/StringUtils.h"
00033 #include "GNode.h"
00034 
00035 #define INPUT_START 990 //Our input nodes start at 990 (see the node list: nodes.csv) 
00036 
00037 using namespace std;
00038 
00042 static inline string IntToString(int x)
00043 {
00044         ostringstream o;
00045         if (!(o << x))
00046                 printf("Error in conversion from int to string \n");
00047         return o.str();
00048 }
00049 
00053 static inline string FltToString(float x)
00054 {
00055         ostringstream o;
00056         if (!(o << x))
00057                 printf("Error in conversion from float to string \n");
00058         return o.str();
00059 }
00060 
00065 class Generator
00066 {
00067         friend class GNode;
00068         public:
00070         Generator( void ) {} 
00072         ~Generator( void ) {} 
00073         void cchain( const string &, const string &, const bool &, const bool & );//Mode to create input file for ChemChain
00074         void egen( const string &, const string &, const bool & );//Mode to generate a file with logic for the eq. generator
00075         void cchainToTables( const string &, const string & );
00076         void set_tablesPath( const string & );
00077         void printNodesList(string &, string &, string &);
00078         string get_tablesPath( );
00079 
00080         private:
00081         int getWord(FILE *, char *, int &, string &, char, bool);
00082         list<GNode> gnodes;
00083         string tablesPath;
00084         list<Input> control_inputs;
00085         int find_id( const string & ); //Finds the id of a node by its name
00086         string find_name( const int & ); //Finds name of a node by its ID
00087         void print_gnodes( void ); // Display the list of nodes ... for testing only
00088         void show_tables( void ); //Display the nodes with their truth tables
00089         bool read_gnodes( const string & ); //Read in the list of nodes from the input file
00090         bool read_tables( const bool & ); // Read the truth tables for each node
00091         void err_exit( void ); //Exits program with a message
00092         vector<string> get_states( GNode &, const bool & ); //Gets states of a node when the function = 1 or 0 
00093         string get_function( GNode & ); //Retrieves the logic (the last column in the table) of a node  
00094         bool is_gnode( const string & ); //Checks if the name (string) is a valid node
00095         int num_1( GNode & ); //Counts the number of 1's in a node
00096         int num_lines( void ); //Counts the number of lines of the overall logic
00097         int num_0( GNode & ); //Counts the number of 0's in a node
00098         void decToBin( int, string & ); //Convert decimal to binary
00099 };
00100 #endif

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