ITK  5.4.0
Insight Toolkit
itkDOMNodeXMLReader.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  * https://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_MOVE(DOMNodeXMLReader);
69  using Superclass = Object;
72 
74  itkNewMacro(Self);
75 
77  itkOverrideGetNameOfClassMacro(DOMNodeXMLReader);
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
96  SetOutput(OutputType * _arg)
97  {
98  this->SetDOMNodeXML(_arg);
99  }
100 #endif
101 
110  // NOTE: The m_DOMNodeXML is only
111  // exposed via the Source generation interface
112  // by the GetOutput() method that mimics
113  // a process object.
114  virtual const OutputType *
115  GetOutput() const
116  {
117  return this->m_DOMNodeXML.GetPointer();
118  }
119  virtual OutputType *
121  {
122  return this->m_DOMNodeXML.GetPointer();
123  }
126 #if !defined(ITK_LEGACY_REMOVE)
127  // This interface was exposed in ITKv4 when the itkGetModifiableObjectMacro was used
128  virtual OutputType *
129  GetModifiedOutput()
130  {
131  return this->m_DOMNodeXML.GetPointer();
132  }
133 #endif
134 
139  void
140  Update(std::istream & is);
141 
145  virtual void
146  Update();
147 
151  virtual void
152  StartElement(const char * name, const char ** atts);
153 
157  virtual void
158  EndElement(const char * name);
159 
163  virtual void
164  CharacterDataHandler(const char * text, int len);
165 
166 protected:
167  DOMNodeXMLReader();
168 
169 private:
171  std::string m_FileName{};
172 
174  OutputPointer m_DOMNodeXML{};
175 
177  OutputType * m_Context{ nullptr };
178 };
179 
180 } // namespace itk
181 
183 inline std::istream &
184 operator>>(std::istream & is, itk::DOMNode & object)
185 {
187  reader->SetDOMNodeXML(&object);
188  reader->Update(is);
189  return is;
190 }
193 #endif // itkDOMNodeXMLReader_h
itk::DOMNodeXMLReader::GetOutput
virtual OutputType * GetOutput()
Definition: itkDOMNodeXMLReader.h:120
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkDOMNode.h
itk::SmartPointer< Self >
itk::DOMNodeXMLReader::GetOutput
virtual const OutputType * GetOutput() const
Definition: itkDOMNodeXMLReader.h:115
operator>>
std::istream & operator>>(std::istream &is, itk::DOMNode &object)
Definition: itkDOMNodeXMLReader.h:184
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::DOMNodeXMLReader::New
static Pointer New()
itk::DOMNode
Class to represent a node in a Document Object Model (DOM) tree structure.
Definition: itkDOMNode.h:53
itkObject.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::DOMNodeXMLReader
Class to read a DOM object from an XML file or an input stream.
Definition: itkDOMNodeXMLReader.h:61