| OpendTect 8.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
BatchProgram Class Reference

Main object for 'standard' batch programs. More...

`#include <batchprog.h>`

Inheritance diagram for BatchProgram:
[legend]

## Public Types
enum | Status { Start , ParseFail , ParseOK , CommFail , CommOK , LogFail , LogOK , WorkWait , WorkStarted , WorkFail , WorkPaused , MoreToDo , WorkOK , Killed , LockOK }
Public Types inherited from ObjectWithName
typedef OD::String | name_type

## Public Member Functions
const CommandLineParser & | clParser ()
| mExp (Batch) bool doWork(od_ostream &)
| mExp (Batch) bool errorMsg(const uiString &
| mExp (Batch) bool infoMsg(const char *
| mExp (Batch) bool isOK() const
| mExp (Batch) bool pauseRequested()
| mExp (Batch) void loadModules()
| mExp (Batch) void setResumed()
IOPar & | pars ()
const IOPar & | pars () const
Public Member Functions inherited from NamedCallBacker
| NamedCallBacker (const char *nm=nullptr)
| NamedCallBacker (const NamedCallBacker &)=delete
| ~NamedCallBacker ()
virtual Notifier< NamedCallBacker > & | objectToBeDeleted () const
NamedCallBacker & | operator= (const NamedCallBacker &)=delete
bool | operator== (const NamedCallBacker &oth) const
bool | operator== (const NamedObject &oth) const
Public Member Functions inherited from CallBacker
| CallBacker ()
| CallBacker (const CallBacker &)
virtual | ~CallBacker ()
bool | attachCB (const NotifierAccess &, const CallBack &, bool onlyifnew=false) const
bool | attachCB (const NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false) const
void | detachAllNotifiers () const
| Call from the destructor of your inherited object.
void | detachCB (const NotifierAccess &, const CallBack &) const
void | detachCB (const NotifierAccess *notif, const CallBack &cb) const
virtual bool | isCapsule () const
bool | isNotifierAttached (const NotifierAccess *) const
| Only for debugging purposes, don't use.
CallBacker & | operator= (const CallBacker &)=delete
void | stopReceivingNotifications () const
virtual CallBacker * | trueCaller ()
Public Member Functions inherited from NamedObject
| NamedObject (const char *nm=nullptr)
| NamedObject (const NamedObject &oth)
virtual | ~NamedObject ()
virtual BufferString | getName () const
bool | getNameFromPar (const IOPar &)
const name_type & | name () const override
NamedObject & | operator= (const NamedObject &)
bool | operator== (const NamedObject &oth) const
virtual void | setName (const char *nm)
Public Member Functions inherited from ObjectWithName
virtual | ~ObjectWithName ()
bool | hasName (const char *nm) const
bool | hasName (const name_type &nm) const
void | putNameInPar (IOPar &) const

## Static Public Member Functions
static const char * | sKeyDataDir ()
static const char * | sKeyFinishMsg ()
static const char * | sKeySimpleBatch ()
static const char * | sKeySurveyDir ()
Static Public Member Functions inherited from CallBacker
static void | createReceiverForCurrentThread ()
static void | removeReceiverForCurrentThread ()

## Public Attributes
bool | cc_stderr =false)
bool | cc_stdout =false)
Notifier< BatchProgram > | endWork
Notifier< BatchProgram > | eventLoopStarted
Notifier< BatchProgram > | killed
Notifier< BatchProgram > | pause
Notifier< BatchProgram > | resume
Notifier< BatchProgram > | startDoWork

## Private Member Functions
| BatchProgram ()
| ~BatchProgram ()
bool | canStartdoWork () const
void | doFinalize ()
void | doWorkCB (CallBacker *)
void | eventLoopStartedCB (CallBacker *)
const BufferString | getLockFileFP () const
bool | initComm ()
bool | initLogging ()
Batch::ID | jobId ()
void | killNotify (bool yn)
| mExp (Batch) bool canReceiveRequests() const
| mExp (Batch) bool init()
| mExp (Batch) float getPriority() const
| mExp (Batch) static void deleteInstance(int retcode)
| mExp (Batch) void endWorkCB(CallBacker *)
| mExp (Batch) void initWork()
| mExp (Batch) void modulesLoaded()
| mExp (Batch) void postWork(bool res)
| mExp (Batch) void startTimer()
JobCommunic * | mmComm ()
bool | parseArguments ()
void | progKilled (CallBacker *)
bool | updateLockFilePars () const
void | workMonitorCB (CallBacker *)

## Private Attributes
Threads::Lock | batchprogthreadlock_
CommandLineParser * | clparser_ = nullptr
JobCommunic * | comm_ = nullptr
IOPar * | iopar_ = nullptr
Batch::ID | jobid_
float | priority_ = 0.f
ObjectSet< OD::JSON::Object > | requests_
Threads::Lock | statelock_
Status | status_ = Start
od_ostream * | strm_ = nullptr
bool | strmismine_ = true
Threads::Thread * | thread_ = nullptr
Timer * | timer_

## Static Private Attributes
static BatchProgram * | inst_

## Friends
class | BatchServiceServerMgr
BatchProgram & | BP ()
void | doWorkCB (CallBacker *)
void | Execute_batch (int *, char **)
void | launchDoWorkCB (CallBacker *)
void | loadModulesCB (CallBacker *)

## Additional Inherited Members
Protected Member Functions inherited from NamedCallBacker
void | sendDelNotif () const
Protected Attributes inherited from NamedCallBacker
Threads::Atomic< bool > | delalreadytriggered_
Notifier< NamedCallBacker > | delnotif_
Protected Attributes inherited from NamedObject
BufferString | name_

## Detailed Description

Main object for 'standard' batch programs.

Most 'interesting' batch programs need a lot of parameters to do the work. Therefore, in OpendTect, BatchPrograms need a 'parameter file', with all the info needed in IOPar format, i.e., keyword/value pairs.

This object takes over the details of reading that file, extracting 'standard' components from the parameters, opening sockets etc.,

To use the object, instead of defining a function 'main', you should define both functions: 'BatchProgram::loadModules': to load the required basic modules 'BatchProgram::doWork': to perform the core work Both functions have full access to a Qt event loop (required for timer, networking, ...).

If you need argc and/or argv outside these two functions, the BP() singleton instance can be accessed.

<>

## Member Enumeration Documentation

## ◆ Status

enum BatchProgram::Status

Enumerator
Start |
ParseFail |
ParseOK |
CommFail |
CommOK |
LogFail |
LogOK |
WorkWait |
WorkStarted |
WorkFail |
WorkPaused |
MoreToDo |
WorkOK |
Killed |
LockOK |

## Constructor & Destructor Documentation

## ◆ BatchProgram()

BatchProgram::BatchProgram | ( |  | ) |
| private

## ◆ ~BatchProgram()

BatchProgram::~BatchProgram | ( |  | ) |
| private

## Member Function Documentation

## ◆ canStartdoWork()

bool BatchProgram::canStartdoWork | ( |  | ) | const
| private

## ◆ clParser()

const CommandLineParser & BatchProgram::clParser | ( |  | ) |
| inline

## ◆ doFinalize()

void BatchProgram::doFinalize | ( |  | ) |
| private

## ◆ doWorkCB()

void BatchProgram::doWorkCB | ( | CallBacker * |  | ) |
| private

## ◆ eventLoopStartedCB()

void BatchProgram::eventLoopStartedCB | ( | CallBacker * |  | ) |
| private

## ◆ getLockFileFP()

const BufferString BatchProgram::getLockFileFP | ( |  | ) | const
| private

## ◆ initComm()

bool BatchProgram::initComm | ( |  | ) |
| private

## ◆ initLogging()

bool BatchProgram::initLogging | ( |  | ) |
| private

## ◆ jobId()

Batch::ID BatchProgram::jobId | ( |  | ) |
| inline private

## ◆ killNotify()

void BatchProgram::killNotify | ( | bool | yn | ) |
| private

## ◆ mExp() [1/16]

BatchProgram::mExp | ( | Batch |  | ) | const
| private

## ◆ mExp() [2/16]

BatchProgram::mExp | ( | Batch |  | ) | &

This method must be defined by user, and should contain the implementation

## ◆ mExp() [3/16]

BatchProgram::mExp | ( | Batch |  | ) | const &

## ◆ mExp() [4/16]

BatchProgram::mExp | ( | Batch |  | ) | const

## ◆ mExp() [5/16]

BatchProgram::mExp | ( | Batch |  | ) |
| private

## ◆ mExp() [6/16]

BatchProgram::mExp | ( | Batch |  | ) | const

## ◆ mExp() [7/16]

BatchProgram::mExp | ( | Batch |  | ) |

## ◆ mExp() [8/16]

BatchProgram::mExp | ( | Batch |  | ) | const
| inline private

## ◆ mExp() [9/16]

BatchProgram::mExp | ( | Batch |  | ) |
| private

## ◆ mExp() [10/16]

BatchProgram::mExp | ( | Batch |  | ) |
| private

## ◆ mExp() [11/16]

BatchProgram::mExp | ( | Batch |  | ) |
| private

## ◆ mExp() [12/16]

BatchProgram::mExp | ( | Batch |  | ) |

Must be implemented to load the basic modules required by the batch program, for example: OD::ModDeps().ensureLoaded( "Attributes" ); Can only be empty if the batch program does not depend on modules above Network

## ◆ mExp() [13/16]

BatchProgram::mExp | ( | Batch |  | ) |
| private

## ◆ mExp() [14/16]

BatchProgram::mExp | ( | Batch |  | ) |
| private

## ◆ mExp() [15/16]

BatchProgram::mExp | ( | Batch |  | ) |

## ◆ mExp() [16/16]

BatchProgram::mExp | ( | Batch |  | ) |
| private

## ◆ mmComm()

JobCommunic * BatchProgram::mmComm | ( |  | ) |
| inline private

## ◆ pars() [1/2]

IOPar & BatchProgram::pars | ( |  | ) |
| inline

## ◆ pars() [2/2]

const IOPar & BatchProgram::pars | ( |  | ) | const
| inline

## ◆ parseArguments()

bool BatchProgram::parseArguments | ( |  | ) |
| private

## ◆ progKilled()

void BatchProgram::progKilled | ( | CallBacker * |  | ) |
| private

## ◆ sKeyDataDir()

static const char * BatchProgram::sKeyDataDir | ( |  | ) |
| inline static

## ◆ sKeyFinishMsg()

static const char * BatchProgram::sKeyFinishMsg | ( |  | ) |
| static

## ◆ sKeySimpleBatch()

static const char * BatchProgram::sKeySimpleBatch | ( |  | ) |
| inline static

## ◆ sKeySurveyDir()

static const char * BatchProgram::sKeySurveyDir | ( |  | ) |
| inline static

## ◆ updateLockFilePars()

bool BatchProgram::updateLockFilePars | ( |  | ) | const
| private

## ◆ workMonitorCB()

void BatchProgram::workMonitorCB | ( | CallBacker * |  | ) |
| private

## Friends And Related Symbol Documentation

## ◆ BatchServiceServerMgr

friend class BatchServiceServerMgr
| friend

## ◆ BP

BatchProgram & BP | ( |  | ) |
| friend

## ◆ doWorkCB

void doWorkCB | ( | CallBacker * |  | ) |
| friend

## ◆ Execute_batch

void Execute_batch | ( | int * | pargc,
|  | char ** | argv )
| friend

## ◆ launchDoWorkCB

void launchDoWorkCB | ( | CallBacker * | cb | ) |
| friend

## ◆ loadModulesCB

void loadModulesCB | ( | CallBacker * |  | ) |
| friend

## Member Data Documentation

## ◆ batchprogthreadlock_

Threads::Lock BatchProgram::batchprogthreadlock_
| private

## ◆ cc_stderr

bool BatchProgram::cc_stderr =false)

## ◆ cc_stdout

bool BatchProgram::cc_stdout =false)

## ◆ clparser_

CommandLineParser* BatchProgram::clparser_ = nullptr
| private

## ◆ comm_

JobCommunic* BatchProgram::comm_ = nullptr
| private

## ◆ endWork

Notifier<BatchProgram> BatchProgram::endWork

## ◆ eventLoopStarted

Notifier<BatchProgram> BatchProgram::eventLoopStarted

## ◆ inst_

BatchProgram* BatchProgram::inst_
| static private

## ◆ iopar_

IOPar* BatchProgram::iopar_ = nullptr
| private

## ◆ jobid_

Batch::ID BatchProgram::jobid_
| private

## ◆ killed

Notifier<BatchProgram> BatchProgram::killed

## ◆ pause

Notifier<BatchProgram> BatchProgram::pause

## ◆ priority_

float BatchProgram::priority_ = 0.f
| private

## ◆ requests_

ObjectSet<OD::JSON::Object> BatchProgram::requests_
| private

## ◆ resume

Notifier<BatchProgram> BatchProgram::resume

## ◆ startDoWork

Notifier<BatchProgram> BatchProgram::startDoWork

## ◆ statelock_

Threads::Lock BatchProgram::statelock_
| private

## ◆ status_

Status BatchProgram::status_ = Start
| private

## ◆ strm_

od_ostream* BatchProgram::strm_ = nullptr
| private

## ◆ strmismine_

bool BatchProgram::strmismine_ = true
| private

## ◆ thread_

Threads::Thread* BatchProgram::thread_ = nullptr
| private

## ◆ timer_

Timer* BatchProgram::timer_
| private

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