CsvLogger.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <fstream>
4 #include <map>
5 #include <memory>
6 #include <string>
7 
8 class CSVLogger
9 {
10  typedef std::map<std::string, double> columns_type;
11 
12  public:
13  CSVLogger();
14  virtual ~CSVLogger();
15 
16  public:
17  void addColumn(std::string name);
18  void updateColumn(std::string name, double value);
19  bool writeHeader();
20  bool writeRow();
21 
22  void setFilepath(std::string path) { filepath_ = path; }
23  bool open();
24  bool isOpen();
25  bool close();
26  bool clear();
27 
28  void setRecording(bool recording) { isRecording = recording; }
29  void newSession();
30 
31  private:
32  columns_type columns_;
33  std::shared_ptr<std::ofstream> file_;
34  std::string filepath_;
35  bool isRecording = false;
36  unsigned int currentSession = 1;
37 };
std::string filepath_
Definition: CsvLogger.h:34
columns_type columns_
Definition: CsvLogger.h:32
bool isOpen()
Definition: CsvLogger.cpp:67
std::shared_ptr< std::ofstream > file_
Definition: CsvLogger.h:33
void updateColumn(std::string name, double value)
Definition: CsvLogger.cpp:10
bool clear()
Definition: CsvLogger.cpp:78
virtual ~CSVLogger()
Definition: CsvLogger.cpp:8
bool close()
Definition: CsvLogger.cpp:68
bool open()
Definition: CsvLogger.cpp:55
unsigned int currentSession
Definition: CsvLogger.h:36
void setFilepath(std::string path)
Definition: CsvLogger.h:22
bool isRecording
Definition: CsvLogger.h:35
bool writeHeader()
Definition: CsvLogger.cpp:15
bool writeRow()
Definition: CsvLogger.cpp:33
void setRecording(bool recording)
Definition: CsvLogger.h:28
void newSession()
Definition: CsvLogger.cpp:90
void addColumn(std::string name)
Definition: CsvLogger.cpp:9
std::map< std::string, double > columns_type
Definition: CsvLogger.h:10


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:19