NCBI C++ ToolKit
app_job_engine.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___APP_JOB_ENGINE__HPP
2 #define GUI_OBJUTILS___APP_JOB_ENGINE__HPP
3 
4 /* $Id: app_job_engine.hpp 24876 2011-12-16 16:03:41Z kuznets $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 /** @addtogroup GUI_UTILS
36 *
37 * @{
38 */
39 
40 #include <gui/utils/app_job.hpp>
41 
43 
45 
46 
47 class IEngineParams;
48 
49 ///////////////////////////////////////////////////////////////////////////////
50 /// IAppJobEngine
51 ///
52 /// Base interface for building engines for background job execution
53 ///
54 /// @sa IAppJob
56 {
57 public:
60 
61  virtual ~IAppJobEngine() {};
62 
63  /// Returns true if Engine supports "active" model i.e. will send
64  /// notifications to Dispatcher when a Job running on this Engine changes
65  /// its state.
66  virtual bool IsActive() = 0;
67 
68  /// For "active" mode set a Listener that will be notified when
69  /// the state of a Job changes.
70  virtual void SetListener(IAppJobEngineListener* listener) = 0;
71 
72  /// If Engine cannot start the Job and exception shall be thrown.
73  virtual void StartJob(IAppJob& job, IEngineParams* params = NULL) = 0;
74 
75  /// Cancel job in the engine
76  /// If job is not running yet - just remove from the pending queue
77  /// otherwise uses IInterruptible to notify the job about cancel request
78  virtual void CancelJob(IAppJob& job) = 0;
79  virtual void SuspendJob(IAppJob& job) = 0;
80  virtual void ResumeJob(IAppJob& job) = 0;
81 
82  /// @return current job state
83  virtual TJobState GetJobState(IAppJob& job) const = 0;
84 
85  /// stop any background threads and free resources associated with the Engine
86  virtual void ShutDown() = 0;
87 
88  /// asyncronous request all jobs to Cancel
89  virtual void RequestCancel() = 0;
90 };
91 
92 
93 ///////////////////////////////////////////////////////////////////////////////
94 /// IAppJobEngineParams
95 /// A base class for Engine Parmeters classes. If Engine takes additional
96 /// parameters that affect Job execution, then a special class need to be
97 /// derived from IAppJobEngineParams. The class shall provide functions for
98 /// setting and getting Engine-specific parameters, an instance of this class
99 /// could be passed to StartJob() function together with a Job object.
101 {
102 public:
103  virtual ~IAppJobEngineParams() {}
104 };
105 
106 
108 
109 /* @} */
110 
111 #endif // GUI_OBJUTILS___APP_JOB_ENGINE__HPP
CAppJobDispatcher.
IAppJobEngineListener - receives notifications about changes in job state.
IAppJobEngineParams A base class for Engine Parmeters classes.
IAppJobEngine.
IAppJob.
Definition: app_job.hpp:82
#define NULL
Definition: ncbistd.hpp:225
virtual void StartJob(IAppJob &job, IEngineParams *params=NULL)=0
If Engine cannot start the Job and exception shall be thrown.
virtual void ResumeJob(IAppJob &job)=0
virtual void SuspendJob(IAppJob &job)=0
virtual void SetListener(IAppJobEngineListener *listener)=0
For "active" mode set a Listener that will be notified when the state of a Job changes.
virtual void RequestCancel()=0
asyncronous request all jobs to Cancel
virtual void CancelJob(IAppJob &job)=0
Cancel job in the engine If job is not running yet - just remove from the pending queue otherwise use...
CAppJobDispatcher TDisp
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
virtual ~IAppJobEngine()
virtual bool IsActive()=0
Returns true if Engine supports "active" model i.e.
virtual ~IAppJobEngineParams()
virtual TJobState GetJobState(IAppJob &job) const =0
IAppJob::EJobState TJobState
virtual void ShutDown()=0
stop any background threads and free resources associated with the Engine
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIUTILS_EXPORT
Definition: gui_export.h:518
#define NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
Modified on Fri May 24 14:54:57 2024 by modify_doxy.py rev. 669887