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

Go to the SVN repository for this file.

1 #ifndef GUI_FRAMEWORK___COMPOSITE_APP_TASK__HPP
2 #define GUI_FRAMEWORK___COMPOSITE_APP_TASK__HPP
3 
4 /* $Id: app_task_impl.hpp 24498 2011-10-04 20:42:44Z 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 #include <corelib/ncbiobj.hpp>
36 
37 #include <gui/gui_export.h>
38 
40 
41 #include <gui/utils/app_job.hpp>
43 
44 
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 /// CAppTask - default implementation of IAppTask, use it as a base class for
49 /// custom tasks.
50 
52  public CObjectEx,
53  public IAppTask
54 {
55 public:
56  CAppTask(const string& descr = kEmptyStr, bool visible = true, int display_delay = 0);
57 
58  /// @name IAppTask interface implementation
59  /// @{
60  virtual ETaskState Run();
61  virtual ETaskState GetState();
62  virtual void CancelBackgrounded();
63  virtual void OnCancel();
64  virtual bool IsVisible();
66  virtual string GetDescr() const;
67  virtual string GetStatusText() const;
68  virtual void SetListener(CEventHandler* handler);
69  virtual IEventLogAction* CreateEventLogAction();
70  /// @}
71 
72  static string StateToString(ETaskState state);
73 
74 protected:
75  /// override this function in derived classes
76  virtual ETaskState x_Run();
77 
78  virtual bool x_IsFiniteState();
79 
80 protected:
82 
84  const bool m_Visible; ///< indicates whether the task is visible
85  string m_Descr; ///< task description
86  int m_DisplayDelay; ///< tasks display delay
87 };
88 
89 
90 ///////////////////////////////////////////////////////////////////////////////
91 /// CCompositeAppTask - an application task that consists of subtasks.
92 ///
93 /// CCompositeAppTask executes the subtask one by one. If a subtask goes into
94 /// background (pauses), the composite task also goes into background.
95 /// If a subtask fails the composite task will also terminate with eFailed status.
96 
98  public CAppTask,
99  public CEventHandler
100 {
102 public:
104 
105  CCompositeAppTask(const string& descr = kEmptyStr, bool visible = true);
106 
107  /// @name IAppTask interface implementation
108  /// @{
109  virtual ETaskState Run();
110  virtual void CancelBackgrounded();
111  /// @}
112 
113  void OnTaskEvent(CEvent* event);
114 
115 protected:
116  /// returns a references to the current subtask
118 
119  /// prepares the next subtask (makes it current), this function is used for
120  /// iterating subtasks.
121  virtual TTaskRef x_NextSubTask() = 0;
122 
123  /// runs the current subtask; one may override this function in order to
124  /// perform special pre-execution or post-execution actions
125  virtual ETaskState x_RunCurrentSubTask();
126 
127 protected:
128 
129 };
130 
131 
133 
134 #endif // GUI_FRAMEWORK___COMPOSITE_APP_TASK__HPP
CAppTask - default implementation of IAppTask, use it as a base class for custom tasks.
int m_DisplayDelay
tasks display delay
ETaskState m_State
CEventHandler * m_Listener
const bool m_Visible
indicates whether the task is visible
string m_Descr
task description
CCompositeAppTask - an application task that consists of subtasks.
virtual TTaskRef x_NextSubTask()=0
prepares the next subtask (makes it current), this function is used for iterating subtasks.
CIRef< IAppTask > TTaskRef
CCompositeAppTask(const string &descr=kEmptyStr, bool visible=true)
virtual TTaskRef x_GetCurrentSubTask()=0
returns a references to the current subtask
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CObjectEx –.
Definition: ncbiobj.hpp:2531
IAppTask.
Definition: app_task.hpp:83
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
virtual void CancelBackgrounded()=0
make a request to cancel backgrounded task (not called for foreground tasks)
virtual int GetStatusDisplayDelay()=0
returns delay in seconds used for certain fast (and not very important tasks) to only show its status...
virtual string GetStatusText() const =0
returns human-readable text describing the current task state
virtual void SetListener(CEventHandler *handler)=0
set a Listener; this allows a taks running in background to notify the Listener (usually Task Manager...
virtual ETaskState GetState()=0
returns the current task state
ETaskState
List of task states defining the task management FSM.
Definition: app_task.hpp:87
virtual void OnCancel()=0
this will be called on pending tasks that will be removed from the queue and won't get a chance to ru...
virtual string GetDescr() const =0
returns a human-readable description of the Task (optional)
virtual bool IsVisible()=0
returns true if the task should be visible in UI visible task shall represent operations understood b...
virtual IEventLogAction * CreateEventLogAction()=0
returns an action for activating task results (optional, can return NULL)
#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 kEmptyStr
Definition: ncbistr.hpp:123
void Run(void)
Enter the main loop.
#define NCBI_GUIFRAMEWORK_EXPORT
Definition: gui_export.h:509
Defines to provide correct exporting from DLLs in Windows.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Mon Mar 04 05:11:30 2024 by modify_doxy.py rev. 669887