Scheduler
record.cpp
Go to the documentation of this file.
1 
10 #include "record.h"
11 
12 #include <iomanip>
13 #include <iostream>
14 #include <fstream>
15 
16 using namespace Utils;
17 
18 Record::Record(std::shared_ptr<Utils::Configuration> c, std::string n) : name(n), conf(c)
19 {
20  record = conf->getBoolValue("global", "record", true);
21 }
22 
23 void Record::printToFile(std::string folder) const
24 {
25  if (!record)
26  return;
27  std::string filename = conf->getFilePrefix() + name + "Report.txt";
28  std::string path = folder + "/" + filename;
29  std::ofstream file;
30  file.open(path, std::ios_base::app);
31  file << "report for "<< name <<" ("<<vector.size()<<"entries):\n";
32  for (unsigned int i = 0; i < vector.size(); i++)
33  {
34  file << std::setfill(' ') << std::setw(12) << std::setprecision(12);
35  file << vector[i].first << ": " << vector[i].second << "\n";
36  }
37  file.close();
38 }
39 
40 
41 void Record::add(double time, double element)
42 {
43  if (record)
44  vector.push_back(std::pair<double, double>(time, element));
45 }
46 
void printToFile(std::string folder) const
Definition: record.cpp:23
void add(double time, double element)
Definition: record.cpp:41
string filename
Definition: aging.py:5
list time
Definition: aging.py:11
Record(std::shared_ptr< Utils::Configuration > conf, std::string name)
Definition: record.cpp:18
Definition: context.h:16