VTK  9.2.20230324
vtkOutputWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOutputWindow.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
31 #ifndef vtkOutputWindow_h
32 #define vtkOutputWindow_h
33 
34 #include "vtkCommonCoreModule.h" // For export macro
35 #include "vtkDebugLeaksManager.h" // Must be included before singletons
36 #include "vtkDeprecation.h" // For `VTK_DEPRECATED_IN_9_3_0`
37 #include "vtkObject.h"
38 
39 VTK_ABI_NAMESPACE_BEGIN
41  "`vtkOutputWindowCleanup` is no longer necessary") VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup
42 {
43 public:
46 
47 private:
48  vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete;
49  vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete;
50 };
51 
52 class vtkOutputWindowPrivateAccessor;
53 class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject
54 {
55 public:
56  // Methods from vtkObject
57  vtkTypeMacro(vtkOutputWindow, vtkObject);
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
68  static vtkOutputWindow* New();
69 
78  static void SetInstance(vtkOutputWindow* instance);
79 
81 
88  virtual void DisplayText(const char*);
89  virtual void DisplayErrorText(const char*);
90  virtual void DisplayWarningText(const char*);
91  virtual void DisplayGenericWarningText(const char*);
92  virtual void DisplayDebugText(const char*);
94 
96 
105  vtkBooleanMacro(PromptUser, bool);
106  vtkSetMacro(PromptUser, bool);
108 
110 
135  {
136  DEFAULT = -1,
137  NEVER = 0,
138  ALWAYS = 1,
139  ALWAYS_STDERR = 2
140  };
141  vtkSetClampMacro(DisplayMode, int, DEFAULT, ALWAYS_STDERR);
142  vtkGetMacro(DisplayMode, int);
143  void SetDisplayModeToDefault() { this->SetDisplayMode(vtkOutputWindow::DEFAULT); }
144  void SetDisplayModeToNever() { this->SetDisplayMode(vtkOutputWindow::NEVER); }
145  void SetDisplayModeToAlways() { this->SetDisplayMode(vtkOutputWindow::ALWAYS); }
148 protected:
150  ~vtkOutputWindow() override;
151 
153  {
158  MESSAGE_TYPE_DEBUG
159  };
160 
166  vtkGetMacro(CurrentMessageType, MessageTypes);
167 
168  enum class StreamType
169  {
170  Null,
171  StdOutput,
172  StdError,
173  };
174 
179  virtual StreamType GetDisplayStream(MessageTypes msgType) const;
180 
182 
183 private:
184  std::atomic<MessageTypes> CurrentMessageType;
185  int DisplayMode;
186  std::atomic<int> InStandardMacros; // used to suppress display to output streams from standard
187  // macros when logging is enabled.
188 
189  friend class vtkOutputWindowPrivateAccessor;
190 
191 private:
192  vtkOutputWindow(const vtkOutputWindow&) = delete;
193  void operator=(const vtkOutputWindow&) = delete;
194 };
195 
196 VTK_ABI_NAMESPACE_END
197 #endif
a simple class to control print indentation
Definition: vtkIndent.h:120
abstract base class for most VTK objects
Definition: vtkObject.h:83
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)