OOStuBS - Technische Informatik II (TI-II)  2.4
job.cc
gehe zur Dokumentation dieser Datei
1 #include <user/job.h>
2 #include <user/appl.h>
3 #include <common/null.h>
4 #include <object/scheduler.h>
5 
6 Job::Job() : mState(stopped), mName(NULL), mApp(NULL){
7 
8 }
9 
10 Job::Job(Application& app, const char* name) : mState(stopped), mName(name), mApp(&app){
11 
12 }
13 
14 Job& Job::operator=(const Job& j){
15  mApp = j.mApp;
16  mState = j.mState;
17  mName = j.mName;
18 
19  return *this;
20 }
21 
22 bool Job::start(){
23  if(mApp && mState==stopped){
26  return true;
27  }
28  return false;
29 }
30 
31 bool Job::stop(){
32  if(mApp && mState==running){
35  return true;
36  }
37  return false;
38 }
39 
41  return mState;
42 }
43 
44 const char* Job::name() const{
45  return mName;
46 }
47 
49  return *mApp;
50 }
51 
53  o << j.name() << ": ";
54  switch(j.state()){
55  case(Job::stopped): return o << "stopped";
56  case(Job::running): return o << "running";
57  default : return o << "unknown";
58  }
59 }