0.2.0
Loading...
Searching...
No Matches
FileWriter.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
13
14#pragma once
15
16#include <string>
17#include <fstream>
18#include <filesystem>
19
20#include <nlohmann/json.hpp>
21using json = nlohmann::json;
22
23namespace NAV
24{
27{
28 public:
30 enum class FileType
31 {
32 NONE,
33 BINARY,
34 ASCII,
35 };
36
40 static const char* to_string(FileType type);
41
43 ~FileWriter() = default;
45 FileWriter(const FileWriter&) = delete;
49 FileWriter& operator=(const FileWriter&) = delete;
52
53 protected:
55 FileWriter() = default;
56
63 bool guiConfig(const char* vFilters, const std::vector<std::string>& extensions, size_t id, const std::string& nameId);
64
66 std::filesystem::path getFilepath();
67
69 [[nodiscard]] json save() const;
70
73 void restore(const json& j);
74
76 bool initialize();
77
80
82 std::string _path;
83
85 std::ofstream _filestream;
86
89};
90
91} // namespace NAV
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Parent class for other data loggers which manages the output filestream.
Definition FileWriter.hpp:27
std::string _path
Path to the file.
Definition FileWriter.hpp:82
FileWriter()=default
Default constructor.
FileWriter(const FileWriter &)=delete
Copy constructor.
FileType _fileType
File Type.
Definition FileWriter.hpp:88
FileType
File Type.
Definition FileWriter.hpp:31
@ ASCII
Ascii text data.
FileWriter & operator=(FileWriter &&)=delete
Move assignment operator.
static const char * to_string(FileType type)
Converts the provided type into string.
~FileWriter()=default
Destructor.
FileWriter(FileWriter &&)=delete
Move constructor.
void deinitialize()
Deinitialize the file reader.
FileWriter & operator=(const FileWriter &)=delete
Copy assignment operator.
bool guiConfig(const char *vFilters, const std::vector< std::string > &extensions, size_t id, const std::string &nameId)
ImGui config.
std::filesystem::path getFilepath()
Returns the path of the file.
void restore(const json &j)
Restores the node from a json object.
json save() const
Saves the node into a json object.
bool initialize()
Initialize the file reader.
std::ofstream _filestream
File stream to write the file.
Definition FileWriter.hpp:85