Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
berryJob.h
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 #ifndef _BERRY_JOB_H
14 #define _BERRY_JOB_H
15 
16 #include <Poco/Thread.h>
17 
19 // #include "berryISchedulingRule.h"
20 #include "berryJobExceptions.h"
21 #include "internal/berryInternalJob.h"
22 
23 #include <berryObject.h>
24 
25 #include <string>
26 
27 namespace berry
28 {
29 
30 struct IJobManager;
31 
59 //TODO struct Job: public InternalJob, public IAdaptable
60 class BERRY_JOBS Job: public InternalJob
61 {
62 
63 public:
64 
66 
73 
74  /* Job priorities */
85  static const int INTERACTIVE = 10;
96  static const int SHORT = 20;
104  static const int LONG = 30;
113  static const int BUILD = 40;
114 
125  static const int DECORATE = 50;
133  static const int NONE = 0;
140  static const int SLEEPING = 0x01;
146  static const int WAITING = 0x02;
152  static const int RUNNING = 0x04;
153 
159  static const IJobManager* GetJobManager();
160 
168  Job(const QString& name);
169 
176  void AddJobChangeListener(IJobChangeListener* listener);
177 
193  bool BelongsTo(Object::Pointer family) override;
194 
205  bool Cancel();
206 
222  void Done(IStatus::Pointer result);
223 
230  QString GetName() const;
231 
239  int GetPriority() const;
240 
250  //TODO QualifiedName GetPropertys
252 
259  IStatus::Pointer GetResult() const ;
260 
269  ISchedulingRule::Pointer GetRule() const;
270 
289  int GetState() const;
290 
297  Poco::Thread* GetThread() const;
298 
309  bool IsBlocking();
310 
321  bool IsSystem() const;
322 
332  bool IsUser() const;
333 
360  //TODO Error Join Problem InterruptedException
362 
369  void RemoveJobChangeListener(IJobChangeListener* listener);
370 
371 
381  void Schedule();
382 
405  void Schedule(Poco::Timestamp::TimeDiff delay);
406 
417  void SetName(const QString& name);
418 
427  void SetPriority(int priority);
428 
446  void SetProgressGroup(IProgressMonitor::Pointer group, int ticks);
447 
467  //TODO QualifiedName SetProperty
469 
478  void SetRule(ISchedulingRule::Pointer rule);
479 
491  void SetSystem(bool value);
492 
502  void SetUser(bool value);
503 
516  void SetThread(Poco::Thread* thread);
517 
535  virtual bool ShouldRun();
536 
553  bool ShouldSchedule() override;
554 
567  bool Sleep();
568 
579  void WakeUp();
580 
590  void WakeUp(long delay);
591 
592 
593 protected:
594 
602  void Canceling() override;
603 
630  IStatus::Pointer Run(IProgressMonitor::Pointer myProgressMonitor) override = 0;
631 
632 };
633 
634 }
635 #endif /* BERRY_JOB_H */
#define BERRY_JOBS
static const IStatus::Pointer ASYNC_FINISH
Definition: berryJob.h:72
#define berryObjectMacro(...)
Definition: berryMacros.h:33
static std::string GetName(std::string fileName, std::string suffix)
void Run(berry::IWorkbenchPartSite::Pointer workbenchPartSite, mitk::DataStorage::Pointer dataStorage)