Orfeo Toolbox  4.0
otbFilterWatcherBase.cxx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12  Some parts of this code are derived from ITK. See ITKCopyright.txt
13  for details.
14 
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notices for more information.
19 
20 =========================================================================*/
21 #include "otbFilterWatcherBase.h"
22 
23 namespace otb
24 {
25 
28 : m_Comment("Not watching an object"),
29  m_Process(0),
30  m_StartTag(0),
31  m_EndTag(0),
32  m_ProgressTag(0),
33  m_Started(false),
34  m_Ended(false)
35 {
36 }
37 
40  const char *comment)
41 : m_Comment(comment),
42  m_Process(process),
43  m_StartTag(0),
44  m_EndTag(0),
45  m_ProgressTag(0),
46  m_Started(false),
47  m_Ended(false)
48 {
49  // Create a series of commands
50  m_StartFilterCommand = CommandType::New();
51  m_EndFilterCommand = CommandType::New();
52  m_ProgressFilterCommand = CommandType::New();
53 
54  // Assign the callbacks
55  m_StartFilterCommand->SetCallbackFunction(this,
57  m_EndFilterCommand->SetCallbackFunction(this,
59  m_ProgressFilterCommand->SetCallbackFunction(this,
61 
62  // Add the commands as observers
63  m_StartTag = m_Process->AddObserver(itk::StartEvent(),
64  m_StartFilterCommand);
65 
66  m_EndTag = m_Process->AddObserver(itk::EndEvent(),
67  m_EndFilterCommand);
68 
69  m_ProgressTag = m_Process->AddObserver(itk::ProgressEvent(),
70  m_ProgressFilterCommand);
71 }
72 
75 {
76  // Remove any observers we have on the old process object
77  if (m_Process)
78  {
79  m_Process->RemoveAllObservers();
80  }
81 
82  // Initialize state
83  m_TimeProbe = watch.m_TimeProbe;
84  m_Process = watch.m_Process;
85  m_Comment = watch.m_Comment;
86 
87  m_StartTag = 0;
88  m_EndTag = 0;
89  m_ProgressTag = 0;
90 
91  // Create a series of commands
92  if (m_Process)
93  {
94  m_StartFilterCommand = CommandType::New();
95  m_EndFilterCommand = CommandType::New();
96  m_ProgressFilterCommand = CommandType::New();
97 
98  // Assign the callbacks
99  m_StartFilterCommand->SetCallbackFunction(this,
101  m_EndFilterCommand->SetCallbackFunction(this,
103  m_ProgressFilterCommand->SetCallbackFunction(this,
105 
106  // Add the commands as observers
107  m_StartTag = m_Process->AddObserver(itk::StartEvent(), m_StartFilterCommand);
108  m_EndTag = m_Process->AddObserver(itk::EndEvent(), m_EndFilterCommand);
109  m_ProgressTag
110  = m_Process->AddObserver(itk::ProgressEvent(), m_ProgressFilterCommand);
111  }
112 }
113 
114 void
117 {
118  // Remove any observers we have on the old process object
119  if (m_Process)
120  {
121  m_Process->RemoveAllObservers();
122  }
123 
124  // Initialize state
125  m_TimeProbe = watch.m_TimeProbe;
126  m_Process = watch.m_Process;
127  m_Comment = watch.m_Comment;
128 
129  m_StartTag = 0;
130  m_EndTag = 0;
131  m_ProgressTag = 0;
132 
133  // Create a series of commands
134  if (m_Process)
135  {
136  m_StartFilterCommand = CommandType::New();
137  m_EndFilterCommand = CommandType::New();
138  m_ProgressFilterCommand = CommandType::New();
139 
140  // Assign the callbacks
141  m_StartFilterCommand->SetCallbackFunction(this,
143  m_EndFilterCommand->SetCallbackFunction(this,
145  m_ProgressFilterCommand->SetCallbackFunction(this,
147 
148  // Add the commands as observers
149  m_StartTag = m_Process->AddObserver(itk::StartEvent(), m_StartFilterCommand);
150  m_EndTag = m_Process->AddObserver(itk::EndEvent(), m_EndFilterCommand);
151  m_ProgressTag
152  = m_Process->AddObserver(itk::ProgressEvent(), m_ProgressFilterCommand);
153  }
154 }
155 
158 {
159  // Remove any observers we have on the old process object
160  if (m_Process)
161  {
162  m_Process->RemoveAllObservers();
163  }
164 }
165 
166 } // end namespace otb

Generated at Sat Mar 8 2014 15:55:44 for Orfeo Toolbox with doxygen 1.8.3.1