VTK  9.1.0
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_0_0
37 #include "vtkObject.h"
38 
39 class VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup
40 {
41 public:
44 
45 private:
46  vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete;
47  vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete;
48 };
49 
50 class vtkOutputWindowPrivateAccessor;
51 class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject
52 {
53 public:
54  // Methods from vtkObject
55  vtkTypeMacro(vtkOutputWindow, vtkObject);
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
66  static vtkOutputWindow* New();
67 
76  static void SetInstance(vtkOutputWindow* instance);
77 
79 
86  virtual void DisplayText(const char*);
87  virtual void DisplayErrorText(const char*);
88  virtual void DisplayWarningText(const char*);
89  virtual void DisplayGenericWarningText(const char*);
90  virtual void DisplayDebugText(const char*);
92 
94 
103  vtkBooleanMacro(PromptUser, bool);
104  vtkSetMacro(PromptUser, bool);
106 
108 
117  VTK_DEPRECATED_IN_9_0_0("Use vtkOutputWindow::SetDisplayMode")
118  void SetUseStdErrorForAllMessages(bool);
119  VTK_DEPRECATED_IN_9_0_0("Use vtkOutputWindow::GetDisplayMode")
120  bool GetUseStdErrorForAllMessages();
121  VTK_DEPRECATED_IN_9_0_0("Use vtkOutputWindow::SetDisplayMode")
122  void UseStdErrorForAllMessagesOn();
123  VTK_DEPRECATED_IN_9_0_0("Use vtkOutputWindow::SetDisplayMode")
124  void UseStdErrorForAllMessagesOff();
126 
128 
153  {
154  DEFAULT = -1,
155  NEVER = 0,
156  ALWAYS = 1,
157  ALWAYS_STDERR = 2
158  };
159  vtkSetClampMacro(DisplayMode, int, DEFAULT, ALWAYS_STDERR);
160  vtkGetMacro(DisplayMode, int);
161  void SetDisplayModeToDefault() { this->SetDisplayMode(vtkOutputWindow::DEFAULT); }
162  void SetDisplayModeToNever() { this->SetDisplayMode(vtkOutputWindow::NEVER); }
163  void SetDisplayModeToAlways() { this->SetDisplayMode(vtkOutputWindow::ALWAYS); }
166 protected:
168  ~vtkOutputWindow() override;
169 
171  {
176  MESSAGE_TYPE_DEBUG
177  };
178 
184  vtkGetMacro(CurrentMessageType, MessageTypes);
185 
186  enum class StreamType
187  {
188  Null,
189  StdOutput,
190  StdError,
191  };
192 
197  virtual StreamType GetDisplayStream(MessageTypes msgType) const;
198 
200 
201 private:
202  static vtkOutputWindow* Instance;
203  MessageTypes CurrentMessageType;
204  int DisplayMode;
205  int InStandardMacros; // used to suppress display to output streams from standard macros when
206  // logging is enabled.
207 
208  friend class vtkOutputWindowPrivateAccessor;
209 
210 private:
211  vtkOutputWindow(const vtkOutputWindow&) = delete;
212  void operator=(const vtkOutputWindow&) = delete;
213 };
214 
215 // Uses schwartz counter idiom for singleton management
217 
218 #endif
vtkOutputWindow::StreamType
StreamType
Definition: vtkOutputWindow.h:187
vtkOutputWindowCleanup::vtkOutputWindowCleanup
vtkOutputWindowCleanup()
vtkOutputWindow::MessageTypes
MessageTypes
Definition: vtkOutputWindow.h:171
vtkOutputWindow::SetDisplayModeToAlways
void SetDisplayModeToAlways()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
Definition: vtkOutputWindow.h:163
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkOutputWindow::GetDisplayStream
virtual StreamType GetDisplayStream(MessageTypes msgType) const
Returns the standard output stream to post the message of the given type on.
vtkOutputWindow::vtkOutputWindow
vtkOutputWindow()
vtkOutputWindow::SetDisplayModeToAlwaysStdErr
void SetDisplayModeToAlwaysStdErr()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
Definition: vtkOutputWindow.h:164
vtkOutputWindowCleanupInstance
static vtkOutputWindowCleanup vtkOutputWindowCleanupInstance
Definition: vtkOutputWindow.h:216
vtkOutputWindow::New
static vtkOutputWindow * New()
Creates a new instance of vtkOutputWindow.
vtkOutputWindow::GetInstance
static vtkOutputWindow * GetInstance()
Return the singleton instance with no reference counting.
vtkDebugLeaksManager.h
vtkOutputWindow::SetDisplayModeToNever
void SetDisplayModeToNever()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
Definition: vtkOutputWindow.h:162
vtkOutputWindow::SetInstance
static void SetInstance(vtkOutputWindow *instance)
Supply a user defined output window.
vtkOutputWindow::DisplayDebugText
virtual void DisplayDebugText(const char *)
Display the text.
vtkOutputWindow::MESSAGE_TYPE_ERROR
@ MESSAGE_TYPE_ERROR
Definition: vtkOutputWindow.h:173
vtkOutputWindow
base class for writing debug output to a console
Definition: vtkOutputWindow.h:52
vtkOutputWindow::NEVER
@ NEVER
Definition: vtkOutputWindow.h:155
vtkOutputWindow::DisplayText
virtual void DisplayText(const char *)
Display the text.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
VTK_DEPRECATED_IN_9_0_0
#define VTK_DEPRECATED_IN_9_0_0(reason)
Definition: vtkDeprecation.h:126
vtkOutputWindow::ALWAYS
@ ALWAYS
Definition: vtkOutputWindow.h:156
vtkOutputWindow::PromptUser
bool PromptUser
Definition: vtkOutputWindow.h:199
vtkOutputWindow::ALWAYS_STDERR
@ ALWAYS_STDERR
Definition: vtkOutputWindow.h:157
vtkOutputWindow::DisplayGenericWarningText
virtual void DisplayGenericWarningText(const char *)
Display the text.
vtkOutputWindowCleanup
Definition: vtkOutputWindow.h:40
vtkObject.h
vtkOutputWindow::MESSAGE_TYPE_GENERIC_WARNING
@ MESSAGE_TYPE_GENERIC_WARNING
Definition: vtkOutputWindow.h:175
vtkOutputWindow::MESSAGE_TYPE_TEXT
@ MESSAGE_TYPE_TEXT
Definition: vtkOutputWindow.h:172
vtkDeprecation.h
vtkOutputWindow::~vtkOutputWindow
~vtkOutputWindow() override
vtkOutputWindow::SetDisplayModeToDefault
void SetDisplayModeToDefault()
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
Definition: vtkOutputWindow.h:161
vtkOutputWindow::DEFAULT
@ DEFAULT
Definition: vtkOutputWindow.h:154
vtkOutputWindowCleanup::~vtkOutputWindowCleanup
~vtkOutputWindowCleanup()
vtkOutputWindow::DisplayWarningText
virtual void DisplayWarningText(const char *)
Display the text.
vtkOutputWindow::MESSAGE_TYPE_WARNING
@ MESSAGE_TYPE_WARNING
Definition: vtkOutputWindow.h:174
vtkOutputWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Print ObjectFactor to stream.
vtkOutputWindow::DisplayModes
DisplayModes
Flag indicates how the vtkOutputWindow handles displaying of text to stderr / stdout.
Definition: vtkOutputWindow.h:153
vtkOutputWindow::DisplayErrorText
virtual void DisplayErrorText(const char *)
Display the text.