Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryJob.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _BERRY_JOB_H
18 #define _BERRY_JOB_H
19 
20 #include <Poco/Thread.h>
21 
22 #include <org_blueberry_core_jobs_Export.h>
23 // #include "berryISchedulingRule.h"
24 #include "berryJobExceptions.h"
25 #include "internal/berryInternalJob.h"
26 
27 #include <berryObject.h>
28 
29 #include <string>
30 
31 namespace berry
32 {
33 
34 struct IJobManager;
35 
63 //TODO struct Job: public InternalJob, public IAdaptable
64 class BERRY_JOBS Job: public InternalJob
65 {
66 
67 public:
68 
70 
77 
78  /* Job priorities */
89  static const int INTERACTIVE = 10;
100  static const int SHORT = 20;
108  static const int LONG = 30;
117  static const int BUILD = 40;
118 
129  static const int DECORATE = 50;
137  static const int NONE = 0;
144  static const int SLEEPING = 0x01;
150  static const int WAITING = 0x02;
156  static const int RUNNING = 0x04;
157 
163  static const IJobManager* GetJobManager();
164 
172  Job(const QString& name);
173 
180  void AddJobChangeListener(IJobChangeListener* listener);
181 
197  bool BelongsTo(Object::Pointer family) override;
198 
209  bool Cancel();
210 
226  void Done(IStatus::Pointer result);
227 
234  QString GetName() const;
235 
243  int GetPriority() const;
244 
254  //TODO QualifiedName GetPropertys
256 
263  IStatus::Pointer GetResult() const ;
264 
273  ISchedulingRule::Pointer GetRule() const;
274 
293  int GetState() const;
294 
301  Poco::Thread* GetThread() const;
302 
313  bool IsBlocking();
314 
325  bool IsSystem() const;
326 
336  bool IsUser() const;
337 
364  //TODO Error Join Problem InterruptedException
366 
373  void RemoveJobChangeListener(IJobChangeListener* listener);
374 
375 
385  void Schedule();
386 
409  void Schedule(Poco::Timestamp::TimeDiff delay);
410 
421  void SetName(const QString& name);
422 
431  void SetPriority(int priority);
432 
450  void SetProgressGroup(IProgressMonitor::Pointer group, int ticks);
451 
471  //TODO QualifiedName SetProperty
473 
482  void SetRule(ISchedulingRule::Pointer rule);
483 
495  void SetSystem(bool value);
496 
506  void SetUser(bool value);
507 
520  void SetThread(Poco::Thread* thread);
521 
539  virtual bool ShouldRun();
540 
557  virtual bool ShouldSchedule() override;
558 
571  bool Sleep();
572 
583  void WakeUp();
584 
594  void WakeUp(long delay);
595 
596 
597 protected:
598 
606  virtual void Canceling() override;
607 
634  virtual IStatus::Pointer Run(IProgressMonitor::Pointer myProgressMonitor) override = 0;
635 
636 };
637 
638 }
639 #endif /* BERRY_JOB_H */
static const IStatus::Pointer ASYNC_FINISH
Definition: berryJob.h:76
#define berryObjectMacro(...)
Definition: berryMacros.h:37
static std::string GetName(std::string fileName, std::string suffix)