OpenMS
Loading...
Searching...
No Matches
ProgressLogger.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg$
6// $Authors: Marc Sturm, Stephan Aiche $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12#include <atomic>
13#include <string>
14
15namespace OpenMS
16{
17
27 class OPENMS_DLLAPI ProgressLogger
28 {
29public:
32
34 virtual ~ProgressLogger();
35
38
41
44 {
47 NONE
48 };
49
53 class OPENMS_DLLAPI ProgressLoggerImpl
54 {
55public:
56 virtual void startProgress(const SignedSize begin, const SignedSize end, const std::string& label, const int current_recursion_depth) const = 0;
57 virtual void setProgress(const SignedSize value, const int current_recursion_depth) const = 0;
58 virtual SignedSize nextProgress() const = 0; //< does not print/show anything; returns current progress
61 virtual void endProgress(const int current_recursion_depth, UInt64 bytes_processed = 0) const = 0;
62
64
66
67
68 };
69
71 void setLogType(LogType type) const;
72
75
79
91 void startProgress(SignedSize begin, SignedSize end, const std::string& label) const;
92
94 void setProgress(SignedSize value) const;
95
98 void endProgress(UInt64 bytes_processed = 0) const;
99
101 void nextProgress() const;
102
103protected:
104 mutable LogType type_;
105 mutable time_t last_invoke_;
108 static std::atomic<int> recursion_depth_;
109
111
112 };
113
114 // Function pointer for injecting the GUI progress logger implementation
115 typedef ProgressLogger::ProgressLoggerImpl* (*MakeGUIProgressLoggerFunc)();
117
118} // namespace OpenMS
119
This class represents an actual implementation of a logger.
Definition ProgressLogger.h:54
virtual void setProgress(const SignedSize value, const int current_recursion_depth) const =0
virtual SignedSize nextProgress() const =0
virtual void endProgress(const int current_recursion_depth, UInt64 bytes_processed=0) const =0
virtual ~ProgressLoggerImpl()
Definition ProgressLogger.h:63
virtual void startProgress(const SignedSize begin, const SignedSize end, const std::string &label, const int current_recursion_depth) const =0
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:28
void setProgress(SignedSize value) const
Sets the current progress.
void setLogger(ProgressLoggerImpl *logger)
Sets the logger to be used for progress logging.
static std::atomic< int > recursion_depth_
Definition ProgressLogger.h:108
ProgressLogger()
Constructor.
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
ProgressLogger(const ProgressLogger &other)
Copy constructor.
time_t last_invoke_
Definition ProgressLogger.h:105
LogType type_
Definition ProgressLogger.h:104
void endProgress(UInt64 bytes_processed=0) const
void startProgress(SignedSize begin, SignedSize end, const std::string &label) const
Initializes the progress display.
ProgressLogger & operator=(const ProgressLogger &other)
Assignment Operator.
virtual ~ProgressLogger()
Destructor.
ProgressLoggerImpl * current_logger_
Definition ProgressLogger.h:110
LogType getLogType() const
Returns the type of progress log being used.
void nextProgress() const
increment progress by 1 (according to range begin-end)
LogType
Possible log types.
Definition ProgressLogger.h:44
@ CMD
Command line progress.
Definition ProgressLogger.h:45
@ GUI
Progress dialog.
Definition ProgressLogger.h:46
uint64_t UInt64
Unsigned integer type (64bit)
Definition Types.h:47
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition Types.h:104
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
MakeGUIProgressLoggerFunc make_gui_progress_logger
ProgressLogger::ProgressLoggerImpl *(* MakeGUIProgressLoggerFunc)()
Definition ProgressLogger.h:115