Visual Computing Library
Loading...
Searching...
No Matches
logger.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_CONCEPTS_LOGGER_H
24#define VCL_CONCEPTS_LOGGER_H
25
26#include <vclib/concepts/const_correctness.h>
27#include <vclib/types.h>
28
29#include <string>
30
31namespace vcl {
32
45template<typename T>
46concept LoggerConcept = requires (
47 T&& obj,
48 std::string str,
49 uint n,
50 typename RemoveRef<T>::LogLevel lvl) {
51 // inner types
52 typename RemoveRef<T>::LogLevel;
53
54 { obj.time() } -> std::same_as<double>;
55 { obj.percentage() } -> std::same_as<double>;
56
57 { obj.log(str) } -> std::same_as<void>;
58 { obj.log(str, lvl) } -> std::same_as<void>;
59
60 // non const requirements
61 requires IsConst<T> || requires {
62 { obj.enableIndentation() } -> std::same_as<void>;
63 { obj.disableIndentation() } -> std::same_as<void>;
64 { obj.enablePrintPercentage() } -> std::same_as<void>;
65 { obj.disablePrintPercentage() } -> std::same_as<void>;
66 { obj.setPrintLevel(lvl) } -> std::same_as<void>;
67 { obj.enablePrintMessageDuringProgress() } -> std::same_as<void>;
68 { obj.disablePrintMessageDuringProgress() } -> std::same_as<void>;
69 { obj.enablePrintTimer() } -> std::same_as<void>;
70 { obj.disablePrintTimer() } -> std::same_as<void>;
71
72 { obj.reset() } -> std::same_as<void>;
73
74 { obj.setMaxLineWidth(n) } -> std::same_as<void>;
75 { obj.startTimer() } -> std::same_as<void>;
76 { obj.stopTimer() } -> std::same_as<void>;
77
78 { obj.startNewTask(double(), double(), str) } -> std::same_as<void>;
79 { obj.endTask(str) } -> std::same_as<void>;
80
81 { obj.setPercentage(n) } -> std::same_as<void>;
82
83 { obj.log(n, str) } -> std::same_as<void>;
84 { obj.log(n, str, lvl) } -> std::same_as<void>;
85
86 { obj.startProgress(str, n) } -> std::same_as<void>;
87 { obj.startProgress(str, n, n) } -> std::same_as<void>;
88 { obj.startProgress(str, n, n, n) } -> std::same_as<void>;
89 { obj.startProgress(str, n, n, n, n) } -> std::same_as<void>;
90 { obj.endProgress() } -> std::same_as<void>;
91 { obj.progress(n) } -> std::same_as<void>;
92 };
93};
94
95} // namespace vcl
96
97#endif // VCL_CONCEPTS_LOGGER_H
The IsConst concept is satisfied if T satisfies one of the following conditions:
Definition const_correctness.h:43
The LoggerConcept is satisfied if the type T is a valid Logger type.
Definition logger.h:46