OTB  7.1.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-2019 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
Stopwatch timer.
Definition: otbStopwatch.h:41
CommandType::Pointer m_EndFilterCommand
itk::ProcessObject * GetProcess()
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
CommandType::Pointer m_StartFilterCommand
itk::ProcessObject::Pointer m_Process
otb::Stopwatch & GetStopwatch()
CommandType::Pointer m_ProgressFilterCommand
itk::SimpleMemberCommand< FilterWatcherBase > CommandType
virtual void StartFilterCallback()
This class is an abstract class Provides an interface to progress task mechanic.
virtual void ShowProgressCallback()