OpenMS
ProgressLogger.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- 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 
11 #include <OpenMS/CONCEPT/Types.h>
12 
13 namespace OpenMS
14 {
15  class String;
16 
26  class OPENMS_DLLAPI ProgressLogger
27  {
28 public:
31 
33  virtual ~ProgressLogger();
34 
37 
40 
42  enum LogType
43  {
44  CMD,
45  GUI,
46  NONE
47  };
48 
52  class OPENMS_DLLAPI ProgressLoggerImpl
53  {
54 public:
55  virtual void startProgress(const SignedSize begin, const SignedSize end, const String& label, const int current_recursion_depth) const = 0;
56  virtual void setProgress(const SignedSize value, const int current_recursion_depth) const = 0;
57  virtual SignedSize nextProgress() const = 0; //< does not print/show anything; returns current progress
60  virtual void endProgress(const int current_recursion_depth, UInt64 bytes_processed = 0) const = 0;
61 
62  virtual ~ProgressLoggerImpl() {}
63 
65 
66 
67  };
68 
70  void setLogType(LogType type) const;
71 
74 
78 
90  void startProgress(SignedSize begin, SignedSize end, const String& label) const;
91 
93  void setProgress(SignedSize value) const;
94 
97  void endProgress(UInt64 bytes_processed = 0) const;
98 
100  void nextProgress() const;
101 
102 protected:
103  mutable LogType type_;
104  mutable time_t last_invoke_;
105  static int recursion_depth_;
106 
108 
109  };
110 
111  // Function pointer for injecting the GUI progress logger implementation
112  typedef ProgressLogger::ProgressLoggerImpl* (*MakeGUIProgressLoggerFunc)();
114 
115 } // namespace OpenMS
116 
This class represents an actual implementation of a logger.
Definition: ProgressLogger.h:53
virtual void setProgress(const SignedSize value, const int current_recursion_depth) const =0
virtual void startProgress(const SignedSize begin, const SignedSize end, const String &label, 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:62
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
void setProgress(SignedSize value) const
Sets the current progress.
ProgressLogger & operator=(const ProgressLogger &other)
Assignment Operator.
void setLogger(ProgressLoggerImpl *logger)
Sets the logger to be used for progress logging.
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.
void startProgress(SignedSize begin, SignedSize end, const String &label) const
Initializes the progress display.
time_t last_invoke_
Definition: ProgressLogger.h:104
LogType type_
Definition: ProgressLogger.h:103
void endProgress(UInt64 bytes_processed=0) const
static int recursion_depth_
Definition: ProgressLogger.h:105
virtual ~ProgressLogger()
Destructor.
ProgressLoggerImpl * current_logger_
Definition: ProgressLogger.h:107
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:43
@ CMD
Command line progress.
Definition: ProgressLogger.h:44
@ GUI
Progress dialog.
Definition: ProgressLogger.h:45
A more convenient string class.
Definition: String.h:34
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:112