22 #ifndef otbStandardOneLineFilterWatcher_hxx
23 #define otbStandardOneLineFilterWatcher_hxx
34 template <
class Pr
intCallbackType>
37 m_DefaultCallback = std::make_shared<PrintCallbackType>();
38 m_Callback = m_DefaultCallback.get();
41 template <
class Pr
intCallbackType>
45 m_DefaultCallback = std::make_shared<PrintCallbackType>();
46 m_Callback = m_DefaultCallback.get();
49 template <
class Pr
intCallbackType>
51 :
FilterWatcherBase(process, comment.c_str()), m_StarsCount(50), m_CurrentNbStars(-1)
53 m_DefaultCallback = std::make_shared<PrintCallbackType>();
54 m_Callback = m_DefaultCallback.get();
57 template <
class Pr
intCallbackType>
62 int progressPercent =
static_cast<int>(m_Process->GetProgress() * 100);
63 int nbStars =
static_cast<int>(m_Process->GetProgress() * m_StarsCount);
64 int nbBlanks = m_StarsCount - nbStars;
71 if (nbStars > m_StarsCount)
73 nbStars = m_StarsCount;
76 if (progressPercent > 100)
78 progressPercent = 100;
81 if (nbStars > m_CurrentNbStars)
83 std::string stars(nbStars,
'*');
84 std::string blanks(nbBlanks,
' ');
85 std::ostringstream oss;
86 oss << m_Comment <<
": " << progressPercent <<
"% [" << stars << blanks <<
"]";
87 if (m_Callback->IsInteractive())
89 m_Callback->Call(
"\r" + oss.str());
98 m_CurrentNbStars = nbStars;
102 template <
class Pr
intCallbackType>
108 template <
class Pr
intCallbackType>
113 if (m_Process && !m_Callback->IsInteractive())
115 m_Callback->Call(m_Buffer);
116 m_Buffer = std::string(
"");
119 m_Callback->Call(
" (" + m_Stopwatch.GetElapsedHumanReadableTime() +
")\n");