NCBI C++ ToolKit
app_job_impl.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: app_job_impl.cpp 34478 2016-01-13 16:19:10Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  * File Description:
29  *
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
34 
36 
37 #include <corelib/guard.hpp>
38 
40 
41 
42 
43 //static const char* kDefaultErrorMessage = "CAppJob: Tool Execution Failed";
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 /// CAppJobProgress
48 : m_Done(0.0)
49 {
50 }
51 
52 
54 {
55  CReadLockGuard lock(progress.m_Lock);
56  x_CopyFrom(progress);
57 }
58 
60 {
61  CReadLockGuard lock(progress.m_Lock);
62  x_CopyFrom(progress);
63  return *this;
64 }
65 
66 
68 : m_Done(done),
69  m_Text(text)
70 {
71 }
72 
73 
75 {
76  CWriteLockGuard lock(m_Lock);
77  m_Done = done;
78 }
79 
80 
81 void CAppJobProgress::SetText(const string& text)
82 {
83  CWriteLockGuard lock(m_Lock);
84  m_Text = text;
85 }
86 
87 
89 {
90  CReadLockGuard lock(m_Lock);
91  return m_Done;
92 }
93 
94 
96 {
97  CReadLockGuard lock(m_Lock);
98  return m_Text;
99 }
100 
102 {
103  m_Done = progress.m_Done;
104  m_Text = progress.m_Text;
105 }
106 
107 
108 ///////////////////////////////////////////////////////////////////////////////
109 /// CAppJobError
110 CAppJobError::CAppJobError( const string& text, bool user_level )
111  : m_Text( text )
112  , m_UserLevel( user_level )
113 {
114 }
115 
116 
117 string CAppJobError::GetText() const
118 {
119  return m_Text;
120 }
121 
123 {
124  return m_UserLevel;
125 }
126 
127 
128 ///////////////////////////////////////////////////////////////////////////////
129 /// CAppJobTextResult
130 
132 : m_Text(text)
133 {
134 }
135 
136 
138 {
139  return m_Text;
140 }
141 
142 
143 
144 ///////////////////////////////////////////////////////////////////////////////
145 /// CAppJob
146 
147 CAppJob::CAppJob(const string& descr)
148 : m_Descr(descr)
149 {
150 }
151 
152 
153 void CAppJob::x_SetStatusText(const string& text)
154 {
155  CFastMutexGuard lock(m_Mutex);
156  m_Status = text;
157 }
158 
159 
161 {
162  CFastMutexGuard lock(m_Mutex);
163 
164  m_Error.Reset();
165 
166  m_Status = "Starting...";
167 }
168 
169 
170 
172 {
173  CFastMutexGuard lock(m_Mutex);
175  return pr;
176 }
177 
178 
180 {
181  return CRef<CObject>(); // we do not support this
182 }
183 
184 
186 {
188 }
189 
190 
191 string CAppJob::GetDescr() const
192 {
193  return m_Descr;
194 }
195 
196 
CAppJobProgress Default implementation for IAppJobProgress - the class encapsulates a text message an...
virtual bool IsUserLevel() const override
CRef< CAppJobError > m_Error
CGuiRWLock m_Lock
MT sync.lock.
virtual float GetNormDone() const override
return a number indicating the progress(0.0 - just started, 1.0 - done)
CAppJobProgress & operator=(const CAppJobProgress &progress)
string m_Descr
mutex to sync our internals
virtual void x_ResetState()
CAppJobTextResult(const string &text)
CAppJobTextResult.
virtual CConstIRef< IAppJobProgress > GetProgress() override
implement Run() in derived classes, make sure that exceptions are handled and m_StopRequested flag is...
CFastMutex m_Mutex
virtual string GetText() const override
returns a string describing the error
virtual void x_SetStatusText(const string &text)
virtual CConstIRef< IAppJobError > GetError() override
Returns IAppJobError object describing internal error that caused the Job to fail.
string m_Status
Current status of the Job.
CAppJobProgress()
CAppJobProgress.
void x_CopyFrom(const CAppJobProgress &progress)
copy constructor, assignment implementation
virtual string GetDescr() const override
Returns a human readable description of the Job (optional)
virtual string GetText() const
CAppJob(const string &descr="AppJob")
CAppJob.
virtual string GetText() const override
returns a text string describing current state
CAppJobError(const string &text, bool user_level=false)
CAppJobError.
virtual CRef< CObject > GetResult() override
Returns the Job Result.
void SetNormDone(float done)
void SetText(const string &text)
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static void text(MDB_val *v)
Definition: mdb_dump.c:62
done
Definition: token1.c:1
Modified on Wed May 01 14:23:32 2024 by modify_doxy.py rev. 669887