OpendTect-6_4  6.4
executor.h
Go to the documentation of this file.
1 #ifndef executor_h
2 #define executor_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H.Bril
9  Date: 11-7-1996
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "task.h"
17 #include "namedobj.h"
18 #include "progressmeter.h"
19 #include "od_iosfwd.h"
20 
40 {
41 public:
42  Executor( const char* nm )
43  : SequentialTask(nm)
44  , prestep(this), poststep(this) {}
45  virtual ~Executor() {}
46 
47  virtual int doStep();
48 
49  inline bool go( od_ostream* s=0, bool isfirst=true,
50  bool islast=true, int delaybtwnstepsinms=0 )
51  { return goImpl(s,isfirst,islast,delaybtwnstepsinms); }
52  inline bool go( od_ostream& s, bool isfirst=true,
53  bool islast=true, int delaybtwnstepsinms=0 )
54  { return goImpl(&s,isfirst,islast,delaybtwnstepsinms); }
55 
58 
59  // Being a Task requires:
60  virtual bool execute() { return go(); }
61 
62 protected:
63 
64  virtual bool goImpl(od_ostream*,bool,bool,int);
65 
66 };
67 
68 
78 {
79 public:
80  ExecutorGroup( const char* nm, bool parallel=false,
81  bool ownsexecs=true );
82  virtual ~ExecutorGroup();
83  virtual void add( Executor* );
86  uiString uiMessage() const;
87  virtual od_int64 totalNr() const;
88  virtual od_int64 nrDone() const;
89  uiString uiNrDoneText() const;
90 
91  int nrExecutors() { return executors_.size(); }
92  Executor* getExecutor(int idx) { return executors_[idx]; }
93 
94  void setNrDoneText(const uiString& txt)
95  { nrdonetext_ = txt; }
97 
98 protected:
99 
100  virtual int nextStep();
101  virtual bool goToNextExecutor();
102  void findNextSumStop();
103 
105  int sumstop_;
106  const bool parallel_;
112 
113 };
114 
115 
121 {
122 public:
124  : TaskRunner()
125  , strm_(strm) {}
126 
127  bool execute(Task&);
128 
129 protected:
130 
132 
133 };
134 
135 
136 #endif
#define mExpClass(module)
Definition: commondefs.h:160
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
Executor consisting of other executors.
Definition: executor.h:77
Notifier< Executor > prestep
Definition: executor.h:56
#define od_int64
Definition: plftypes.h:36
ObjectSet< Executor > & executors_
Definition: executor.h:109
const bool parallel_
Definition: executor.h:106
Notifier< Executor > poststep
Only when MoreToDo will be returned.
Definition: executor.h:57
Definition: uistring.h:89
Executor * getExecutor(int idx)
Definition: executor.h:92
od_ostream & strm_
Definition: executor.h:131
The generalization of something (e.g. a computation) where the steps must be done in sequence...
Definition: task.h:124
int nrExecutors()
Definition: executor.h:91
void setNrDoneText(const uiString &txt)
If set, will use this and the counted nrdone.
Definition: executor.h:94
int sumstop_
Definition: executor.h:105
Class that can execute a task.
Definition: task.h:169
TextTaskRunner(od_ostream &strm)
Definition: executor.h:123
bool go(od_ostream &s, bool isfirst=true, bool islast=true, int delaybtwnstepsinms=0)
Definition: executor.h:52
virtual ~Executor()
Definition: executor.h:45
uiString nrdonetext_
Definition: executor.h:108
TaskRunner to show progress of a Task in text format.
Definition: executor.h:120
int currentexec_
Definition: executor.h:107
int sumstart_
Definition: executor.h:104
TypeSet< int > executorres_
Definition: executor.h:110
int doStep()
Generalization of something (e.g. a computation) that needs to be done in multiple steps...
Definition: task.h:28
bool ownsexecs_
Definition: executor.h:111
virtual bool execute()
Definition: executor.h:60
Executor(const char *nm)
Definition: executor.h:42
bool go(od_ostream *s=0, bool isfirst=true, bool islast=true, int delaybtwnstepsinms=0)
Definition: executor.h:49
Specification to enable chunkwise execution of a process.
Definition: executor.h:39

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019