Class Reference for E1039 Core & Analysis Software
rs_Reader.cc
Go to the documentation of this file.
1 //rs_Reader.cc
2 #include <iostream>
3 #include <fstream>
4 #include <sstream>
5 #include <limits>
6 #include <cstring>
7 #include <vector>
8 #include "rs_Reader.h"
9 using namespace std;
10 
11 rs_Reader::rs_Reader(const std::string file_name_in)
12  : file_name(file_name_in)
13 {
14  //cout << "Opening File with RS: "<< file_name << endl;
15 
16  //READ IN DATA FROM RS
17  ifstream infile_rs;
18  infile_rs.open(file_name);
19  if (!infile_rs.is_open()){
20  cout << "Error opening RS file" <<endl;
21  exit(1);
22  }
23  infile_rs.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
24  int pol_temp;
25  int road_count = 0;
26  rs rs_temp;
27 
28  while(infile_rs >> rs_temp.road_id >> pol_temp >> rs_temp.H1X >> rs_temp.H2X >> rs_temp.H3X >> rs_temp.H4X >> rs_temp.signal >> rs_temp.background){
29  roads.push_back(rs_temp);
30  road_count ++;
31  }
32  pol = pol_temp;
33  N_ROADS = road_count;
34 /*
35  rs_vec.push_back(rs_vals());
36  int count = 0;
37 
38  while(infile_rs >> rs_vec[count].road_id >> pol >> rs_vec[count].H1X >> rs_vec[count].H2X >> rs_vec[count].H3X >> rs_vec[count].H4X >> rs_vec[count].signal >> rs_vec[count].background){
39  count++;
40  rs_vec.push_back(rs_vals());
41  }
42 
43  vector<rs_vals>::iterator it;
44 
45  it = rs_vec.end()-1;
46  rs_vec.erase(it);
47 
48  N_ROADS = rs_vec.size();
49 */
50  infile_rs.close();
51 }
std::vector< rs > roads
Definition: rs_Reader.h:27
int pol
Definition: rs_Reader.h:26
int N_ROADS
Definition: rs_Reader.h:25
rs_Reader(const std::string file_name)
Definition: rs_Reader.cc:11
std::string file_name
Definition: rs_Reader.h:24
Definition: rs_Reader.h:9
int H4X
Definition: rs_Reader.h:15
int background
Definition: rs_Reader.h:17
int H2X
Definition: rs_Reader.h:13
int H1X
Definition: rs_Reader.h:12
int H3X
Definition: rs_Reader.h:14
int signal
Definition: rs_Reader.h:16
int road_id
Definition: rs_Reader.h:11