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

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