ITK  5.4.0
Insight Toolkit
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
itk::DOMWriter< TInput > Class Template Referenceabstract

#include <itkDOMWriter.h>

Detailed Description

template<typename TInput>
class itk::DOMWriter< TInput >

Class to write an ITK object to an XML file or a DOM object, using the DOM APIs.

End-users need to derive from this class to implement writers for user objects. In subclasses, users need to provide an implementation for the virtual function GenerateData(-,-).

This class performs similar functions as the XMLWriterBase - both provide the base for handling object writing to an XML destination. The difference is that, writers derived from this class perform object writing using the easy-to-use DOM APIs, while XMLWriterBase-based writers directly generate textual XML documents, which is tedious and more error prone.

Internally, this class first generates an intermediate DOM object from the input object, then the DOM object is implicitly written to the output XML file using the DOMNodeXMLWriter.

Note: Though this class behaves similar to ProcessObject, it is not derived from ProcessObject. This is because many user objects to be written, e.g., registrations, transforms, optimizers, and so on, are not objects of type DataObject, thus this class cannot be connected to an ITK process pipeline.

The following code snippet demonstrates how to use a DOM-based writer that is derived from this class:

itk::MyObjectType::Pointer input_object = ...
const char* output_xml_file_name = ...
itk::MyObjectDOMWriter::Pointer writer = itk::MyObjectDOMWriter::New();
writer->SetInput( input_object );
writer->SetFileName( output_xml_file_name );
writer->Update();
See also
XMLWriterBase
DOMNodeXMLWriter
DOMNode

Definition at line 67 of file itkDOMWriter.h.

+ Inheritance diagram for itk::DOMWriter< TInput >:
+ Collaboration diagram for itk::DOMWriter< TInput >:

Public Types

using DOMNodePointer = typename DOMNodeType::Pointer
 
using DOMNodeType = DOMNode
 
using InputType = TInput
 
using LoggerPointer = typename LoggerType::Pointer
 
using LoggerType = Logger
 
using Self = DOMWriter
 
- Public Types inherited from itk::Object
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = Object
 
using Superclass = LightObject
 
- Public Types inherited from itk::LightObject
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = LightObject
 

Public Member Functions

virtual const char * GetFileName () const
 
const InputTypeGetInput () const
 
virtual LoggerTypeGetLogger () const
 
const char * GetNameOfClass () const override
 
virtual void SetFileName (const char *_arg)
 
virtual void SetInput (const InputType *input)
 
virtual void Update ()
 
void Update (DOMNodeType *outputdom, const void *userdata=nullptr)
 
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *)
 
unsigned long AddObserver (const EventObject &event, Command *) const
 
unsigned long AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const
 
LightObject::Pointer CreateAnother () const override
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
CommandGetCommand (unsigned long tag)
 
bool GetDebug () const
 
MetaDataDictionaryGetMetaDataDictionary ()
 
const MetaDataDictionaryGetMetaDataDictionary () const
 
virtual ModifiedTimeType GetMTime () const
 
virtual const TimeStampGetTimeStamp () const
 
bool HasObserver (const EventObject &event) const
 
void InvokeEvent (const EventObject &)
 
void InvokeEvent (const EventObject &) const
 
virtual void Modified () const
 
void Register () const override
 
void RemoveAllObservers ()
 
void RemoveObserver (unsigned long tag)
 
void SetDebug (bool debugFlag) const
 
void SetReferenceCount (int) override
 
void UnRegister () const noexcept override
 
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
 
void SetMetaDataDictionary (MetaDataDictionary &&rrhs)
 
virtual void SetObjectName (std::string _arg)
 
virtual const std::string & GetObjectName () const
 
- Public Member Functions inherited from itk::LightObject
Pointer Clone () const
 
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
void Print (std::ostream &os, Indent indent=0) const
 

Protected Member Functions

 DOMWriter ()
 
virtual void GenerateData (DOMNodeType *outputdom, const void *userdata) const =0
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
virtual void SetTimeStamp (const TimeStamp &timeStamp)
 
 ~Object () override
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Member Functions

virtual void SetIntermediateDOM (DOMNodeType *_arg)
 
virtual DOMNodeTypeGetModifiableIntermediateDOM ()
 

Private Attributes

std::string m_FileName {}
 
const InputTypem_Input {}
 
LightObject::ConstPointer m_InputHolder {}
 
DOMNodePointer m_IntermediateDOM {}
 
LoggerPointer m_Logger {}
 

Additional Inherited Members

- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
 
static void GlobalWarningDisplayOff ()
 
static void GlobalWarningDisplayOn ()
 
static Pointer New ()
 
static void SetGlobalWarningDisplay (bool val)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 
- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount {}
 

Member Typedef Documentation

◆ DOMNodePointer

template<typename TInput >
using itk::DOMWriter< TInput >::DOMNodePointer = typename DOMNodeType::Pointer

Definition at line 81 of file itkDOMWriter.h.

◆ DOMNodeType

template<typename TInput >
using itk::DOMWriter< TInput >::DOMNodeType = DOMNode

Definition at line 80 of file itkDOMWriter.h.

◆ InputType

template<typename TInput >
using itk::DOMWriter< TInput >::InputType = TInput

Definition at line 78 of file itkDOMWriter.h.

◆ LoggerPointer

template<typename TInput >
using itk::DOMWriter< TInput >::LoggerPointer = typename LoggerType::Pointer

Definition at line 84 of file itkDOMWriter.h.

◆ LoggerType

template<typename TInput >
using itk::DOMWriter< TInput >::LoggerType = Logger

Definition at line 83 of file itkDOMWriter.h.

◆ Self

template<typename TInput >
using itk::DOMWriter< TInput >::Self = DOMWriter

Standard class type aliases.

Definition at line 74 of file itkDOMWriter.h.

Constructor & Destructor Documentation

◆ DOMWriter()

template<typename TInput >
itk::DOMWriter< TInput >::DOMWriter ( )
protected

Member Function Documentation

◆ GenerateData()

template<typename TInput >
virtual void itk::DOMWriter< TInput >::GenerateData ( DOMNodeType outputdom,
const void *  userdata 
) const
protectedpure virtual

Function to be implemented in subclasses. It is called automatically when update functions are performed. It should fill the contents of the intermediate DOM object by pulling information from the input object. Some derived writers may accept an incomplete input object during the writing process, in those cases the optional argument 'userdata' can be used to provide the missed information.

◆ GetFileName()

template<typename TInput >
virtual const char* itk::DOMWriter< TInput >::GetFileName ( ) const
virtual

Get the output XML filename.

◆ GetInput()

template<typename TInput >
const InputType* itk::DOMWriter< TInput >::GetInput ( ) const

Get the input object to be written.

◆ GetLogger()

template<typename TInput >
virtual LoggerType* itk::DOMWriter< TInput >::GetLogger ( ) const
virtual

Return the internal logger so that users can change the output format or add/remove logging destinations.

◆ GetModifiableIntermediateDOM()

template<typename TInput >
virtual DOMNodeType* itk::DOMWriter< TInput >::GetModifiableIntermediateDOM ( )
privatevirtual

Get/Set the intermediate DOM object.

◆ GetNameOfClass()

template<typename TInput >
const char* itk::DOMWriter< TInput >::GetNameOfClass ( ) const
overridevirtual
See also
LightObject::GetNameOfClass()

Reimplemented from itk::Object.

◆ SetFileName()

template<typename TInput >
virtual void itk::DOMWriter< TInput >::SetFileName ( const char *  _arg)
virtual

Set the output XML filename.

◆ SetInput()

template<typename TInput >
virtual void itk::DOMWriter< TInput >::SetInput ( const InputType input)
virtual

Set the input object to be written.

◆ SetIntermediateDOM()

template<typename TInput >
virtual void itk::DOMWriter< TInput >::SetIntermediateDOM ( DOMNodeType _arg)
privatevirtual

Get/Set the intermediate DOM object.

◆ Update() [1/2]

template<typename TInput >
virtual void itk::DOMWriter< TInput >::Update ( )
virtual

Function called by end-users to write the input object to the output XML file.

◆ Update() [2/2]

template<typename TInput >
void itk::DOMWriter< TInput >::Update ( DOMNodeType outputdom,
const void *  userdata = nullptr 
)

Function called by Update() or end-users to write the input object to a DOM object. Some derived writers may accept an incomplete input object during the writing process, in those cases the optional argument 'userdata' can be used to provide the missed information.

Member Data Documentation

◆ m_FileName

template<typename TInput >
std::string itk::DOMWriter< TInput >::m_FileName {}
private

Variable to hold the output XML file name.

Definition at line 140 of file itkDOMWriter.h.

◆ m_Input

template<typename TInput >
const InputType* itk::DOMWriter< TInput >::m_Input {}
private

Variable to hold the input object.

Definition at line 143 of file itkDOMWriter.h.

◆ m_InputHolder

template<typename TInput >
LightObject::ConstPointer itk::DOMWriter< TInput >::m_InputHolder {}
private

Variable to hold the input object if it is a smart object.

Definition at line 146 of file itkDOMWriter.h.

◆ m_IntermediateDOM

template<typename TInput >
DOMNodePointer itk::DOMWriter< TInput >::m_IntermediateDOM {}
private

Variable to hold the intermediate DOM object.

Definition at line 149 of file itkDOMWriter.h.

◆ m_Logger

template<typename TInput >
LoggerPointer itk::DOMWriter< TInput >::m_Logger {}
mutableprivate

Variable to log various messages during the writing process.

Definition at line 152 of file itkDOMWriter.h.


The documentation for this class was generated from the following file:
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
New
static Pointer New()