ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkDOMNodeXMLReader.h
Go to the documentation of this file.
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 
19 #ifndef itkDOMNodeXMLReader_h
20 #define itkDOMNodeXMLReader_h
21 
22 #include "itkDOMNode.h"
23 #include "itkObject.h"
24 #include "ITKIOXMLExport.h"
25 
26 #include <istream>
27 
28 namespace itk
29 {
30 
61 class ITKIOXML_EXPORT DOMNodeXMLReader : public Object
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_ASSIGN(DOMNodeXMLReader);
66 
69  using Superclass = Object;
72 
74  itkNewMacro(Self);
75 
77  itkTypeMacro(DOMNodeXMLReader, Object);
78 
81 
83  itkSetStringMacro(FileName);
84 
86  itkGetStringMacro(FileName);
87 
92  itkSetObjectMacro( DOMNodeXML, OutputType );
93 #if !defined(ITK_LEGACY_REMOVE)
94  //Provide backwards compatible interface
95  virtual void SetOutput (OutputType * _arg) { this->SetDOMNodeXML(_arg); }
96 #endif
97 
98 
106  //NOTE: The m_DOMNodeXML is only
107  // exposed via the Source generation interface
108  // by the GetOutput() method that mimics
109  // a process object.
110  virtual const OutputType * GetOutput () const { return this->m_DOMNodeXML.GetPointer(); }
111  virtual OutputType * GetOutput() { return this->m_DOMNodeXML.GetPointer(); }
113 
114 #if !defined(ITK_LEGACY_REMOVE)
115  // This interface was exposed in ITKv4 when the itkGetModifiableObjectMacro was used
116  virtual OutputType * GetModifiedOutput() { return this->m_DOMNodeXML.GetPointer(); }
117 #endif
118 
123  void Update( std::istream& is );
124 
128  virtual void Update();
129 
133  virtual void StartElement( const char* name, const char** atts );
134 
138  virtual void EndElement( const char* name );
139 
143  virtual void CharacterDataHandler( const char* text, int len );
144 
145 protected:
146  DOMNodeXMLReader();
147 
148 private:
150  std::string m_FileName;
151 
154 
156  OutputType* m_Context{nullptr};
157 };
158 
159 } // namespace itk
160 
162 inline std::istream& operator>>( std::istream& is, itk::DOMNode& object )
163 {
165  reader->SetDOMNodeXML( &object );
166  reader->Update( is );
167  return is;
168 }
170 
171 #endif // itkDOMNodeXMLReader_h
Light weight base class for most itk classes.
Class to represent a node in a Document Object Model (DOM) tree structure.
Definition: itkDOMNode.h:53
std::istream & operator>>(std::istream &is, itk::DOMNode &object)
virtual OutputType * GetOutput()
static Pointer New()
virtual const OutputType * GetOutput() const
Base class for most ITK classes.
Definition: itkObject.h:60
Class to read a DOM object from an XML file or an input stream.