File: igstkTransformFileWriter.h

package info (click to toggle)
igstk 4.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 38,980 kB
  • sloc: cpp: 86,267; xml: 96; makefile: 75; python: 38
file content (152 lines) | stat: -rw-r--r-- 5,179 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*=========================================================================

  Program:   Image Guided Surgery Software Toolkit
  Module:    $RCSfile: igstkTransformFileWriter.h,v $
  Language:  C++
  Date:      $Date: 2009-06-04 20:06:54 $
  Version:   $Revision: 1.1 $

  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __igstkTransformFileWriter_h
#define __igstkTransformFileWriter_h

#include "igstkStateMachine.h"
#include "igstkTransformXMLFileWriterBase.h"
#include "igstkPrecomputedTransformData.h"
#include "igstkMacros.h"
#include "igstkObject.h"


namespace igstk
{
/** \class TransformFileWriter
 * 
 *  \brief This class is an IGSTK wrapper for all writers of xml files 
 *         for precomputed transformation. 
 *         The specific type of transformation is defined by the actual writer
 *         specified with the RequestSetWriter() method.
 *
 */
class TransformFileWriter : public Object 
{
public:

  /**Macro with standard traits declarations (Self, SuperClass, state machine 
    * etc.). */
  igstkStandardClassTraitsMacro( TransformFileWriter, Object )

  /** This is the container type which holds all the data associated with the 
   *  transformation (transformation, computation time...).*/
  typedef PrecomputedTransformData  TransformDataType;

  /**
   * Set a specific writer, which also defines the type of transformation.
   */
  void RequestSetWriter(
     const TransformXMLFileWriterBase::Pointer transformWriter );

  /**
   * Set the required data.
   */
  void RequestSetData( TransformDataType::Pointer &transformData,  
                       const std::string &fileName );

  /**
   * Actually perform the write operation. This method generates a 
   * WriteSuccessEvent upon success and a WriteFailureEvent if writing failed. If
   * the writer hasn't been initialized yet (missing TransformDataType, file name
   * or xml writer) an InvalidRequestErrorEvent is generated.
   */
  void RequestWrite();

  
  /** This event is generated if setting the xml writer succeeded. */
  igstkEventMacro( SetWriterSuccessEvent, IGSTKEvent );

  /** This event is generated if setting the xml writer failed. */
  igstkEventMacro( SetWriterFailureEvent, IGSTKErrorEvent );

  /** This event is generated if setting the data succeeded. */
  igstkEventMacro( SetDataSuccessEvent, IGSTKEvent );
 
  /** This event is generated if setting the data failed. */
  igstkEventMacro( SetDataFailureEvent, IGSTKErrorEvent );

  /** This event is generated if writing succeeded. */
  igstkEventMacro( WriteSuccessEvent, IGSTKEvent );

  /** This event is generated if writing failed. */
  igstkLoadedEventMacro( WriteFailureEvent, IGSTKErrorEvent, 
                         EventHelperType::StringType );

  
protected:

  TransformFileWriter( void );
  virtual ~TransformFileWriter( void );

  /** Print the object information in a stream. */
  void PrintSelf( std::ostream& os, itk::Indent indent ) const;

private:

  /** List of state machine states */
  igstkDeclareStateMacro( Idle );
  igstkDeclareStateMacro( AttemptingSetData );
  igstkDeclareStateMacro( AttemptingSetWriter );
  igstkDeclareStateMacro( DataSet );
  igstkDeclareStateMacro( WriterSet );
  igstkDeclareStateMacro( AttemptingSetWriterHaveData );
  igstkDeclareStateMacro( AttemptingSetDataHaveWriter );
  igstkDeclareStateMacro( Initialized );
  
  

  /** List of state machine inputs */
  igstkDeclareInputMacro( SetWriter );
  igstkDeclareInputMacro( SetData );
  igstkDeclareInputMacro( Write );
  igstkDeclareInputMacro( Success );
  igstkDeclareInputMacro( Failure );

  /**List of state machine actions*/
  void ReportInvalidRequestProcessing();  
  void SetWriterProcessing();
  void ReportSetWriterSuccessProcessing();
  void ReportSetWriterFailureProcessing();
  void SetDataProcessing();
  void ReportSetDataSuccessProcessing();
  void ReportSetDataFailureProcessing();
  void WriteProcessing();
  void ReportWriteSuccessProcessing();
  void ReportWriteFailureProcessing();
      
  TransformFileWriter( 
    const TransformFileWriter & other );

  const TransformFileWriter & operator=( 
    const TransformFileWriter & right );

  TransformDataType::Pointer          m_TmpTransformData;
  TransformDataType::Pointer          m_TransformData;
  std::string                         m_TmpFileName;
  std::string                         m_FileName;
  TransformXMLFileWriterBase::Pointer m_TmpXMLFileWriter;
  TransformXMLFileWriterBase::Pointer m_XMLFileWriter;

  //if writing fails the WriteProcessing() method updates this string
  //with an appropriate error message which the user recieves when
  //the ReportWriteFailureProcessing() generates the WriteFailureEvent
  EventHelperType::StringType m_WriteFailureErrorMessage;
};


}
#endif //__igstkTransformFileWriter_h