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
28 #ifndef vtkOutputWindow_h
29 #define vtkOutputWindow_h
30 
31 #include "vtkCommonCoreModule.h" // For export macro
32 #include "vtkDebugLeaksManager.h" // Must be included before singletons
33 #include "vtkDeprecation.h" // For `VTK_DEPRECATED_IN_9_3_0`
34 #include "vtkObject.h"
35 
36 VTK_ABI_NAMESPACE_BEGIN
38  "`vtkOutputWindowCleanup` is no longer necessary") VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup
39 {
40 public:
43 
44 private:
45  vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete;
46  vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete;
47 };
48 
49 class vtkOutputWindowPrivateAccessor;
50 class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject
51 {
52 public:
53  // Methods from vtkObject
54  vtkTypeMacro(vtkOutputWindow, vtkObject);
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
65  static vtkOutputWindow* New();
66 
75  static void SetInstance(vtkOutputWindow* instance);
76 
78 
85  virtual void DisplayText(const char*);
86  virtual void DisplayErrorText(const char*);
87  virtual void DisplayWarningText(const char*);
88  virtual void DisplayGenericWarningText(const char*);
89  virtual void DisplayDebugText(const char*);
91 
93 
102  vtkBooleanMacro(PromptUser, bool);
103  vtkSetMacro(PromptUser, bool);
105 
107 
132  {
133  DEFAULT = -1,
134  NEVER = 0,
135  ALWAYS = 1,
136  ALWAYS_STDERR = 2
137  };
138  vtkSetClampMacro(DisplayMode, int, DEFAULT, ALWAYS_STDERR);
139  vtkGetMacro(DisplayMode, int);
140  void SetDisplayModeToDefault() { this->SetDisplayMode(vtkOutputWindow::DEFAULT); }
141  void SetDisplayModeToNever() { this->SetDisplayMode(vtkOutputWindow::NEVER); }
142  void SetDisplayModeToAlways() { this->SetDisplayMode(vtkOutputWindow::ALWAYS); }
145 protected:
147  ~vtkOutputWindow() override;
148 
150  {
155  MESSAGE_TYPE_DEBUG
156  };
157 
163  vtkGetMacro(CurrentMessageType, MessageTypes);
164 
165  enum class StreamType
166  {
167  Null,
168  StdOutput,
169  StdError,
170  };
171 
176  virtual StreamType GetDisplayStream(MessageTypes msgType) const;
177 
179 
180 private:
181  std::atomic<MessageTypes> CurrentMessageType;
182  int DisplayMode;
183  std::atomic<int> InStandardMacros; // used to suppress display to output streams from standard
184  // macros when logging is enabled.
185 
186  friend class vtkOutputWindowPrivateAccessor;
187 
188  vtkOutputWindow(const vtkOutputWindow&) = delete;
189  void operator=(const vtkOutputWindow&) = delete;
190 };
191 
192 VTK_ABI_NAMESPACE_END
193 #endif
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
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)