1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
   |  
#include <iostream>   
#include <fstream>       
#include <sstream>  
#include <vector>     
#include <stdlib.h>
#include "Input.h"
#include "Coup.h"
#include "Mat.h"
#include "Elem.h"
#include "Start.h"
#include "Preci.h"
#include "main.h"
using namespace std;
Input::Input()
{
}
Input::~Input()
{
}
void Input::runInput(int coupling,vector<string> temp,Coup &_coup,unsigned int nb)
{
    vector<string> arg;              
    vector< vector<string> >argBis;   
    int a=0;
    bool testTemp=false,TestDistri=false;
    string command, dump;
    Mat _mat;
    Elem _elem;
    Preci _preci;
    Start start;
    string my_file = "texte.txt";
    ifstream dataBase(my_file.c_str(), ios::in);    
    if(dataBase)   
    {
        while (!dataBase.eof())   
        {
            getline(dataBase,dump);              
            arg.clear();
            parse(dump,arg);
            if (arg[0]=="#")
            {
            }
            else if (arg[0]=="mat")
            {
                a=0;
                a=arg.size()-1; 
                if (a==4)
                {
                }
                else if (a<4)
                {                    
                    break;
                }
                else if (a>4)
                {
                    break;
                }
                _mat.Add_Mat(arg);
            }
            else if (arg[0]=="elem")
            {
                a=0;
                a=arg.size()-1;
                if (a==5)
                {
                }
                else if (a<5)
                {
                   break;
                }
                else if (a>5)
                {
                    break;
                }
                _elem.Add_Elem(arg);
            }
            else if (arg[0]=="preci")
            {
                    _preci.Add_Preci(arg,_elem);
            }
            else if (arg[0]=="tempProfile")
            {
                if (TestTemp==true)
                {
                    break;
                }
                else if(coupling==1)
                {
                    argBis.push_back(temp);
                }
                else
                {
                    a=0;
                    a=arg.size()-1;
                    if (a%2!=0)    
                    {
                      break;
                    }
                    else
                    {
                    }
                    for (size_t i=1; i<arg.size()-3; i=i+2) 
                    {                       
                        if ( atof(arg[i+2].c_str()) >= atof(arg[i].c_str()) )
                        {
                        }
                        else
                        {
                            break;
                        }
                    }
                    argBis.push_back( arg );
                }
            }
            else if (arg[0]=="all")
            {
                _elem.Add_All(arg);
            }
        }
        TempProfile _tempProfile(argBis.back());
        dataBase.close(); 
        tempeFileBase.close();
        _initialBase.close();
start.Run(coupling,_coup,nb,_mat,_preci,_elem,_tempProfile,TestTemp,TestDistri);
    }
} | 
Partager