VTK  9.3.0
vtkOutputWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
19 #ifndef vtkOutputWindow_h
20 #define vtkOutputWindow_h
21 
22 #include "vtkCommonCoreModule.h" // For export macro
23 #include "vtkDebugLeaksManager.h" // Must be included before singletons
24 #include "vtkDeprecation.h" // For `VTK_DEPRECATED_IN_9_3_0`
25 #include "vtkObject.h"
26 
27 VTK_ABI_NAMESPACE_BEGIN
29  "`vtkOutputWindowCleanup` is no longer necessary") VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup
30 {
31 public:
34 
35 private:
36  vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete;
37  vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete;
38 };
39 
40 class vtkOutputWindowPrivateAccessor;
41 class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject
42 {
43 public:
44  // Methods from vtkObject
45  vtkTypeMacro(vtkOutputWindow, vtkObject);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
56  static vtkOutputWindow* New();
57 
66  static void SetInstance(vtkOutputWindow* instance);
67 
69 
76  virtual void DisplayText(const char*);
77  virtual void DisplayErrorText(const char*);
78  virtual void DisplayWarningText(const char*);
79  virtual void DisplayGenericWarningText(const char*);
80  virtual void DisplayDebugText(const char*);
82 
84 
93  vtkBooleanMacro(PromptUser, bool);
94  vtkSetMacro(PromptUser, bool);
96 
98 
123  {
124  DEFAULT = -1,
125  NEVER = 0,
126  ALWAYS = 1,
127  ALWAYS_STDERR = 2
128  };
129  vtkSetClampMacro(DisplayMode, int, DEFAULT, ALWAYS_STDERR);
130  vtkGetMacro(DisplayMode, int);
131  void SetDisplayModeToDefault() { this->SetDisplayMode(vtkOutputWindow::DEFAULT); }
132  void SetDisplayModeToNever() { this->SetDisplayMode(vtkOutputWindow::NEVER); }
133  void SetDisplayModeToAlways() { this->SetDisplayMode(vtkOutputWindow::ALWAYS); }
136 protected:
138  ~vtkOutputWindow() override;
139 
141  {
146  MESSAGE_TYPE_DEBUG
147  };
148 
154  vtkGetMacro(CurrentMessageType, MessageTypes);
155 
156  enum class StreamType
157  {
158  Null,
159  StdOutput,
160  StdError,
161  };
162 
167  virtual StreamType GetDisplayStream(MessageTypes msgType) const;
168 
170 
171 private:
172  std::atomic<MessageTypes> CurrentMessageType;
173  int DisplayMode;
174  std::atomic<int> InStandardMacros; // used to suppress display to output streams from standard
175  // macros when logging is enabled.
176 
177  friend class vtkOutputWindowPrivateAccessor;
178 
179  vtkOutputWindow(const vtkOutputWindow&) = delete;
180  void operator=(const vtkOutputWindow&) = delete;
181 };
182 
183 VTK_ABI_NAMESPACE_END
184 #endif
a simple class to control print indentation
Definition: vtkIndent.h:29
abstract base class for most VTK objects
Definition: vtkObject.h:52
vtkOutputWindowCleanup()=default
~vtkOutputWindowCleanup()=default
base class for writing debug output to a console
virtual void DisplayGenericWarningText(const char *)
Display the text.
void SetDisplayModeToAlways()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
void SetDisplayModeToNever()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
virtual StreamType GetDisplayStream(MessageTypes msgType) const
Returns the standard output stream to post the message of the given type on.
void SetDisplayModeToAlwaysStdErr()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
DisplayModes
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
void PrintSelf(ostream &os, vtkIndent indent) override
Print ObjectFactor to stream.
static vtkOutputWindow * New()
Creates a new instance of vtkOutputWindow.
static vtkOutputWindow * GetInstance()
Return the singleton instance with no reference counting.
void SetDisplayModeToDefault()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
~vtkOutputWindow() override
virtual void DisplayDebugText(const char *)
Display the text.
static void SetInstance(vtkOutputWindow *instance)
Supply a user defined output window.
virtual void DisplayWarningText(const char *)
Display the text.
virtual void DisplayText(const char *)
Display the text.
virtual void DisplayErrorText(const char *)
Display the text.
#define VTK_DEPRECATED_IN_9_3_0(reason)