Stride Reference Manual  - generated for commit 9643b11
InfectedFile.cpp
Go to the documentation of this file.
1 /*
2  * This is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * any later version.
6  * The software is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  * You should have received a copy of the GNU General Public License
11  * along with the software. If not, see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2017, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #include "InfectedFile.h"
22 #include "util/FileSys.h"
23 
24 namespace stride {
25 namespace output {
26 
27 using namespace std;
28 using namespace stride::util;
29 
30 InfectedFile::InfectedFile(const std::string& output_prefix) : m_fstream()
31 {
32  const auto p = FileSys::BuildPath(output_prefix, "cases.csv");
33  m_fstream.open(p.c_str());
34 }
35 
37 
38 void InfectedFile::Print(const vector<unsigned int>& infectionCounts)
39 {
40  for (unsigned int i = 0; i < (infectionCounts.size() - 1); i++) {
41  m_fstream << infectionCounts[i] << ",";
42  }
43  m_fstream << infectionCounts[infectionCounts.size() - 1] << endl;
44 }
45 
46 } // namespace output
47 } // namespace stride
Utilities for the project.
STL namespace.
static filesys::path BuildPath(const std::string &output_prefix, const std::string &filename)
Interpret prefix (directory or filename prefix) and return appropriate path.
Definition: FileSys.cpp:52
Header for the InfectedFile class.
InfectedFile(const std::string &output_dir="output")
Constructor: initialize.
~InfectedFile()
Destructor: close the file stream.
std::ofstream m_fstream
The file stream.
Definition: InfectedFile.h:46
Interface for install directory queries.
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
void Print(const std::vector< unsigned int > &infectionCounts)
Print the given cases with corresponding tag.