VTK  9.2.6
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 =========================================================================*/
40 #ifndef vtkOutputWindow_h
41 #define vtkOutputWindow_h
42 
43 #include "vtkCommonCoreModule.h" // For export macro
44 #include "vtkDebugLeaksManager.h" // Must be included before singletons
45 #include "vtkObject.h"
46 
47 class VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup
48 {
49 public:
52 
53 private:
54  vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete;
55  vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete;
56 };
57 
58 class vtkOutputWindowPrivateAccessor;
59 class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject
60 {
61 public:
62  // Methods from vtkObject
63  vtkTypeMacro(vtkOutputWindow, vtkObject);
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
74  static vtkOutputWindow* New();
75 
84  static void SetInstance(vtkOutputWindow* instance);
85 
87 
94  virtual void DisplayText(const char*);
95  virtual void DisplayErrorText(const char*);
96  virtual void DisplayWarningText(const char*);
97  virtual void DisplayGenericWarningText(const char*);
98  virtual void DisplayDebugText(const char*);
100 
102 
111  vtkBooleanMacro(PromptUser, bool);
112  vtkSetMacro(PromptUser, bool);
114 
116 
141  {
142  DEFAULT = -1,
143  NEVER = 0,
144  ALWAYS = 1,
145  ALWAYS_STDERR = 2
146  };
147  vtkSetClampMacro(DisplayMode, int, DEFAULT, ALWAYS_STDERR);
148  vtkGetMacro(DisplayMode, int);
149  void SetDisplayModeToDefault() { this->SetDisplayMode(vtkOutputWindow::DEFAULT); }
150  void SetDisplayModeToNever() { this->SetDisplayMode(vtkOutputWindow::NEVER); }
151  void SetDisplayModeToAlways() { this->SetDisplayMode(vtkOutputWindow::ALWAYS); }
154 protected:
156  ~vtkOutputWindow() override;
157 
159  {
164  MESSAGE_TYPE_DEBUG
165  };
166 
172  vtkGetMacro(CurrentMessageType, MessageTypes);
173 
174  enum class StreamType
175  {
176  Null,
177  StdOutput,
178  StdError,
179  };
180 
185  virtual StreamType GetDisplayStream(MessageTypes msgType) const;
186 
188 
189 private:
190  static vtkOutputWindow* Instance;
191  MessageTypes CurrentMessageType;
192  int DisplayMode;
193  int InStandardMacros; // used to suppress display to output streams from standard macros when
194  // logging is enabled.
195 
196  friend class vtkOutputWindowPrivateAccessor;
197 
198 private:
199  vtkOutputWindow(const vtkOutputWindow&) = delete;
200  void operator=(const vtkOutputWindow&) = delete;
201 };
202 
203 // Uses schwartz counter idiom for singleton management
205 
206 #endif
a simple class to control print indentation
Definition: vtkIndent.h:49
abstract base class for most VTK objects
Definition: vtkObject.h:72
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.
static vtkOutputWindowCleanup vtkOutputWindowCleanupInstance