VTK  9.0.3
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 =========================================================================*/
25 #ifndef vtkOutputWindow_h
26 #define vtkOutputWindow_h
27 
28 #include "vtkCommonCoreModule.h" // For export macro
29 #include "vtkDebugLeaksManager.h" // Must be included before singletons
30 #include "vtkObject.h"
31 
32 class VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup
33 {
34 public:
37 
38 private:
39  vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete;
40  vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete;
41 };
42 
43 class vtkOutputWindowPrivateAccessor;
44 class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject
45 {
46 public:
47  // Methods from vtkObject
48  vtkTypeMacro(vtkOutputWindow, vtkObject);
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
59  static vtkOutputWindow* New();
60 
69  static void SetInstance(vtkOutputWindow* instance);
70 
72 
79  virtual void DisplayText(const char*);
80  virtual void DisplayErrorText(const char*);
81  virtual void DisplayWarningText(const char*);
82  virtual void DisplayGenericWarningText(const char*);
83  virtual void DisplayDebugText(const char*);
85 
87 
96  vtkBooleanMacro(PromptUser, bool);
97  vtkSetMacro(PromptUser, bool);
99 
101 
110  VTK_LEGACY(void SetUseStdErrorForAllMessages(bool));
111  VTK_LEGACY(bool GetUseStdErrorForAllMessages());
112  VTK_LEGACY(void UseStdErrorForAllMessagesOn());
113  VTK_LEGACY(void UseStdErrorForAllMessagesOff());
115 
117 
142  {
143  DEFAULT = -1,
144  NEVER = 0,
145  ALWAYS = 1,
146  ALWAYS_STDERR = 2
147  };
148  vtkSetClampMacro(DisplayMode, int, DEFAULT, ALWAYS_STDERR);
149  vtkGetMacro(DisplayMode, int);
150  void SetDisplayModeToDefault() { this->SetDisplayMode(vtkOutputWindow::DEFAULT); }
151  void SetDisplayModeToNever() { this->SetDisplayMode(vtkOutputWindow::NEVER); }
152  void SetDisplayModeToAlways() { this->SetDisplayMode(vtkOutputWindow::ALWAYS); }
155 protected:
157  ~vtkOutputWindow() override;
158 
160  {
165  MESSAGE_TYPE_DEBUG
166  };
167 
173  vtkGetMacro(CurrentMessageType, MessageTypes);
174 
175  enum class StreamType
176  {
177  Null,
178  StdOutput,
179  StdError,
180  };
181 
186  virtual StreamType GetDisplayStream(MessageTypes msgType) const;
187 
189 
190 private:
191  static vtkOutputWindow* Instance;
192  MessageTypes CurrentMessageType;
193  int DisplayMode;
194  int InStandardMacros; // used to suppress display to output streams from standard macros when
195  // logging is enabled.
196 
197  friend class vtkOutputWindowPrivateAccessor;
198 
199 private:
200  vtkOutputWindow(const vtkOutputWindow&) = delete;
201  void operator=(const vtkOutputWindow&) = delete;
202 };
203 
204 // Uses schwartz counter idiom for singleton management
206 
207 #endif
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:54
base class for writing debug output to a console
virtual void DisplayGenericWarningText(const char *)
void SetDisplayModeToAlways()
void SetDisplayModeToNever()
virtual StreamType GetDisplayStream(MessageTypes msgType) const
Returns the standard output stream to post the message of the given type on.
void SetDisplayModeToAlwaysStdErr()
bool GetUseStdErrorForAllMessages()
DisplayModes
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
void SetUseStdErrorForAllMessages(bool)
Historically (VTK 8.1 and earlier), when printing messages to terminals, vtkOutputWindow would always...
void PrintSelf(ostream &os, vtkIndent indent) override
Print ObjectFactor to stream.
static vtkOutputWindow * New()
Creates a new instance of vtkOutputWindow.
void UseStdErrorForAllMessagesOn()
static vtkOutputWindow * GetInstance()
Return the singleton instance with no reference counting.
void SetDisplayModeToDefault()
~vtkOutputWindow() override
void UseStdErrorForAllMessagesOff()
virtual void DisplayDebugText(const char *)
static void SetInstance(vtkOutputWindow *instance)
Supply a user defined output window.
virtual void DisplayWarningText(const char *)
virtual void DisplayText(const char *)
Display the text.
virtual void DisplayErrorText(const char *)
static vtkOutputWindowCleanup vtkOutputWindowCleanupInstance