SimpleITK  
sitkLogger.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef sitkLogger_h
19 #define sitkLogger_h
20 
21 
22 #include "sitkCommon.h"
23 #include "sitkObjectOwnedBase.h"
24 
25 #include <map>
26 
27 
28 namespace itk
29 {
30 
31 class OutputWindow;
32 
33 namespace simple
34 {
35 
36 class ITKLogger;
37 
49 {
50 public:
51  LoggerBase() = default;
52 
53  ~LoggerBase() override;
54 
55  virtual void
56  DisplayText(const char * t)
57 #ifndef SWIGR
58  = 0
59 #endif
60  ;
61 
62  virtual void
63  DisplayErrorText(const char * t);
64 
65  virtual void
66  DisplayWarningText(const char * t);
67 
68  virtual void
69  DisplayGenericOutputText(const char * t);
70 
71  virtual void
72  DisplayDebugText(const char * t);
73 
74  std::string
75  GetName() const override;
76  void
77  SetName(const std::string & n) override;
78 
87  virtual ITKLogger
88  SetAsGlobalITKLogger();
89 
94  static ITKLogger
95  GetGlobalITKLogger();
96 };
97 
98 #if defined(SWIG)
99 # define SITK_FINAL
100 #else
101 # define SITK_FINAL final
102 #endif
103 
110 class SITKCommon_EXPORT ITKLogger SITK_FINAL : public LoggerBase
111 {
112 public:
113  explicit ITKLogger(itk::OutputWindow *);
114  ~ITKLogger() override;
115 
116  ITKLogger() = default;
117  ITKLogger(const ITKLogger &);
118  ITKLogger & operator=(ITKLogger);
119 
120  void
121  DisplayText(const char * t) override;
122 
123  void
124  DisplayErrorText(const char * t) override;
125 
126  void
127  DisplayWarningText(const char * t) override;
128 
129  void
130  DisplayGenericOutputText(const char * t) override;
131 
132  void
133  DisplayDebugText(const char * t) override;
134 
141  ITKLogger
142  SetAsGlobalITKLogger() override;
143 
144 
145 private:
146  itk::OutputWindow * m_OutputWindow{ nullptr };
147 };
148 
149 } // namespace simple
150 } // namespace itk
151 
152 #endif
itk::simple::SITK_FINAL
Definition: sitkLogger.h:110
sitkCommon.h
itk::OutputWindow
sitkObjectOwnedBase.h
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::LoggerBase
A base class to handle SimpleITK and ITK messages and logging.
Definition: sitkLogger.h:48
itk
itk::simple::ObjectOwnedBase
An abstract base class to connect this object with the lifetime of another.
Definition: sitkObjectOwnedBase.h:47