Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Progress.h
Go to the documentation of this file.
1 
12 #ifndef __KOME_CORE_PROGRESS_H__
13 #define __KOME_CORE_PROGRESS_H__
14 
15 
16 #include "Timer.h"
17 
18 #include <vector>
19 #include <map>
20 #include <utility>
21 #include <string>
22 
23 
24 namespace kome {
25  namespace core {
26 
31  class CORE_TOOLKITS_CLASS Progress {
32  public:
38  Progress( const char* title = NULL );
39 
44  virtual ~Progress();
45 
46  protected:
48  std::vector< Progress* > m_subProgresses;
49 
51  int m_start;
53  int m_end;
55  int m_pos;
57  int m_prevPos;
59  int m_relPos;
60 
62  std::string m_title;
63 
66 
68  std::vector< std::pair< std::string, Timer* > >* m_timers;
69 
70  public:
77  void setRange( const int start, const int end );
78 
85  void setPosition( const int pos, const bool bForced = false ); // @Date:2013/11/18 <Add> A.Ozaki
86 
93  void setStatus( const char* status, const bool bForced = false ); // @Date:2013/11/18 <Add> A.Ozaki
94 
100  bool isStopped();
101 
106  void fill();
107 
108 // >>>>>> @Date:2013/11/18 <Add> A.Ozaki
109 //
110  protected:
112  long long m_llPrevTime;
113 
115  std::string m_strStatus;
116 //
117 // <<<<<< @Date:2013/11/18 <Add> A.Ozaki
118 
119  public:
125  int getRelativePosition();
126 
127  public:
134  Timer* createTimer( const char* name );
135 
141  unsigned int getNumberOfTimers();
142 
149  const char* getTimerName( const unsigned int index );
150 
157  Timer* getTimer( const unsigned int index );
158 
159  public:
165  void createSubProgresses( const unsigned int num );
166 
172  unsigned int getNumberOfSubProgresses();
173 
180  Progress* getSubProgress( const unsigned int idx );
181 
182  public:
188  static Progress& getIgnoringProgress();
189 
190  protected:
197  virtual void onSetRange( const int start, const int end ) = 0;
198 
205  virtual void onSetPosition( const int pos, const int prevPos ) = 0;
206 
213  virtual void onSetStatus( const char* status, const bool bForced ) = 0; // @Date:2013/11/25 <Add> A.Ozaki
214 
220  virtual bool onIsStopped() = 0;
221 
222  // >>>>>> @Date:2013/11/25 <Add> A.Ozaki
223  //
228  virtual void onFill( void ) = 0;
229  //
230  // <<<<<< @Date:2013/11/25 <Add> A.Ozaki
231  };
232 
238  class IgnoringProgress : public Progress {
239  public:
245 
250  virtual ~IgnoringProgress();
251 
252  protected:
257  virtual void onSetRange( const int, const int );
258 
259 
264  virtual void onSetPosition( const int , const int );
265 
271  virtual void onSetStatus( const char*, const bool bForced = false ); // @Date:2013/11/25 <Add> A.Ozaki
272 
278  virtual bool onIsStopped();
279 
280  // >>>>>> @Date:2013/11/25 <Add> A.Ozaki
281  //
286  virtual void onFill( void );
287  //
288  // <<<<<< @Date:2013/11/25 <Add> A.Ozaki
289  };
290 
295  class SubProgress : public Progress {
296  public:
302  SubProgress( Progress& parent );
303 
308  virtual ~SubProgress();
309 
310  protected:
313 
314  protected:
321  virtual void onSetRange( const int start, const int end );
322 
323 
330  virtual void onSetPosition( const int pos, const int prevPos );
331 
338  virtual void onSetStatus( const char* status, const bool bForced = false ); // @Date:2013/11/25 <Add> A.Ozaki
339 
345  virtual bool onIsStopped();
346 
347  // >>>>>> @Date:2013/11/25 <Add> A.Ozaki
348  //
353  virtual void onFill( void );
354  //
355  // <<<<<< @Date:2013/11/25 <Add> A.Ozaki
356  };
357  }
358 }
359 
360 #endif // __KOME_CORE_PROGRESS_H__
virtual void onSetPosition(const int pos, const int prevPos)
This method is called by setPosition method. (override method)
Definition: Progress.cpp:408
virtual ~SubProgress()
destructor
Definition: Progress.cpp:399
virtual void onSetStatus(const char *status, const bool bForced=false)
This method is called by setStatus method. (override method)
Definition: Progress.cpp:421
std::string m_title
Definition: Progress.h:62
std::vector< std::pair< std::string, Timer * > > * m_timers
Definition: Progress.h:68
Progress object. Even if a method is called, it disgards it.
Definition: Progress.h:238
virtual void onFill(void)
This method is called by fill method. (override method)
Definition: Progress.cpp:433
timer class
Definition: Timer.h:26
interfaces of Timer class
std::vector< Progress * > m_subProgresses
Definition: Progress.h:48
progress display abstract class
Definition: Progress.h:31
virtual bool onIsStopped()
This method is called by isStopped method. (override method)
Definition: Progress.cpp:426
virtual void onSetStatus(const char *, const bool bForced=false)
This method is called by setStatus method. (override method)
Definition: Progress.cpp:371
std::string m_strStatus
Definition: Progress.h:115
#define NULL
Definition: CoreMacros.h:18
sub progress object.
Definition: Progress.h:295
virtual void onSetRange(const int start, const int end)
This method is called by setRange method. (override method)
Definition: Progress.cpp:404
IgnoringProgress()
constructor
Definition: Progress.cpp:355
long long m_llPrevTime
Definition: Progress.h:112
SubProgress(Progress &parent)
constructor
Definition: Progress.cpp:394
virtual ~IgnoringProgress()
destructor
Definition: Progress.cpp:359
virtual void onSetPosition(const int, const int)
This method is called by setPosition method. (override method)
Definition: Progress.cpp:367
virtual bool onIsStopped()
This method is called by isStopped method. (override method)
Definition: Progress.cpp:375
virtual void onFill(void)
This method is called by fill method. (override method)
Definition: Progress.cpp:382
virtual void onSetRange(const int, const int)
This method is called by setRange method. (override method)
Definition: Progress.cpp:363