Stride Reference Manual  1.0
CasesFile.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, Willem L, Kuylen E, Stijven S & Broeckhove J
14  */
15 
21 #include "CasesFile.h"
22 
23 #include <iostream>
24 
25 namespace stride {
26 namespace output {
27 
28 using namespace std;
29 
30 CasesFile::CasesFile(const std::string& file) {
31  initialize(file);
32 }
33 
35  m_fstream.close();
36 }
37 
38 void CasesFile::initialize(const std::string& file) {
39  m_fstream.open((file + "_cases.csv").c_str());
40 }
41 
42 void CasesFile::print(const vector<unsigned int>& cases) {
43  for (unsigned int i = 0; i < (cases.size() - 1); i++) {
44  m_fstream << cases[i] << ",";
45  }
46  m_fstream << cases[cases.size() - 1] << endl;
47 }
48 
49 }
50 }
CasesFile(const std::string &file="stride_cases")
Constructor: initialize.
Definition: CasesFile.cpp:30
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
Header for the CasesFile class.
void initialize(const std::string &file)
Generate file name and open the file stream.
Definition: CasesFile.cpp:38
STL namespace.
void print(const std::vector< unsigned int > &cases)
Print the given cases with corresponding tag.
Definition: CasesFile.cpp:42
~CasesFile()
Destructor: close the file stream.
Definition: CasesFile.cpp:34