OTB  9.0.0
Orfeo Toolbox
otbFilterWatcherBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbFilterWatcherBase_h
23 #define otbFilterWatcherBase_h
24 
25 #include <string>
26 
27 #include "otbStopwatch.h"
28 #include "itkCommand.h"
29 #include "itkProcessObject.h"
30 
31 #include "OTBCommonExport.h"
32 
33 namespace otb
34 
35 {
48 class OTBCommon_EXPORT FilterWatcherBase
49 {
50 public:
53  FilterWatcherBase(itk::ProcessObject* process, const char* comment = "");
54 
57 
60 
62  void operator=(const FilterWatcherBase&);
63 
65  virtual ~FilterWatcherBase();
66 
67  const char* GetNameOfClass()
68  {
69  return (m_Process.GetPointer() ? m_Process->GetNameOfClass() : "None");
70  }
71 
75  itk::ProcessObject* GetProcess()
76  {
77  return m_Process.GetPointer();
78  }
79 
81  std::string GetComment()
82  {
83  return m_Comment;
84  }
85 
88  {
89  return m_Stopwatch;
90  }
91 
92 protected:
94  virtual void ShowProgressCallback()
95  {
96  this->ShowProgress();
97  }
98 
100  virtual void StartFilterCallback()
101  {
102  if (!m_Started)
103  {
104  this->StartFilter();
105  m_Started = true;
106  }
107  }
109 
111  virtual void EndFilterCallback()
112  {
113  if (!m_Ended)
114  {
115  this->EndFilter();
116  m_Ended = true;
117  }
118  }
120 
122  virtual void ShowProgress() = 0;
123 
125  virtual void StartFilter() = 0;
126 
128  virtual void EndFilter() = 0;
129 
132 
134  std::string m_Comment;
135 
137  itk::ProcessObject::Pointer m_Process;
138 
140  typedef itk::SimpleMemberCommand<FilterWatcherBase> CommandType;
141 
143  CommandType::Pointer m_StartFilterCommand;
144 
146  CommandType::Pointer m_EndFilterCommand;
147 
149  CommandType::Pointer m_ProgressFilterCommand;
150 
152  unsigned long m_StartTag;
153 
155  unsigned long m_EndTag;
156 
158  unsigned long m_ProgressTag;
159 
162  bool m_Started;
163 
166  bool m_Ended;
167 
168 private:
169 };
170 
171 } // end namespace otb
172 
173 #endif
otb::FilterWatcherBase::m_StartTag
unsigned long m_StartTag
Definition: otbFilterWatcherBase.h:152
otb::FilterWatcherBase::m_Process
itk::ProcessObject::Pointer m_Process
Definition: otbFilterWatcherBase.h:137
otb::FilterWatcherBase::CommandType
itk::SimpleMemberCommand< FilterWatcherBase > CommandType
Definition: otbFilterWatcherBase.h:140
otb::FilterWatcherBase::StartFilterCallback
virtual void StartFilterCallback()
Definition: otbFilterWatcherBase.h:100
otb::FilterWatcherBase::m_Started
bool m_Started
Definition: otbFilterWatcherBase.h:162
otb::FilterWatcherBase::m_ProgressFilterCommand
CommandType::Pointer m_ProgressFilterCommand
Definition: otbFilterWatcherBase.h:149
otb::FilterWatcherBase::GetComment
std::string GetComment()
Definition: otbFilterWatcherBase.h:81
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::FilterWatcherBase::EndFilterCallback
virtual void EndFilterCallback()
Definition: otbFilterWatcherBase.h:111
otb::FilterWatcherBase::m_Stopwatch
otb::Stopwatch m_Stopwatch
Definition: otbFilterWatcherBase.h:131
otb::FilterWatcherBase::m_StartFilterCommand
CommandType::Pointer m_StartFilterCommand
Definition: otbFilterWatcherBase.h:143
otb::FilterWatcherBase::m_Ended
bool m_Ended
Definition: otbFilterWatcherBase.h:166
otb::FilterWatcherBase::ShowProgressCallback
virtual void ShowProgressCallback()
Definition: otbFilterWatcherBase.h:94
otb::Stopwatch
Stopwatch timer.
Definition: otbStopwatch.h:41
otb::FilterWatcherBase::GetNameOfClass
const char * GetNameOfClass()
Definition: otbFilterWatcherBase.h:67
otb::FilterWatcherBase
This class is an abstract class Provides an interface to progress task mechanic.
Definition: otbFilterWatcherBase.h:48
otb::FilterWatcherBase::m_Comment
std::string m_Comment
Definition: otbFilterWatcherBase.h:134
otb::FilterWatcherBase::GetProcess
itk::ProcessObject * GetProcess()
Definition: otbFilterWatcherBase.h:75
otb::FilterWatcherBase::m_EndFilterCommand
CommandType::Pointer m_EndFilterCommand
Definition: otbFilterWatcherBase.h:146
otbStopwatch.h
otb::FilterWatcherBase::m_EndTag
unsigned long m_EndTag
Definition: otbFilterWatcherBase.h:155
otb::FilterWatcherBase::GetStopwatch
otb::Stopwatch & GetStopwatch()
Definition: otbFilterWatcherBase.h:87
otb::FilterWatcherBase::m_ProgressTag
unsigned long m_ProgressTag
Definition: otbFilterWatcherBase.h:158