VTK  9.0.1
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
vtkOutputWindow::StreamType
StreamType
Definition: vtkOutputWindow.h:176
vtkOutputWindowCleanup::vtkOutputWindowCleanup
vtkOutputWindowCleanup()
vtkOutputWindow::MessageTypes
MessageTypes
Definition: vtkOutputWindow.h:160
vtkOutputWindow::SetDisplayModeToAlways
void SetDisplayModeToAlways()
Definition: vtkOutputWindow.h:152
vtkOutputWindow::GetUseStdErrorForAllMessages
bool GetUseStdErrorForAllMessages()
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
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()
Definition: vtkOutputWindow.h:153
vtkOutputWindowCleanupInstance
static vtkOutputWindowCleanup vtkOutputWindowCleanupInstance
Definition: vtkOutputWindow.h:205
vtkOutputWindow::New
static vtkOutputWindow * New()
Creates a new instance of vtkOutputWindow.
vtkOutputWindow::GetInstance
static vtkOutputWindow * GetInstance()
Return the singleton instance with no reference counting.
vtkOutputWindow::SetUseStdErrorForAllMessages
void SetUseStdErrorForAllMessages(bool)
Historically (VTK 8.1 and earlier), when printing messages to terminals, vtkOutputWindow would always...
vtkDebugLeaksManager.h
vtkOutputWindow::SetDisplayModeToNever
void SetDisplayModeToNever()
Definition: vtkOutputWindow.h:151
vtkOutputWindow::SetInstance
static void SetInstance(vtkOutputWindow *instance)
Supply a user defined output window.
vtkOutputWindow::DisplayDebugText
virtual void DisplayDebugText(const char *)
vtkOutputWindow::MESSAGE_TYPE_ERROR
@ MESSAGE_TYPE_ERROR
Definition: vtkOutputWindow.h:162
vtkOutputWindow
base class for writing debug output to a console
Definition: vtkOutputWindow.h:45
vtkOutputWindow::NEVER
@ NEVER
Definition: vtkOutputWindow.h:144
vtkOutputWindow::DisplayText
virtual void DisplayText(const char *)
Display the text.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkOutputWindow::ALWAYS
@ ALWAYS
Definition: vtkOutputWindow.h:145
vtkOutputWindow::UseStdErrorForAllMessagesOn
void UseStdErrorForAllMessagesOn()
vtkOutputWindow::PromptUser
bool PromptUser
Definition: vtkOutputWindow.h:188
vtkOutputWindow::ALWAYS_STDERR
@ ALWAYS_STDERR
Definition: vtkOutputWindow.h:146
vtkOutputWindow::DisplayGenericWarningText
virtual void DisplayGenericWarningText(const char *)
vtkOutputWindowCleanup
Definition: vtkOutputWindow.h:33
vtkObject.h
vtkOutputWindow::MESSAGE_TYPE_GENERIC_WARNING
@ MESSAGE_TYPE_GENERIC_WARNING
Definition: vtkOutputWindow.h:164
vtkOutputWindow::MESSAGE_TYPE_TEXT
@ MESSAGE_TYPE_TEXT
Definition: vtkOutputWindow.h:161
vtkOutputWindow::~vtkOutputWindow
~vtkOutputWindow() override
vtkOutputWindow::SetDisplayModeToDefault
void SetDisplayModeToDefault()
Definition: vtkOutputWindow.h:150
vtkOutputWindow::DEFAULT
@ DEFAULT
Definition: vtkOutputWindow.h:143
vtkOutputWindowCleanup::~vtkOutputWindowCleanup
~vtkOutputWindowCleanup()
vtkOutputWindow::DisplayWarningText
virtual void DisplayWarningText(const char *)
vtkOutputWindow::MESSAGE_TYPE_WARNING
@ MESSAGE_TYPE_WARNING
Definition: vtkOutputWindow.h:163
vtkOutputWindow::UseStdErrorForAllMessagesOff
void UseStdErrorForAllMessagesOff()
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:142
vtkOutputWindow::DisplayErrorText
virtual void DisplayErrorText(const char *)