1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
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 itkXMLFileOutputWindow_h
19 #define itkXMLFileOutputWindow_h
20 
21 #include "itkFileOutputWindow.h"
22 
23 namespace itk
24 {
25 /** \class XMLFileOutputWindow
26  * \brief Messages sent from the system are sent to a file with each message
27  *        enclosed by XML tags.
28  *
29  * Writes debug/warning/error output to an XML file.  Uses predefined XML
30  * tags for each text display method.  The text is processed to replace
31  * XML markup characters.
32  *
33  *   DisplayText - \<Text\>
34  *
35  *   DisplayErrorText - \<Error\>
36  *
37  *   DisplayWarningText - \<Warning\>
38  *
39  *   DisplayGenericOutputText - \<GenericOutput\>
40  *
41  *   DisplayDebugText - \<Debug\>
42  *
43  * The method DisplayTag outputs the text unprocessed.  To use this
44  * class, instantiate it and then call SetInstance(this).
45  *
46  * \ingroup OSSystemObjects
47  * \ingroup ITKCommon
48  */
49 class ITKCommon_EXPORT XMLFileOutputWindow:public FileOutputWindow
50 {
51 public:
52   ITK_DISALLOW_COPY_AND_ASSIGN(XMLFileOutputWindow);
53 
54   /** Standard class type aliases. */
55   using Self = XMLFileOutputWindow;
56   using Superclass = FileOutputWindow;
57   using Pointer = SmartPointer< Self >;
58   using ConstPointer = SmartPointer< const Self >;
59 
60   /** Method for creation through the object factory. */
61   itkNewMacro(Self);
62 
63   /** Run-time type information (and related methods). */
64   itkTypeMacro(XMLFileOutputWindow, FileOutputWindow);
65 
66   /** Send a string to the XML file. */
67   void DisplayText(const char *) override;
68 
69   /** Send an error string to the XML file. */
70   void DisplayErrorText(const char *) override;
71 
72   /** Send a warning string to the XML file. */
73   void DisplayWarningText(const char *) override;
74 
75   /** Send a generic output string to the XML file. */
76   void DisplayGenericOutputText(const char *) override;
77 
78   /** Send a debug string to the XML file. */
79   void DisplayDebugText(const char *) override;
80 
81   /**  Put the text into the log file without processing it. */
82   virtual void DisplayTag(const char *);
83 
84 protected:
85   XMLFileOutputWindow();
86   ~XMLFileOutputWindow() override;
87   void PrintSelf(std::ostream & os, Indent indent) const override;
88 
89   void Initialize();
90 
91   virtual void DisplayXML(const char *, const char *);
92 };
93 } // end namespace itk
94 
95 #endif
96