VTK  9.2.20220816
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 
40  "`vtkOutputWindowCleanup` is no longer necessary") VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup
41 {
42 public:
45 
46 private:
47  vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete;
48  vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete;
49 };
50 
51 class vtkOutputWindowPrivateAccessor;
52 class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject
53 {
54 public:
55  // Methods from vtkObject
56  vtkTypeMacro(vtkOutputWindow, vtkObject);
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
67  static vtkOutputWindow* New();
68 
77  static void SetInstance(vtkOutputWindow* instance);
78 
80 
87  virtual void DisplayText(const char*);
88  virtual void DisplayErrorText(const char*);
89  virtual void DisplayWarningText(const char*);
90  virtual void DisplayGenericWarningText(const char*);
91  virtual void DisplayDebugText(const char*);
93 
95 
104  vtkBooleanMacro(PromptUser, bool);
105  vtkSetMacro(PromptUser, bool);
107 
109 
134  {
135  DEFAULT = -1,
136  NEVER = 0,
137  ALWAYS = 1,
138  ALWAYS_STDERR = 2
139  };
140  vtkSetClampMacro(DisplayMode, int, DEFAULT, ALWAYS_STDERR);
141  vtkGetMacro(DisplayMode, int);
142  void SetDisplayModeToDefault() { this->SetDisplayMode(vtkOutputWindow::DEFAULT); }
143  void SetDisplayModeToNever() { this->SetDisplayMode(vtkOutputWindow::NEVER); }
144  void SetDisplayModeToAlways() { this->SetDisplayMode(vtkOutputWindow::ALWAYS); }
147 protected:
149  ~vtkOutputWindow() override;
150 
152  {
157  MESSAGE_TYPE_DEBUG
158  };
159 
165  vtkGetMacro(CurrentMessageType, MessageTypes);
166 
167  enum class StreamType
168  {
169  Null,
170  StdOutput,
171  StdError,
172  };
173 
178  virtual StreamType GetDisplayStream(MessageTypes msgType) const;
179 
181 
182 private:
183  std::atomic<MessageTypes> CurrentMessageType;
184  int DisplayMode;
185  std::atomic<int> InStandardMacros; // used to suppress display to output streams from standard
186  // macros when logging is enabled.
187 
188  friend class vtkOutputWindowPrivateAccessor;
189 
190 private:
191  vtkOutputWindow(const vtkOutputWindow&) = delete;
192  void operator=(const vtkOutputWindow&) = delete;
193 };
194 
195 #endif
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
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)