Medical Imaging Interaction Toolkit  2018.4.99-1bab67a2
Medical Imaging Interaction Toolkit
berryJob.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "berryJob.h"
14 #include "berryIJobManager.h"
15 #include "internal/berryJobManager.h"
16 #include "berryIStatus.h"
17 #include "berryStatus.h"
18 
19 #include <string>
20 
21 namespace berry
22 {
23 
24 
25 
27  new Status (IStatus::OK_TYPE, JobManager::PI_JOBS(),
28  1,
29  "",
30  berry::Status::SourceLocation(__FILE__, "berry::Job::ASYNC_FINISH", __LINE__)
31  ));
32 
33 Job::Job(const QString& name)
34  : InternalJob(name)
35 {
36 }
37 
39 {
40  return ptr_manager;
41 }
42 
43 
45 {
46  return false;
47 }
48 
50 {
51  return InternalJob::Cancel();
52 }
53 
55 {
56  InternalJob::Done(result);
57 }
58 
59 QString Job::GetName() const
60 {
61  return InternalJob::GetName();
62 }
63 
64 int Job::GetPriority() const
65 {
66  return InternalJob::GetPriority();
67 }
68 
69 // TODO QualifiedName muss noch implementiert werden
70 // Object Job::GetProperty(QualifiedName key)
71 // {
72 // return InternalJob::GetProperty(key);
73 // }
74 
75 
77  {
78  return InternalJob::GetResult();
79  }
80 
82 {
83  return InternalJob::GetRule();
84 }
85 
86 int Job::GetState() const
87 {
88  return InternalJob::GetState();
89 }
90 
91 Poco::Thread*
93 {
94  return InternalJob::GetThread();
95 }
96 
98 {
99  return InternalJob::IsBlocking();
100 }
101 
102 bool Job::IsSystem() const
103 {
104  return InternalJob::IsSystem();
105 }
106 
107 bool Job::IsUser() const
108 {
109  return InternalJob::IsUser();
110 }
111 
112 // TODO Join
113 //void Job::Join()
114 // throw (InterruptedException)
115 // {
116 // InternalJob::Join();
117 // }
118 
120 {
121  InternalJob::RemoveJobChangeListener(listener);
122 }
123 
125 {
126  Poco::Timestamp::TimeDiff tmpNoDelay = 0;
127  InternalJob::Schedule(tmpNoDelay);
128 }
129 
130 void Job::Schedule(Poco::Timestamp::TimeDiff delay)
131 {
132  InternalJob::Schedule(delay);
133 }
134 
135 void Job::SetName(const QString& name)
136 {
137  InternalJob::SetName(name);
138 }
139 
140 void Job::SetPriority(int priority)
141 {
142  InternalJob::SetPriority(priority);
143 }
144 
146 {
147  InternalJob::SetProgressGroup(group, ticks);
148 }
149 
150 // TODO SetProperty
151 // void Job::SetProperty(QualifiedName key, Object value)
152 // {
153 // InternalJob::SetProperty(key, value);
154 // }
155 
157 {
158  InternalJob::SetRule(rule);
159 }
160 
161 void Job::SetSystem(bool value)
162 {
163  InternalJob::SetSystem(value);
164 }
165 
166 void Job::SetUser(bool value)
167 {
168  InternalJob::SetUser(value);
169 }
170 
171 void Job::SetThread(Poco::Thread* thread)
172 {
173  InternalJob::SetThread(thread);
174 }
175 
177 {
178  return true;
179 }
180 
182 {
183  return true;
184 }
185 
187 {
188  return InternalJob::Sleep();
189 }
190 
192 {
193  InternalJob::WakeUp(0);
194 }
195 
196 void Job::WakeUp(long delay)
197 {
198  InternalJob::WakeUp(delay);
199 }
200 
202 {
203  //default implementation does nothing
204 }
205 
206 }
void SetSystem(bool value)
Definition: berryJob.cpp:161
berry::SmartPointer< Self > Pointer
Definition: berryIStatus.h:54
static const IJobManager * GetJobManager()
Definition: berryJob.cpp:38
bool IsBlocking()
Definition: berryJob.cpp:97
void WakeUp()
Definition: berryJob.cpp:191
virtual bool ShouldRun()
Definition: berryJob.cpp:176
Job(const QString &name)
Definition: berryJob.cpp:33
void SetUser(bool value)
Definition: berryJob.cpp:166
ISchedulingRule::Pointer GetRule() const
Definition: berryJob.cpp:81
QString GetName() const
Definition: berryJob.cpp:59
Poco::Thread * GetThread() const
Definition: berryJob.cpp:92
IStatus::Pointer GetResult() const
Object GetProperty(QualifiedName key) const ;.
Definition: berryJob.cpp:76
void Canceling() override
Definition: berryJob.cpp:201
static const IStatus::Pointer ASYNC_FINISH
Definition: berryJob.h:72
void RemoveJobChangeListener(IJobChangeListener *listener)
void Join() ;
Definition: berryJob.cpp:119
bool ShouldSchedule() override
Definition: berryJob.cpp:181
void Done(IStatus::Pointer result)
Definition: berryJob.cpp:54
int GetState() const
Definition: berryJob.cpp:86
void SetProgressGroup(IProgressMonitor::Pointer group, int ticks)
Definition: berryJob.cpp:145
bool BelongsTo(Object::Pointer family) override
Definition: berryJob.cpp:44
void SetName(const QString &name)
Definition: berryJob.cpp:135
void SetPriority(int priority)
Definition: berryJob.cpp:140
int GetPriority() const
Definition: berryJob.cpp:64
bool Sleep()
Definition: berryJob.cpp:186
static std::string GetName(std::string fileName, std::string suffix)
bool IsSystem() const
Definition: berryJob.cpp:102
void Schedule()
Definition: berryJob.cpp:124
void SetThread(Poco::Thread *thread)
Definition: berryJob.cpp:171
void SetRule(ISchedulingRule::Pointer rule)
void SetProperty(QualifiedName key, Object value);
Definition: berryJob.cpp:156
bool Cancel()
Definition: berryJob.cpp:49
bool IsUser() const
Definition: berryJob.cpp:107