print.h
Go to the documentation of this file.
1 /*
2  * OpenVINS: An Open Platform for Visual-Inertial Research
3  * Copyright (C) 2018-2023 Patrick Geneva
4  * Copyright (C) 2018-2023 Guoquan Huang
5  * Copyright (C) 2018-2023 OpenVINS Contributors
6  * Copyright (C) 2018-2019 Kevin Eckenhoff
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef OV_CORE_PRINT_H
23 #define OV_CORE_PRINT_H
24 
25 #include <cstdarg>
26 #include <cstdint>
27 #include <cstring>
28 #include <iostream>
29 #include <string>
30 
31 namespace ov_core {
32 
42 class Printer {
43 public:
54  enum PrintLevel { ALL = 0, DEBUG = 1, INFO = 2, WARNING = 3, ERROR = 4, SILENT = 5 };
55 
60  static void setPrintLevel(const std::string &level);
61 
66  static void setPrintLevel(PrintLevel level);
67 
75  static void debugPrint(PrintLevel level, const char location[], const char line[], const char *format, ...);
76 
79 
80 private:
82  static constexpr uint32_t MAX_FILE_PATH_LEGTH = 30;
83 };
84 
85 } /* namespace ov_core */
86 
87 /*
88  * Converts anything to a string
89  */
90 #define STRINGIFY(x) #x
91 #define TOSTRING(x) STRINGIFY(x)
92 
93 /*
94  * The different Types of print levels
95  */
96 #define PRINT_ALL(x...) ov_core::Printer::debugPrint(ov_core::Printer::PrintLevel::ALL, __FILE__, TOSTRING(__LINE__), x);
97 #define PRINT_DEBUG(x...) ov_core::Printer::debugPrint(ov_core::Printer::PrintLevel::DEBUG, __FILE__, TOSTRING(__LINE__), x);
98 #define PRINT_INFO(x...) ov_core::Printer::debugPrint(ov_core::Printer::PrintLevel::INFO, __FILE__, TOSTRING(__LINE__), x);
99 #define PRINT_WARNING(x...) ov_core::Printer::debugPrint(ov_core::Printer::PrintLevel::WARNING, __FILE__, TOSTRING(__LINE__), x);
100 #define PRINT_ERROR(x...) ov_core::Printer::debugPrint(ov_core::Printer::PrintLevel::ERROR, __FILE__, TOSTRING(__LINE__), x);
101 
102 #endif /* OV_CORE_PRINT_H */
ov_core::Printer::PrintLevel
PrintLevel
The different print levels possible.
Definition: print.h:54
ov_core::Printer::debugPrint
static void debugPrint(PrintLevel level, const char location[], const char line[], const char *format,...)
The print function that prints to stdout.
Definition: print.cpp:80
ov_core::Printer::SILENT
@ SILENT
Definition: print.h:54
ov_core::Printer
Printer for open_vins that allows for various levels of printing to be done.
Definition: print.h:42
ov_core::Printer::current_print_level
static PrintLevel current_print_level
The current print level.
Definition: print.h:78
ov_core::Printer::setPrintLevel
static void setPrintLevel(const std::string &level)
Set the print level to use for all future printing to stdout.
Definition: print.cpp:29
ov_core::Printer::ALL
@ ALL
Definition: print.h:54
ov_core::Printer::ERROR
@ ERROR
Definition: print.h:54
ov_core::Printer::WARNING
@ WARNING
Definition: print.h:54
ov_core::Printer::MAX_FILE_PATH_LEGTH
static constexpr uint32_t MAX_FILE_PATH_LEGTH
The max length for the file path. This is to avoid very long file paths from.
Definition: print.h:82
ov_core::Printer::DEBUG
@ DEBUG
Definition: print.h:54
ov_core
Core algorithms for OpenVINS.
Definition: CamBase.h:30
ov_core::Printer::INFO
@ INFO
Definition: print.h:54


ov_core
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Mon Dec 16 2024 03:06:46